facelessuser / coloraide

A library to aid in using colors
https://facelessuser.github.io/coloraide
MIT License
200 stars 12 forks source link

Inconsistent use of white points #33

Closed facelessuser closed 3 years ago

facelessuser commented 3 years ago

One of my biggest concerns with using CIELAB and CIELCH was how inconsistent the chroma calculation was. It would swing quite large, and something always felt off. It bothered me greatly.

Recently I dug into it and found the reason for the large swing in chroma and why it was even closer to zero was due to the fact that white point usage was consistent. As CIELAB was in D50 and sRGB was in D65, there was a conversion to XYZ and then chromatic adaption. It was in this area that CIELAB was thrown greatly off course.

We can see the heights to which chroma could reach when evaluating sRGB achromatic colors:

srgb: maximum chroma: 0.014636
srgb: maximum a: 0.003817
srgb: maximum b: 0.014130

But after re-evaluating all the matrices with the same chromatic adaption white point, we can see a vast improvement.

srgb: maximum chroma: 0.000012
srgb: maximum a: 0.000011
srgb: maximum b: 0.000005

I want to code up an experimental branch that adjusts all the matrices. I am interested to see if color.js (and the CSS spec) fix the XYZ matrices or they adjust the chromatic adaption matrices.

NOTE: I could not exactly figure out how color.js calculated their ProPhoto matrices. I was really, really close, but not spot-on. I'm not sure if their primaries were different or their white point was different from mine. But if all the matrices get updated, it won't matter as we would then match them.

Ref https://github.com/LeaVerou/color.js/issues/87

facelessuser commented 3 years ago

I did figure out ProPhoto primaries and white points. They kept the white point to 4 significant digits like D65, and capped the primaries to that as well. So I will match my primaries with the consistent white points.