Search code examples
image-processingcomparisoncolors

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


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.


Solution

  • Delta-e, is a single number that represents the perceived 'distance' between two colors. The lower the number, the more similar the colors are to the human eye.

    There are a few different ways to calculate it...CIE76 (aka CIE 1976 or dE76) being the most popular.

    Each one goes about things in a different way, but for the most part they all require you to convert to a better (for comparison) color model than RGB.

    For CIE76 you basically just convert your colors to the LAB color space, then compute the 3 dimensional distance between them.

    Wikipedia has all the formulae: http://en.wikipedia.org/wiki/Color_difference

    You can check your work with online color calculators: