Sign in to follow this  

Colors distance: best Space and formula?

Recommended Posts

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, that is what I'm currently using.

Anyone knows other solutions/tips?

Thank you

Share this post

Link to post
Share on other sites
[quote name='pcmaster' timestamp='1310387226' post='4833696']
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...

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this