Saturon LogoSaturon

saturon/deltaE

Compute perceptual color differences using CIE76, CIE94, CIEDE2000, and OKLab algorithms.

The saturon/deltaE subpath provides standalone functions for calculating the perceptual distance (Delta E / ΔE\Delta E) between two colors. Higher values indicate greater visual dissimilarity, where a value around 1.0 roughly corresponds to a Just Noticeable Difference (JND) for human vision under reference viewing conditions.

Functions

deltaEOK()

Calculates color difference in the OKLab color space (Euclidean distance scaled by 100). Fast and highly reliable for general-purpose perceptual differences and modern displays.

import { deltaEOK } from "saturon/deltaE";

const diff = deltaEOK(color1, color2);

deltaE76()

Calculates perceptual distance using the classic CIE76 formula (ΔE76\Delta E_{76}), computed as simple Euclidean distance in the CIE L∗a∗b∗L^*a^*b^* color space.

import { deltaE76 } from "saturon/deltaE";

const diff = deltaE76(color1, color2);

deltaE94()

Calculates color difference using the CIE94 standard (ΔE94\Delta E_{94}), incorporating weighting factors for lightness (kLk_L), chroma (kCk_C), and hue (kHk_H) in CIE L∗a∗b∗L^*a^*b^* space.

import { deltaE94 } from "saturon/deltaE";

const diff = deltaE94(color1, color2);

deltaE2000()

Calculates perceptual distance using the industry-standard CIEDE2000 algorithm (ΔE00\Delta E_{00}). It accounts for non-uniformities in CIE L∗a∗b∗L^*a^*b^* space, neutral color corrections, and rotation terms in the blue region.

import { deltaE2000 } from "saturon/deltaE";

const diff = deltaE2000(color1, color2);

Common Signature

All Delta E functions share the exact same parameter signature:

function deltaE(color1: ColorData, color2: ColorData): number;

Parameters

ParameterTypeDescription
color1ColorDataThe baseline color object ({ model, coords }).
color2ColorDataThe target color object ({ model, coords }).

Returns

A non-negative number representing the perceptual distance scalar (ΔE\Delta E) between color1 and color2.


Behavior

  1. Both input colors are automatically converted to the required color model for calculation ("oklab" for deltaEOK, "lab" for deltaE76, deltaE94, and deltaE2000).
  2. Coordinates are extracted using toArray() with unclipped bounds (fit: "none") to maintain numerical precision.
  3. Perceptual Metrics:
  • deltaEOK: Computes Euclidean distance ΔL2+Δa2+Δb2×100\sqrt{\Delta L^2 + \Delta a^2 + \Delta b^2} \times 100 in OKLab space.
  • deltaE76: Computes Euclidean distance ΔL2+Δa2+Δb2\sqrt{\Delta L^2 + \Delta a^2 + \Delta b^2} in CIE L∗a∗b∗L^*a^*b^* space.
  • deltaE94: Evaluates lightness (ΔL\Delta L), chroma (ΔC\Delta C), and hue (ΔH\Delta H) weighting functions (SL,SC,SHS_L, S_C, S_H).
  • deltaE2000: Applies non-linear transformed chroma (Cˉ′\bar{C}'), hue rotation factors (RTR_T), and lightness/chroma/hue weighting scales.

Usage Example

import { deltaEOK, deltaE2000, deltaE76 } from "saturon/deltaE";

const colorA = { model: "rgb", coords: [255, 0, 0] };
const colorB = { model: "rgb", coords: [240, 20, 10] };

// OKLab perceptual distance
const distanceOK = deltaEOK(colorA, colorB);
console.log(distanceOK); // ~8.42

// Industry standard CIEDE2000
const distance2000 = deltaE2000(colorA, colorB);
console.log(distance2000); // ~4.12

// Classic CIE76
const distance76 = deltaE76(colorA, colorB);
console.log(distance76); // ~11.85

On this page