how to check in python if a pixel in an image is of a specific color? (other than black and white for grey image)
Example image:
Here I want to check if a pixel is of green color.
Only getting a BGR value from a pixel and changing it is mentioned here in the Basic Operations on Images in python
What will be the python command that I would have to use to check a pixel?
YourImage[coordinate_X , coordinate_Y]] ; you'll get an array of R G B data if its green then its 0 255 0 You can also use cv2.inRange to check green color.
@Ziri How do I check this in a condition like IF statement? (We are talking about python I hope, not C++) ๐
Try : color = YourImage[coordinate_X , coordinate_Y]] ; if ( color[0] == 0 && color[1] == 255 && color[2] ==0) --> Its green