Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Counting the number of colours in an image

Can someone guide me on a way to count the number of colours in an image? My idea is to take an RGB image, convert it to HSV and then split the channels so I only have the Hue channel. Then within the Hue channel, I would like to know if there are for example 50 pixels that have the value 123 and 25 pixels with the value 160 and so forth. Any guidance please on the methods I can use to do this?

The reason for doing this is, given 2 images A & B. I will have the number of colours of each image, then compare whether the two images share the same number of colours. For example, both images have 50 pixels with the value 123 etc.

Thank you in advance