The difference or distance between two colors is a metric of interest in color science. It allows quantified examination of a notion that formerly could only be described with adjectives. Quantification of these properties is of great importance to those whose work is color critical. Common definitions make use of the Euclidean distance in a device independent color space.
As most definitions of color distance are distances within a color space, the standard means of determining distances is the Euclidean distance. If one presently has an RGB (Red, Green, Blue) tuple and wishes to find the color difference, computationally one of the easiest is to call R, G, B linear dimensions defining the color space.
When the result should be both computationally simple as well, it is often acceptable to remove the square root and simply use:
This will work in cases when a single color is to be compared to a single color and the need is to simply know whether a distance is greater. If these squared color distances are summed, such a metric effectively becomes the variance of the color distances.
There have been many attempts to weight RGB values to better fit human perception, where the components are commonly weighted (red 30%, green 59%, and blue 11%), however these are demonstratively worse at color determinations and are properly the contributions to the brightness of these colors, rather than to the degree to which human vision has less tolerance for these colors. The closer approximations would be more properly coefficients of 2, 4, and 3
one of the better low-cost approximations (using a color range of 0–255),
There are a number of color distance formulae that attempt to use color spaces like HSV with the hue as a circle, placing the various colors within a three dimensional space of either a cylinder or cone, but most of these are just modifications of RGB without accounting for differences in human color perception they will tend to be on par with a simple Euclidean metric.
The International Commission on Illumination (CIE) calls their distance metric ΔE*ab (also called ΔE*, or, inaccurately, dE*, dE, or "Delta E") where delta is a Greek letter often used to denote difference, and E stands for Empfindung; German for "sensation". Use of this term can be traced back to the influential Hermann von Helmholtz and Ewald Hering.