Skip to content

Feature - Replace LCH-weighted color matching with weighted Cartesian OKLab distance #28

@claudobahn

Description

@claudobahn

The current color matching uses a polar LCH decomposition with weights WL=0.5, WC=3.0, WH=6.0. Near-achromatic palette colors (black, white) have near-zero chroma, which collapses the hue difference term ΔH² to zero regardless of the pixel's hue. This makes black a universal attractor for saturated colors — vivid purple maps to black (dist=0.38) instead of blue (dist=1.28) because the hue penalty vanishes.

Additionally, the low lightness weight (WL=0.5) deprioritises structural detail, which human vision relies on for spatial recognition.

Change: Replace the LCH distance with weighted Euclidean distance in Cartesian OKLab:

dist = (1.0·ΔL)² + (1.5·Δa)² + (1.5·Δb)²

The Cartesian formulation has no achromatic singularity — the distance from a saturated color to black is naturally large because Δa² and Δb² remain intact rather than being subtracted out by −ΔC². The modest Wab=1.5 boost ensures e-paper color inks are still utilised without washing out neutrals.

Validation: Optimal Wab=1.5 determined by downsampled ΔE sweep (4×4 block averaging in OKLab) across 8 test images. No regressions on natural photos; measurable improvement on saturated out-of-gamut subjects.

Implementation:
claudobahn@014a00f

Before/After:

Image Image Image Image Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions