Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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.

like image 421
Tjelle Avatar asked Jan 29 '09 15:01

Tjelle


People also ask

How is color difference calculated?

For two samples in Riemannian colour space, the colour difference can be calculated by integrating the quadratic equation for curvature along the geodesic distance between the points and dividing the result by a constant called least perceptible difference (McDonald 1982; Wyszecki and Stiles, 1982).

How do you measure the closeness of two colors?

In order to measure the difference between two colors, the difference is assigned to a distance within the color space. In an equidistant-method color space, the color difference ∆E can be determined from the distance between the color places: ΔE = √ (L*₁-L*₂)² + (a*₁-a*₂)² + (b*₁-b*₂)².

How do you compare two colors?

The most common method would be a visual color comparison by looking at two physical color samples side by side under a light source. Color is very relative, so you can compare colors in terms of the other color across dimensions such as hue, lightness and saturation (brightness).

What is identified as the difference between two colors *?

Color difference can be defined as the numerical comparison of a sample's color to the standard. It indicates the differences in absolute color coordinates and is referred to as Delta (Δ).


1 Answers

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.

like image 170
Jeff Yates Avatar answered Nov 02 '22 04:11

Jeff Yates