Alex Rivera | Logout

Is there an easy way to compare how close two colors are to each other?

Asked 2009-01-29T15:59:30.597
24

Is there a way to compare how close two colors are to each other? If to say both of them are blue.
At the moment the way that we compare them is to manually assign each possible color to a color family(red, green, blue...). And then just compare the strings :)
But surely that manual task can be assigned to a neat little algorithm.

Edit
Report

1 Answer

22

You probably want to convert the colors to an HSL model (Hue, Saturation, Lightness) and then compare the values within thresholds in the order HSL. If the hue is within a tolerance deemed as "close", then check the "closeness" of the saturation, and then the lightness.

answered 2009-01-29T16:03:31.807

Your Answer