Re: [csswg-drafts] [css-color-4] CSS gamut mapping algorithm clarifications (#7653)

> > Second question: Should we reconsider the trade-off of the "push chrome back out" step?
> 
> Looking at the provided demo page, it seems the algorithm implemented is a binary search in Oklch, although expressed as Oklab (instead of looking for Chroma, you're looking for an _alpha_ coefficient for the `a` and `b` components)

Yes, this is just to avoid switching between polar and rectangular coordinates.

> with improvements brought over from the _analytical solution_ paragraph ("push chroma back out"), which sounds like combining the two alternative techniques?

This paragraph complicates things a lot.

> For the analytical implementation, having found the exact intersection, project outwards (towards higher chroma) along the line of constant lightness until the deltaEOK between the projected point and a clipped version of that point exceeds one JND. Then returned the clipped version of the color as the mapped result.

The text in the "Excessive Chroma Reduction" and "Chroma Reduction with Local Clipping" sections gives a motivation for this, but I would like to see concrete examples of the form "gamut map color X to gamut G with and without this step and see the difference".

Separately, the term "analytical" should generally be avoided. It generally refers to closed-form solutions (as opposed to iterative solutions), which are very rarely desirable. The Newton-based solution I mentioned is not analytic -- it's in the same class of iterative solutions as binary search. Both solutions will converge to the exact solution (up to floating point precision), the only difference is the number of steps that are needed.

The idea of adding an extra step to solutions that arrive at the exact solution too quickly seems inappropriate.

I would like to write up the code that is also capable of finding the point on the surface of the gamut that is closest to the input point in a weighted L2 sense. So, if the input point is `(L,a,b)`, find the point `(L*,a*,b*)` that is within the gamut (or on its boundary) such that we minimize their distance `(L-L*)^2+(a-a*)^2+(b-b*)^2`.

Again, various text gives motivation for the "only change chroma" scheme, but I would want to see concrete examples where it demonstrates superiority. In the example cases that I've tried (e.g, "red-redder" from [here](https://github.com/w3c/csswg-drafts/issues/7610#issuecomment-1226026465)), I am not convinced that the result is desirable.


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


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

Received on Wednesday, 29 March 2023 13:02:47 UTC