Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #127. Replaces the perceptual color difference metric at the heart of pixelmatch — YIQ Euclidean distance (Kotsarenko & Ramos 2010) — with the vastly better HyAB distance in the OKLab color space (with toe-corrected lightness) (Ottosson 2020; Abasi et al. 2019).
The threshold semantics are preserved: distances are scaled so that
1.0is the black↔white difference, and the defaultthreshold: 0.1is unchanged.Why
|ΔL| + √(Δa² + Δb²)) is a city-block/Euclidean hybrid shown to track human judgment of large color differences better than pure Euclidean metrics — and large differences are exactly what a diff threshold operates on.Behavioral changes
0.1boundary, their median distance under the new metric is ~0.12 — i.e. the same threshold value is on average ~20% more sensitive than before. Sensitivity is now nearly uniform across the lightness range (band medians 0.118–0.124), which the old metric never achieved.Performance
The new metric is more math per pixel (sRGB linearization, LMS transform, cube roots), offset by various performance optimizations:
Math.cbrtis a slow library call);Net result on the benchmark: comparable to the old YIQ implementation despite the heavier color model.