We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello,
I am wondering if there is a way of finding 3 unique dominant colours in an image. So far I am able to find average colour and the colour from specified locations in an image but I am trying to create a colour palette using 3 different colors from an image. I suppose there will be 2 parts to this:
Identifying dominant colours
&
determining if they are suitably different from each other (so that they are visibly different to the viewer).
If anyone could point me in the right direction then that would be great!
Answers
Finding the three most used colors from an image is relatively simple. There are sketches around (use the search from the main site) that can compute the frequency of each color.
You can then sort these colors by order of frequency.
The main issue, as you guessed, is that it is probable, on most images (like photos), that these colors are close.
So you have to take the first color, go down on the list until you find a color different enough, and repeat for the third one.
The problem is defining "different enough". Perhaps you should get the hue() value and see if the difference is big enough.