Color Differences

The colordiff function gives an approximate value for the difference between two colors.

julia> colordiff(colorant"red", colorant"darkred")
23.754143f0

julia> colordiff(colorant"red", colorant"blue")
52.881363f0

julia> colordiff(HSV(0, 0.75, 0.5), HSL(0, 0.75, 0.5))
19.48590873778533
    colordiff(a::Color, b::Color; metric=DE_2000())

Evaluate the CIEDE2000 color difference formula by default. This gives an approximate measure of the perceptual difference between two colors to a typical viewer. A larger number is returned for increasingly distinguishable colors.

Options for metric are as follows:

MetricSummary
DE_2000The color difference using the recommended CIE Delta E 2000 equation.
DE_94The color difference using the recommended CIE Delta E 94 equation.
DE_JPC79McDonald's "JP Coates Thread Company" color difference formula.
DE_CMCThe color difference using the CMC l:c equation.
DE_BFDThe color difference using the BFD equation.
DE_ABThe original ΔE*, Euclidean color difference equation in the Lab colorspace.
DE_DIN99The Euclidean color difference equation applied in the DIN99 colorspace.
DE_DIN99dThe Euclidean color difference equation applied in the DIN99d colorspace.
DE_DIN99oThe Euclidean color difference equation applied in the DIN99o colorspace.

The following charts show the differences between the three colors for each metric with the default parameters:

66.2 33.8 76.8 DE_2000 52.4 38.2 68.2 DE_94 62.1 37.9 99.8 DE_JPC79 47.9 52.6 68.9 DE_CMC 85.8 49.9 102 DE_BFD 106 77.6 125 DE_AB 49.7 28.9 52.3 DE_DIN99 61.9 45.3 71.4 DE_DIN99d 64.6 45.2 74.2 DE_DIN99o

The difference in the size of circles in the charts above represents the difference in the scale. The radii of the circles are all 20 in their scale units, so larger circles mean that the metric returns smaller values. Therefore, we should not compare the color differences between different metrics.

Colors.colordiffFunction
colordiff(a, b; metric=DE_2000())

Compute an approximate measure of the perceptual difference between colors a and b. Optionally, a metric may be supplied, chosen among DE_2000 (the default), DE_94, DE_JPC79, DE_CMC, DE_BFD, DE_AB, DE_DIN99, DE_DIN99d and DE_DIN99o.

The return value is a non-negative number in a type depending on the colors and metric.

Note

The supported metrics measure the difference within Lab or its variant colorspaces. When the input colors are not in the colorspace internally used by the metric, the colors (e.g. in RGB) are converted with the default whitepoint CIE D65 (Colors.WP_D65). If you want to use another whitepoint, convert the colors into the colorspace used by metric (e.g. Lab for DE_2000) in advance.

source
Colors.DE_2000Method
DE_2000(kl=1, kc=1, kh=1)

Construct a metric of the CIE Delta E 2000 recommendation, with weighting parameters kl, kc and kh as provided for in the recommendation. When not provided, these parameters default to 1.

source
Colors.DE_94Method
DE_94(kl=1, kc=1, kh=1, k1=0.045, k2=0.015)

Construct a metric of CIE Delta E 94 recommendation (1994), with weighting parameters kl, kc, kh, k1, and k2 as provided for in the recommendation. The kl, k1, and k2 depend on the application:

Graphic ArtsTextiles
kl12
k10.0450.048
k20.0150.014

and the default values are for graphic arts. The kc and kh default to 1.

The DE_94 is more perceptually uniform than the DE_AB, but has some non-uniformities resolved by the DE_2000.

Note

The DE_94 is a quasimetric, i.e. violates symmetry. Therefore, colordiff(a, b, metric=DE_94()) may not equal to colordiff(b, a, metric=DE_94()). The first argument of colordiff is taken as the reference (standard) color.

source
Colors.DE_JPC79Method
DE_JPC79()

Construct a metric using McDonald's "JP Coates Thread Company" color difference formula.

source
Colors.DE_CMCMethod
DE_CMC(kl=1, kc=1)

Construct a metric using the CMC equation (CMC l:c), with weighting parameters kl and kc. When not provided, these parameters default to 1.

Note

The DE_CMC is a quasimetric, i.e. violates symmetry. Therefore, colordiff(a, b, metric=DE_CMC()) may not equal to colordiff(b, a, metric=DE_CMC()). The first argument of colordiff is taken as the reference (standard) color.

source
Colors.DE_BFDMethod
DE_BFD([wp,] kl=1, kc=1)

Construct a metric using the BFD equation, with weighting parameters kl and kc. Additionally, a whitepoint wp can be specified, because the BFD equation must convert between XYZ and Lab during the computation. When not provided, kl and kc default to 1, and wp defaults to CIE D65 (Colors.WP_D65).

source
Colors.DE_ABMethod
DE_AB()

Construct a metric of the original CIE Delta E equation (ΔE*ab), or Euclidean color difference equation in the Lab (CIELAB) colorspace.

source
Colors.DE_DIN99Method
DE_DIN99()

Construct a metric using Euclidean color difference equation applied in the DIN99 colorspace.

source
Colors.DE_DIN99dMethod
DE_DIN99d()

Construct a metric using Euclidean color difference equation applied in the DIN99d colorspace.

source
Colors.DE_DIN99oMethod
DE_DIN99o()

Construct a metric using Euclidean color difference equation applied in the DIN99o colorspace.

source