zschuessler / DeltaE

CIE color difference formulas in JavaScript
http://zschuessler.github.io/DeltaE
The Unlicense
257 stars 25 forks source link

Calculation wrong #4

Closed ddsol closed 7 years ago

ddsol commented 7 years ago

This Delta E calculation is wrong. For some insight I suggest reading this paper.

Details:

de({l: 60, a: -79.86355100472929, b: 60.18150231520482}, {l: 60, a: 79.86355100472929, b: -60.181502315204824}) = 59.58968443596155;

de({l: 60, a: -79.86355100472929, b: 60.18150231520482}, {l: 60, a: 79.863656041144, b: -60.18136292692152}) = 102.06502930178404;

How can that be right when the difference in the second color is extremely small (and no difference in the first color) but the resulting Delta E is radically different?

zschuessler commented 7 years ago

I've verified the calculation is correct here: http://colormine.org/delta-e-calculator/cie2000

I read the linked resource when creating this library. Does something specific exist in the paper which refutes the accuracy of the implementation?

(By the way, de00 gives inaccurate results when there is a hue shift of 180/360 degrees. this is mentioned in the paper)

zschuessler commented 7 years ago

I just noticed in your original message you said the difference in color is extremely small. Are you using the CIELAB color space? The colors are drastically different. Bright green vs bright pink.

You can also tell the colors are polar opposites in hue because the colors are inverted in A/B values.

ddsol commented 7 years ago

Well, I fed all the test data in that paper through this function and it looks like the results are the same. The difference in the second color is extremely small in both cases. But it is a flip at the 180° mark.

Also, the paper only tests colors with a very small color difference (R<2.5) so the discontinuity is small there. But as you can see above, the discontinuity is huge.

That said, DeltaE is apparently just really bad at diffing colors where dE>5 or so. So, if (dE00(a,b)>5) return NaN; 😄.

From the paper:

Though the CIEDE2000 color-difference equations are only applicable for small color differences, it is preferable that data for testing software implementations should include at least a few large color differences

zschuessler commented 7 years ago

Momma always said nothing was perfect :wink:

Reviewing this, it would be cool if discontinuity was calculated. Too specific of a use case and time consuming for it to be a good addition I think.

Cheers!