In
color science
Color science is the science, scientific study of color including lighting and optics; Photometry (optics), measurement of light and colorimetry, color; the physiology, psychophysics, and color model, modeling of color vision; and color reproductio ...
, color difference or color distance is the separation between two
color
Color (or colour in English in the Commonwealth of Nations, Commonwealth English; American and British English spelling differences#-our, -or, see spelling differences) is the visual perception based on the electromagnetic spectrum. Though co ...
s. This
metric
Metric or metrical may refer to:
Measuring
* Metric system, an internationally adopted decimal system of measurement
* An adjective indicating relation to measurement in general, or a noun describing a specific type of measurement
Mathematics
...
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 mathematics, the Euclidean distance between two points in Euclidean space is the length of the line segment between them. It can be calculated from the Cartesian coordinates of the points using the Pythagorean theorem, and therefore is o ...
in a
device-independent color space
A color space is a specific organization of colors. In combination with color profiling supported by various physical devices, it supports reproducible representations of colorwhether such representation entails an analog or a digital represe ...
.
Euclidean
sRGB
As most definitions of color difference are distances within a
color space
A color space is a specific organization of colors. In combination with color profiling supported by various physical devices, it supports reproducible representations of colorwhether such representation entails an analog or a digital represe ...
, 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 consider ''R'', ''G'', ''B'' linear dimensions defining the color space.
A very simple example can be given between the two colors with RGB values (0, 64, 0) () and (255, 64, 0) (): their distance is 255. Going from there to (255, 64, 128) () is a distance of 128.
When we wish to calculate distance from the first point to the third point (i.e. changing more than one of the color values), we can do this:
When the result should be 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
In probability theory and statistics, variance is the expected value of the squared deviation from the mean of a random variable. The standard deviation (SD) is obtained as the square root of the variance. Variance is a measure of dispersion ...
of the color distances.
There have been many attempts to
weigh RGB values, however these are demonstrably 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 (for non-linear
sRGB
sRGB (standard RGB) is a colorspace, for use on monitors, printers, and the World Wide Web. It was initially proposed by HP and Microsoft in 1996 and became an official standard of the International Electrotechnical Commission (IEC) as IEC 6 ...
, using a color range of 0–255):
[
where:
One of the better low-cost approximations, sometimes called "redmean", combines the two cases smoothly:]
There are a number of color distance formulae that attempt to use color spaces like HSV or HSL with the hue represented 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.
Uniform color spaces
CIELAB and CIELUV are relatively perceptually-uniform color spaces and they have been used as spaces for Euclidean measures of color difference. The CIELAB version is known as CIE76. However, the non-uniformity of these spaces were later discovered, leading to the creation of more complex formulae.
A uniform color space is supposed to make a simple measure of color difference, usually Euclidean, "just work". Color spaces that improve on this issue include CAM02-UCS, CAM16-UCS, and Jzazbz.
Rec. ITU-R BT.2124 or Δ''E''ITP
In 2019 a new standard for WCG and HDR was introduced, since CIEDE2000 was not adequate for it: CIEDE2000 is not reliable below 1 cd/m2 and has not been verified above 100 cd/m2; in addition, even in BT.709 blue primary CIEDE2000 is underpredicting the error. Δ''E''ITP is scaled so that a value of 1 indicates the potential of a just noticeable color difference. The Δ''E''ITP color difference metric is derived from display referenced ICTCP, but XYZ is also available in the standard. The formula is a simply scaled Euclidean distance:
where the components of this "ITP" is given by
: ''I'' = ''I'',
: ''T'' = 0.5 ''C''''T'',
: ''P'' = ''C''''P''.
Other geometric constructions
The Euclidean measure is known to work poorly on large color distances (i.e. more than 10 units in most systems). A hybrid approach where a taxicab distance is used between the lightness and the chroma plane, , is shown to work better on CIELAB.
CIELAB ΔE*
The International Commission on Illumination
The International Commission on Illumination (usually abbreviated CIE for its French name Commission internationale de l'éclairage) is the international authority on light, illumination, colour, and colour spaces. It was established in 1913 a ...
(CIE) calls their distance metric (also inaccurately called , , or "Delta E") where delta
Delta commonly refers to:
* Delta (letter) (Δ or δ), the fourth letter of the Greek alphabet
* D (NATO phonetic alphabet: "Delta"), the fourth letter in the Latin alphabet
* River delta, at a river mouth
* Delta Air Lines, a major US carrier ...
is a Greek letter
The Greek alphabet has been used to write the Greek language since the late 9th or early 8th century BC. It was derived from the earlier Phoenician alphabet, and is the earliest known alphabetic script to systematically write vowels as wel ...
often used to denote difference, and E stands for ''Empfindung''; German for "sensation". Use of this term can be traced back to Hermann von Helmholtz
Hermann Ludwig Ferdinand von Helmholtz (; ; 31 August 1821 – 8 September 1894; "von" since 1883) was a German physicist and physician who made significant contributions in several scientific fields, particularly hydrodynamic stability. The ...
and Ewald Hering
Karl Ewald Konstantin Hering (5 August 1834 – 26 January 1918) was a German physiologist who did much research in color vision, binocular perception, eye movements, and hyperacuity. He proposed opponent color theory in 1892.
Born in Gersd ...
.
Perceptual non-uniformities in the underlying CIELAB
The CIELAB color space, also referred to as ''L*a*b*'', is a color space defined by the International Commission on Illumination (abbreviated CIE) in 1976. It expresses color as three values: ''L*'' for perceptual lightness and ''a*'' and ''b* ...
color space have led to the CIE refining their definition over the years, leading to the superior (as recommended by the CIE) 1994 and 2000 formulas. These non-uniformities are important because the human eye is more sensitive to certain colors than others. CIELAB metric is used to define color tolerance of CMYK solids. A good metric should take this into account in order for the notion of a " just noticeable difference" (JND) to have meaning. Otherwise, a certain may be insignificant between two colors in one part of the color space while being significant in some other part.
All formulae are originally designed to have the difference of 1.0 stand for a JND. This convention is generally followed by other perceptual distance functions such as the aforementioned .[ However, further experimentation may invalidate this design assumption, the revision of CIE76 JND to 2.3 being an example.][
]
CIE76
The CIE 1976 color difference formula is the first formula that related a measured color difference to a known set of CIELAB coordinates. This formula has been succeeded by the 1994 and 2000 formulas because the CIELAB space turned out to be not as perceptually uniform as intended, especially in the saturated regions. This means that this formula rates these colors too highly as opposed to other colors.
Given two colors in CIELAB color space
The CIELAB color space, also referred to as ''L*a*b*'', is a color space defined by the International Commission on Illumination (abbreviated CIE) in 1976. It expresses color as three values: ''L*'' for perceptual lightness and ''a*'' and '' ...
, and , the CIE76 color difference formula is defined as:
corresponds to a JND (just noticeable difference).
CMC l:c (1984)
In 1984, the Colour Measurement Committee of the Society of Dyers and Colourists
Logo
The Society of Dyers and Colourists (SDC) is an international professional society, with headquarters in Bradford, England, specializing in colour in all its manifestations, but particularly in relation to textiles. Founded in 1884, it was g ...
defined a difference measure based on the CIE L*C*h color model, an alternative representation of L*a*b* coordinates. Named after the developing committee, their metric is called CMC l:c. The quasimetric (i.e. it violates symmetry: parameter T is based on the hue of the reference alone) has two parameters: lightness (l) and chroma (c), allowing the users to weight the difference based on the ratio of l:c that is deemed appropriate for the application. Commonly used values are 2:1 for acceptability and 1:1 for the threshold of imperceptibility.
The distance of a color to a reference is:
CMC l:c is designed to be used with D65 and the CIE Supplementary Observer.
CIE94
The CIE 1976 color difference definition was extended to address perceptual non-uniformities, while retaining the CIELAB color space, by the introduction of application-specific parametric weighting factors ''kL'', ''kC'' and ''kH'', and functions ''SL'', ''SC'', and ''SH'' derived from an automotive paint test's tolerance data.
As with the CMC I:c, Δ''E'' (1994) is defined in the L*C*h* color space and likewise violates symmetry, therefore defining a quasimetric. Given a reference color and another color , the difference is
where
and where ''kC'' and ''kH'' are usually both set to unity, and the parametric weighting factors ''kL'', ''K''1 and ''K''2 depend on the application:
:
Geometrically, the quantity corresponds to the arithmetic mean of the chord lengths of the equal chroma circles of the two colors.
CIEDE2000
Since the 1994 definition did not adequately resolve the perceptual uniformity issue, the CIE refined their definition with the CIEDE2000 formula published in 2001, adding five corrections:
* A hue rotation term (RT), to deal with the problematic blue region (hue angles in the neighborhood of 275°):
* Compensation for neutral colors (the primed values in the L*C*h differences)
* Compensation for lightness (SL)
* Compensation for chroma (SC)
* Compensation for hue (SH)
The formulae below should use degrees rather than radians; the issue is significant for ''RT''.
The parametric weighting factors ''kL'', ''kC'', and ''kH'' are usually set to unity.
The inverse tangent (tan−1) can be computed using a common library routine atan2(b, )
which usually has a range from −π to π radians; color specifications are given in 0 to 360 degrees, so some adjustment is needed. The inverse tangent is indeterminate if both ' and ''b'' are zero (which also means that the corresponding ' is zero); in that case, set the hue angle to zero. See .
The example above expects the parameter order of atan2 to be atan2(y, x)
.
When either '1 or '2 is zero, then Δ is irrelevant and may be set to zero. See .
When either '1 or '2 is zero, then is '1+'2 (no divide by 2; essentially, if one angle is indeterminate, then use the other angle as the average; relies on indeterminate angle being set to zero). See stating most implementations on the Internet at the time had "an error in the computation of average hue".