Function deltaE2000
Measures the CIEDE2000 colour difference between two CIELAB D50 values.
CIEDE2000 is a named CIELAB-based metric with lightness, chroma, hue, and chroma-hue interaction corrections. The calculation is deterministic and allocation-free. It does not choose thresholds or decide whether a difference is perceptually significant.
Parameters
| Name | Description |
|---|---|
| lhs | First CIELAB D50 value. |
| rhs | Second CIELAB D50 value. |
Returns
The CIEDE2000 colour difference. NaN input propagates as NaN. An infinite component difference produces positive infinity.
Standards
ISO/CIE 11664-6:2014, based on CIE Technical Report 142-2001.
Example
const lhs = CieLabD50d(50, 2.6772, -79.7751);
const rhs = CieLabD50d(50, 0, -82.7485);
const value = lhs .deltaE2000(rhs);
// The DMD 2.111/LDC 1.41 libm path produces a known incorrect runtime
// Delta-E-2000 value in this trigonometric reference vector. Keep the
// executable check on the qualified frontend generation only; the old
// toolchains remain diagnostic until their libm behavior is replaced or
// independently qualified.
static if (__VERSION__ >= 2120)
assert(value > 2.0424 && value < 2.0426);
Example
enum lhs = CieLabD50d(50, 2.6772, -79.7751);
enum rhs = CieLabD50d(50, 0, -82.7485);
enum value = lhs .deltaE2000(rhs);
// DMD 2.111 CTFE evaluates the trigonometric branch inaccurately here;
// retain the runtime reference check for that compiler and keep the
// compile-time numerical gate on toolchains with the corrected CTFE.
static if (__VERSION__ >= 2120)
static assert(value > 2.0424 && value < 2.0426);
Example
const zero = CieLabD50d(50, 0, 0);
assert(zero .deltaE2000(zero) == 0);
assert(zero .deltaE76(zero) == 0);
Example
const lhs = CieLabD50d(50, 0, 0);
const rhs = CieLabD50d(50, 1e-12, 0);
assert(lhs .deltaE2000(rhs) >= 0);
assert(lhs .deltaE2000(rhs) == rhs .deltaE2000(lhs));
Example
enum nanValue =
deltaE2000(
CieLabD50d(double .nan, 0, 0),
CieLabD50d(50, 0, 0)
);
enum infinityValue =
deltaE2000(
CieLabD50d(double .infinity, 0, 0),
CieLabD50d(50, 0, 0)
);
static assert(nanValue != nanValue);
static assert(infinityValue == double .infinity);