1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//! HyAB and Kotsarenko-Ramos color differences.
//!
//! Both factories live here because they are short formulae that don't
//! warrant their own modules.
//!
//! Ports culori 4.0.2's `differenceHyab` from `difference.js`:
//!
//! ```js
//! const differenceHyab = () => {
//! let lab = converter('lab65');
//! return (std, smp) => {
//! let LabStd = lab(std);
//! let LabSmp = lab(smp);
//! let dL = LabStd.l - LabSmp.l;
//! let dA = LabStd.a - LabSmp.a;
//! let dB = LabStd.b - LabSmp.b;
//! return Math.abs(dL) + Math.sqrt(dA * dA + dB * dB);
//! };
//! };
//! ```
//!
//! Source: Abasi, Amani Tehran, Fairchild (2019), "Distance metrics for
//! very large color differences."
use cratedifference_euclidean_with;
use crateextract;
use crateColor;
/// HyAB color difference: `|ΔL| + √(Δa² + Δb²)` evaluated in `lab65`.
///
/// Designed by Abasi et al. (2019) for large color differences where
/// Euclidean distance in CIELab over-emphasizes lightness changes. Both
/// inputs are converted to D65 Lab before the formula is applied.
/// Kotsarenko-Ramos color difference, defined over Y'IQ.
///
/// Mirrors culori's `differenceKotsarenkoRamos`, which is a thin wrapper
/// around `differenceEuclidean('yiq', [0.5053, 0.299, 0.1957])`.
///
/// Source: Kotsarenko & Ramos (2010), "Measuring perceived color
/// difference using YIQ NTSC transmission color space in mobile
/// applications," Programación Matemática y Software.