Re: [csswg-drafts] [css-color-4] Gamut Mapping Algorithm and Color Banding (#7135)

I've also recently implemented the css-color-4 gamut mapping algorithm along with a few other related ideas and published [a demo](https://danburzo.ro/demos/color/gamut-mapping.html). Barring any implementation mistakes, I can confirm the issues with banding and discontinuities (#7071) with the algorithm described in the spec. I'm plotting hue slices of the various uniform color spaces (CIELCH, OKLCH, etc). I imagine authors will use `lch()` and `oklch()` across the entire range of expected coordinates, so we want these plots look uniform and contain intuitive values at the extremes. To highlight [a recent interaction](https://twitter.com/vasilis/status/1507703499647299587), users may expect vivid `lch()` blacks such as `lch(0% 95 328)` to still be black, and presumably vivid whites to be white. 

With the current algorithm, I believe the JND would have to be lowered out of existence: when the JND becomes small enough to eliminate banding, it's virtually indistinguishable from simple chroma reduction.

Here are some of the related ideas I've tried (just to get them out of the way):

* `fuzzy` definition of in-gamut at each step of the binary search (either the candidate color is in gamut, or its clipped version is under JND distance) — this could work with a minuscule & arbitrarily-established JND.
* `reduce-cl` tries to reduce lightness along with chroma — converging to any naive choice of destination point looks quite bad, so the line needs to be at least hue-dependent ([like Björn Ottosson explored](https://bottosson.github.io/posts/gamutclipping/))

I will try to implement @facelessuser's proposed algorithm & plot some results. 

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


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

Received on Monday, 28 March 2022 18:14:54 UTC