Re: [csswg-drafts] [css-color] Add OKLab, OKLCH (#6642)

I've mentioned this elsewhere, but maybe it will spark a conversation here.

My one issue is that the provided XYZ matrix assumes an XYZ -> Linear sRGB transfer matrix that doesn't align with what is actually suggested for sRGB in the CSS spec. Since the Oklab matrix is essentially a transform of, XYZ D65 -> Linear sRGB -> LMS, this does introduce some noise only because it is assuming a different XYZ -> Linear sRGB matrix than what is specified in the CSS spec.

If converting from XYZ  using the matrix specified in https://bottosson.github.io/posts/oklab/#converting-from-xyz-to-oklab and comparing that to using the CSS XYZ -> Linear sRGB conversion and then using the Linear sRGB to Oklab transform as specified here: https://bottosson.github.io/posts/oklab/#converting-from-linear-srgb-to-oklab, you will get different results.

In short, using the XYZ matrix as specified by the Oklab article assumes the white point that he used, but CSS uses a different white point, so this introduces noise. If the conversion was done from Linear sRGB, this noise is reduced.

Or you can just calculate the XYZ matrix using your own XYZ -> sRGB Linear matrix.

Assuming the XYZ -> Linear sRGB transfer that is specified in the CSS docs:

```
        [
  [  3.2409699419045226,  -1.537383177570094,   -0.4986107602930034  ],
  [ -0.9692436362808796,   1.8759675015077202,   0.04155505740717559 ],
  [  0.05563007969699366, -0.20397695888897652,  1.0569715142428786  ]
 ]
```

The Oklab matrices below would be as follows which would reduce the noise.

```
===== XYZ D65 Linear -> lms =====
[[ 0.8190224432164319    0.3619062562801221   -0.12887378261216414 ]
 [ 0.0329836671980271    0.9292868468965546    0.03614466816999844 ]
 [ 0.048177199566046255  0.26423952494422764   0.6335478258136937  ]]
===== lms -> XYZ D65 =====
[[ 1.2268798733741557  -0.5578149965554813   0.28139105017721583]
 [-0.04057576262431372  1.1122868293970594  -0.07171106666151701]
 [-0.07637294974672142 -0.4214933239627914   1.5869240244272418 ]]
```

-- 
GitHub Notification of comment by facelessuser
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/6642#issuecomment-943521484 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Thursday, 14 October 2021 16:29:29 UTC