Colors distance: best Space and formula?

Started by
1 comment, last by cignox1 12 years, 9 months ago
Hi all,
I need an algorithm that takes a color and returns the closest matching color from a palette of 10-12. So far I experimented with euclidean distance in RGB, Lab and HSV, but still I get sometimes the wrong result. I started by using imageMagick with remap option, but it gave very poor matches (violet would become grey, green would become brown and so on) so I ended up writing my own algo.

Now, in a couple of days I will be able to run the app on a wider images repository to get some stats, but I already know that sometimes it simply won't work. The problem could be splitted in 3 parts:

-best color space
-best distance formula
-best target palette

Currently, best results are given by Lab (but with notable errors) and the solution proposed on http://www.compuphase.com/cmetric.htm, that is what I'm currently using.

Anyone knows other solutions/tips?

Thank you
Advertisement
What about trying also some dithering? Floyd-Steinberg error-spreading for example and for error metric you could use your own formula.

What about trying also some dithering? Floyd-Steinberg error-spreading for example and for error metric you could use your own formula.


Dithering would make the image more pleseant to look at, but I don't really need the output image: I just need to extract the dominant colors of the subject to implement color-based saearch in an online shop.
What I do is retrieving the histogram and taking just the first entries into consideration. But then (or before) I need to remap those values to my predefined palette, and this is where I get struck...


This topic is closed to new replies.

Advertisement