i want to detect an image is green in python using the ycbcr color space on open cv, I've tried to define the lower and upper bounds of the color. but still having trouble finding the right format. here my code :
img4 = cv.cvtColor(img3, cv.COLOR_BGR2YCrCb)
lower_green = np.array([93, 147, 72])
upper_green = np.array([75, 113, 87])
mask_green = cv.inRange(img4,lower_green, upper_green)
green = cv.bitwise_and(img4,img4, mask=mask_green)
cv.imshow('Original2 Image',img4 )
cv.imshow('mask green color',green )
and how do I detect color if I have a lot of images, for example if I have 100 images of apples and there are red and green colors, do I have to do it bitwise or between the lower and upper limits of red and green?, and whether the masking is done during the import iteration of the image or when the image has been inserted into the array like :
data = []
data.append(im)
X = np.array(data)