0

What is the most accurate algorithm to calculate the difference between 2 RGBA colors?

By accurate I mean close to human perception.

NeoWang
  • 17,361
  • 24
  • 78
  • 126
  • 2
    also HSV si a good match see related [RGB value base color name](http://stackoverflow.com/a/37476754/2521214) But you need to take in to account/consideration that all of the color spaces are just tri-chromat approximations of **fully integrated** X,Y,Z perception inputs. The real human perception of color difference is also wavelength and spectral distribution dependent which standard RGB colors have no information of as they are just tri-chromat. Not to mention each human has different sensitivity curves. Another thing is you want compare just colors or the intensity too? equations differs. – Spektre Sep 29 '16 at 06:03
  • To tell you the truth, nobody knows. But see @matt's answer. –  Sep 29 '16 at 06:52

1 Answers1

5

The most practical way is usually to convert the colors to the CIEUVW or CIELAB color space, and then take the normal Euclidean distance to be the color distance.

Both of these color spaces were designed to approximate "perceptual uniformity", so that this distance is good approximation of human-perceived color difference for colors that are "reasonably close".

See: https://en.wikipedia.org/wiki/CIE_1964_color_space https://en.wikipedia.org/wiki/Lab_color_space

Matt Timmermans
  • 53,709
  • 3
  • 46
  • 87