1274

7
+7  Q:

## Followup: Finding an accurate "distance" between colors

Original Question

I am looking for a function that attempts to quantify how "distant" (or distinct) two colors are. This question is really in two parts:

1. What color space best represents human vision?
2. What distance metric in that space best represents human vision (euclidean?)
A:

May look like spam but no, this link is really interesting for color spaces :)

http://www.compuphase.com/cmetric.htm

A:

The easiest distance would of course be to just consider the colors as 3d vectors originating from the same origin, and taking the distance between their end points.

If you need to consider such factors that green is more prominent in judging intensity, you can weigh the values.

ImageMagic provides the following scales:

• red: 0.3
• green: 0.6
• blue: 0.1

Of course, values like this would only be meaningful in relation to other values for other colors, not as something that would be meaningful to humans, so all you could use the values for would be similiarity ordering.

+3  A:

HSL and HSV are better for human color perception. According to Wikipedia:

It is sometimes preferable in working with art materials, digitized images, or other media, to use the HSV or HSL color model over alternative models such as RGB or CMYK, because of differences in the ways the models emulate how humans perceive color. RGB and CMYK are additive and subtractive models, respectively, modelling the way that primary color lights or pigments (respectively) combine to form new colors when mixed.

+1  A:

Well, as a first point of call, I'd say of the common metrics HSV (Hue, Saturation and Value) or HSL are better representative of how humans perceive colour than say RGB or CYMK. See HSL, HSV on Wikipedia.

I suppose naively I would plot the points in the HSL space for the two colours and calculate the magnitude of the difference vector. However this would mean that bright yellow and bright green would be considered just as different as green to dark green. But then many consider red and pink two different colours.

Moreover, difference vectors in the same direction in this parameter space are not equal. For instance, the human eye picks up green much better than other colours. A shift in hue from green by the same amount as a shift from red may seem greater. Also a shift in saturation from a small amount to zero is the difference between grey and pink, elsewhere the shift would be the difference between two shades of red.

From a programmers point of view, you would need to plot the difference vectors but modified by a proportionality matrix that would adjust the lengths accordingly in various regions of the HSL space - this would be fairly arbitrary and would be based on various colour theory ideas but be tweaked fairly arbitrarily depending on what you wanted to apply this to.

Even better, you could see if anyone has already done such a thing online...

+1  A:

The Wikipedia article on color differences lists a number of color spaces and distance metrics designed to agree with human perception of color distances.

+10  A:

Convert to La*b* (aka just plain "Lab", and you'll also see reference to "CIELAB"). A good quick measaure of color difference is

(L1-L2)^2 + (a1-a2)^2 + (b1-b2)^2

Color scientists have other more refined measures, which may not be worth the bother, depending on accuracy needed for what you're doing.

The a and b values represent opposing colors in a way similar to how cones work, and may be negative or positive. Neutral colors - white, grays are a=0, b=0. The L is brightness defined in a particular way, from zero (pure darkness) up to whatever. Crude explanation: Given a color, our eyes distinguish between two broad ranges of wavelength - blue vs longer wavelengths. and then, thanks to a more recent genetic mutation, the longer wavelength cones bifurcated into two, distinguishing for us red vs. green. By the way, it'll be great for your career to rise above your color caveman collegues who know of only "RGB" or "CMYK" which are great for devices but suck for serious perception work. I've worked for imaging scientists who didn't know a thing about this stuff!

For more fun reading on color difference theory, try http://white.stanford.edu/~brian/scielab/introduction.html and info and links on color theory in general, websurf starting with http://www.efg2.com/Lab/Library/Color/ and http://www.poynton.com/Poynton-color.html More detail on Lab at http://en.kioskea.net/video/cie-lab.php3; i can't at this time find a non-ugly page that actually had the conversion formulas but i'm sure someone will edit this answer to include one..

Regarding the ugliness of the conversion formulas: they're ugly for a reason, since getting from RGB to XYZ to LAB depends on viewing conditions. cf: (warning, ugliness) http://www.easyrgb.com/index.php?X=MATH
+1  A:

As someone who is color blind I believe it is good to try to add more separation then normal vision. The most common form of color blindness is red/green deficiency. It doesn't mean that you can't see red or green, it means that it is more difficult to see and more difficult to see the differences. So it takes a larger separation before a color blind person can tell the difference.