Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

6
  • Thank you for your answer. However, I should express my question more clearly. It seems like you're counting the number of yellow/red pixels in the "mask". I want to use those color to select the "region of interest" in the original image. As in, what pixels are contained within that region marked by the yellow / red blobs. Commented Feb 3, 2021 at 2:41
  • That's exactly what you answered in the comments when I asked you to clarify what you wanted! If you want to do something with the pixels in the original image, you can just AND them with the masks I worked out since my masks are Boolean True/False at each pixel location. Commented Feb 3, 2021 at 7:28
  • Can you explain how you can perform bitwise AND on a tuple (RGB) since that's what the original image is represented as? I know opencv provides the function, but I assume you would have to somehow map the tuples to an integer? Commented Feb 3, 2021 at 7:49
  • How could the original image be a tuple? You are using OpenCV which stores images as Numpy arrays and you refer to np.where() in your question. Please state clearly exactly what you want as an answer. Thank you. Commented Feb 3, 2021 at 8:03
  • I am reading the image like this. img = cv2.imread(name, COLOR_BGR2RGB). Since each pixel has three channels, it makes sense that it is a tuple? Printing out img gives something like [[255,255,255],[255,255,255]....]. I want to know how can I perform a bitwise AND using the image and mask above. Thank you Commented Feb 3, 2021 at 8:17