I am trying to detect green colour from images, for that I using cv2, by defining upper and lower limit of green colour as [40, 0, 0]
and [90, 255, 255]
, this works well,
but, when I tested this image, I got detected the white region also, the output is mask image, the expected mask output is only black colour
the code is
frame = cv2.imread('img.jpg')
hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)
lower = np.array([40, 0, 0])
upper = np.array([90, 255, 255])
mask = cv2.inRange(hsv, lower, upper)
res = cv2.bitwise_and(frame,frame, mask= mask)
cv2.imshow('mask',mask)
Why the upper and lower bound of green detects the white regions in the input image, and is there any other way to detect only green colour from the image
thanks