diff --git a/docs/api.md b/docs/api.md
index 2b1a62cc..20dd4b7a 100644
--- a/docs/api.md
+++ b/docs/api.md
@@ -673,14 +673,20 @@ Computes the [CIE94][cie94] ΔE\*94 color difference between the colo
Computes the [CIEDE2000][ciede2000] ΔE\*00 color difference between the colors _a_ and _b_ as implemented by [G. Sharma](http://www2.ece.rochester.edu/~gsharma/ciede2000/).
-Returns a [CIEDE2000](https://en.wikipedia.org/wiki/Color_difference#CIEDE2000) Delta E\* function.
-
# culori.**differenceCmc**() · [Source](https://github.com/evercoder/culori/blob/master/src/difference.js)
Computes the [CMC l:c (1984)][cmc] ΔE\*CMC color difference between the colors _a_ and _b_.
ΔE\*CMC is not considered a metric since it's not symmetrical, that is the distance from _a_ to _b_ is not always equal to the distance from _b_ to _a_. Therefore it cannot be reliably used with [`culori.nearest()`](#nearest).
+# culori.**differenceHyab**() · [Source](https://github.com/evercoder/culori/blob/master/src/difference.js)
+
+Computes the HyAB color difference between the colors _a_ and _b_, as proposed in:
+
+> Abasi S, Amani Tehran M, Fairchild MD. _Distance metrics for very large color differences._ Color Res Appl. 2019; 1–16. https://doi.org/10.1002/col.22451 ([PDF](http://markfairchild.org/PDFs/PAP40.pdf))
+
+The HyAB formula combines the Euclidean and [city block](https://en.wikipedia.org/wiki/Taxicab_geometry) distance and has been experimentally shown to work better for large color differences than CIEDE2000, while still holding up well for smaller color differences, making it a _"good candidate formula for image processing and computer vision applications"_.
+
### Other difference formulas
# culori.**differenceDin99o**() · [Source](https://github.com/evercoder/culori/blob/master/src/difference.js)
diff --git a/src/difference.js b/src/difference.js
index 02509fc6..43051a77 100644
--- a/src/difference.js
+++ b/src/difference.js
@@ -253,6 +253,31 @@ const differenceCmc = (l = 1, c = 1) => {
};
};
+/*
+
+ HyAB color difference formula, introduced in:
+
+ Abasi S, Amani Tehran M, Fairchild MD.
+ "Distance metrics for very large color differences."
+ Color Res Appl. 2019; 1–16.
+ https://doi.org/10.1002/col.22451
+
+ PDF available at:
+
+ http://markfairchild.org/PDFs/PAP40.pdf
+ */
+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);
+ };
+};
+
const differenceDin99o = () => differenceEuclidean('dlab');
/*
@@ -278,6 +303,7 @@ export {
differenceCie94,
differenceCiede2000,
differenceCmc,
+ differenceHyab,
differenceDin99o,
differenceKotsarenkoRamos
};
diff --git a/src/index.js b/src/index.js
index 229f221b..26833850 100644
--- a/src/index.js
+++ b/src/index.js
@@ -163,6 +163,7 @@ export {
differenceCie94,
differenceCiede2000,
differenceCmc,
+ differenceHyab,
differenceDin99o,
differenceKotsarenkoRamos,
differenceHueSaturation,
diff --git a/test/difference.test.js b/test/difference.test.js
index 79c9254a..ad103bd5 100644
--- a/test/difference.test.js
+++ b/test/difference.test.js
@@ -5,6 +5,7 @@ import {
differenceCie94,
differenceCiede2000,
differenceCmc,
+ differenceHyab,
differenceKotsarenkoRamos,
rgb,
lab65,
@@ -181,3 +182,8 @@ tape('difference in LCh space', t => {
t.equal(differenceEuclidean('lch')('red', 'green'), 130.3764124621912);
t.end();
});
+
+tape('differenceHyab', t => {
+ t.equal(differenceHyab()('red', 'green'), 139.93576718451553);
+ t.end();
+});