I am using colour space segmentation to detect traffic signs of multiple colours.
This is my code:
img = cv.imread('055_0039.png')
img_hsv = cv.cvtColor(img, cv.COLOR_BGR2HSV)
img_hsv = cv.GaussianBlur(img_hsv, (5, 5), 0)
low_red_hsv = (0, 70, 50)
high_red_hsv = (10, 255, 255)
low_red_light = (170, 70, 50)
high_red_light = (180, 255, 255)
low_blue = (100,150,0)
high_blue = (120,255,255)
low_yellow = (20, 100, 100)
high_yellow = (30, 255, 255)
mask_yellow = cv.inRange(img_hsv, low_yellow, high_yellow)
mask_blue = cv.inRange(img_hsv, low_blue, high_blue)
mask_red = cv.inRange(img_hsv, low_red_hsv, high_red_hsv)
mask_red_light = cv.inRange(img_hsv, low_red_light, high_red_light)
mask = mask_red | mask_red_light | mask_blue | mask_yellow
#mask = cv.inRange(img_hsv, low_blue, high_blue)
res = cv.bitwise_and(img, img, mask = mask)
result = cv.cvtColor(res, cv.COLOR_BGR2RGB)
plt.subplot(1,2,1)
plt.imshow(mask, cmap = 'gray')
plt.subplot(1,2,2)
plt.imshow(result)
plt.show()
for images with no white colours in it, this will be the output:
but I want to also segment the white colours of these images:
Am I doing something wrong with my code here?