# 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:

Metric | Summary |
---|---|

`DE_2000` | The color difference using the recommended CIE Delta E 2000 equation. |

`DE_94` | The color difference using the recommended CIE Delta E 94 equation. |

`DE_JPC79` | McDonald's "JP Coates Thread Company" color difference formula. |

`DE_CMC` | The color difference using the CMC l:c equation. |

`DE_BFD` | The color difference using the BFD equation. |

`DE_AB` | The original ΔE*, Euclidean color difference equation in the `Lab` colorspace. |

`DE_DIN99` | The Euclidean color difference equation applied in the `DIN99` colorspace. |

`DE_DIN99d` | The Euclidean color difference equation applied in the `DIN99d` colorspace. |

`DE_DIN99o` | The 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:

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.colordiff`

— Function`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.

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.

`Colors.DE_2000`

— Method`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`

.

`Colors.DE_94`

— Method`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 Arts | Textiles | |
---|---|---|

`kl` | `1` | `2` |

`k1` | `0.045` | `0.048` |

`k2` | `0.015` | `0.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`

.

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.

`Colors.DE_JPC79`

— Method`DE_JPC79()`

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

`Colors.DE_CMC`

— Method`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`

.

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.

`Colors.DE_BFD`

— Method`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`

).

`Colors.DE_AB`

— Method`DE_AB()`

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

(CIELAB) colorspace.

`Colors.DE_DIN99`

— Method`DE_DIN99()`

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

colorspace.

`Colors.DE_DIN99d`

— Method`DE_DIN99d()`

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

colorspace.

`Colors.DE_DIN99o`

— Method`DE_DIN99o()`

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

colorspace.