1

I'd like to quantify the number of pixels in an image based on their color, ignoring black background pixels. The heights are predefined and organized by color.

Color map. Each color corresponds to a range of heights.

Since the colors are set, it shouldn't be too difficult to count the pixels. However, doing this with RGB tuples is difficult. Can the RGB image input be converted to hex so that green RGB values of 0, 255, 1 = hex #00ff01, and then all the pixels of that hex value added up?

Example of image to have pixels quantified.

Basically I'm trying to see how these images change as I alter parameters that generate their output. Thought a good "scientific" way would be to count the pixels to see if more are green, less are yellow, orange, and red, than just visually looking through.

Thanks.

  • [Something like this?](https://stackoverflow.com/a/52079022/8881141) [Or this?](https://stackoverflow.com/a/59671950/8881141) I guess, scipy has also some features that may be of help. – Mr. T Oct 27 '20 at 18:55
  • 1
    If you look at your pixels in detail you will find there are actually 10,364 different colours in your image, so you'll need to define a range of colours that you consider green, for example. Have a read here https://en.m.wikipedia.org/wiki/HSL_and_HSV and have a read here too https://stackoverflow.com/search?tab=newest&q=%5bopencv%5d%20hsv – Mark Setchell Oct 27 '20 at 19:00

0 Answers0