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

facelessuser has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-color-4] Gamut Mapping Algorithm and Color Banding ==
I'll preface this by saying I'm not entirely sure what the top priority is in the gamut mapping, so maybe this amount of banding is perfectly acceptable.

So the gamut mapping algorithm, I assume, is balancing the best possible match with speed, so there will be a bit of a trade-off, and in some cases may be some concessions.

The current algorithm seems to want to minimize calling the distancing algorithm as much as possible, which makes sense as that will provide the greatest speed. So, the algorithm breaks the binary search loop as soon as the chroma reduction yields a color outside the gamut but within the JND range from the clipped form of the chroma reduced color. The color can fall anywhere within this window and it will kick out. In a gradient with other colors that should be fairly close, banding can occur.

I've implemented the CSS color gamut mapping algorithm as outlined in the spec, but I've also implemented a variant that tries to keep the color on the high end of the JND to prevent reducing the chroma more than necessary. When doing this, the results provide smoother transitions. The variant only performs the distancing on iterations where the color is out of gamut and kicks out as soon as it is close-ish to the upper end of the JND from its clipped counterpart. Obviously, there is a tradeoff in speed, but not as bad as performing the distancing on every iteration.

I'll admit, the banding can be kind of subtle, and sometimes a little less so, and again, I'm not sure if this is an acceptable amount or not, figured it would be worth bringing it up as I imagine a system doing lots of gamut mapping could produce some banding, but speed is also a concern.

<img width="671" alt="Screen Shot 2022-03-11 at 6 41 07 PM" src="https://user-images.githubusercontent.com/1055125/157999433-974e6df3-9798-4b3b-93a0-1ac0d22b2bae.png">



Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/7135 using your GitHub account


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

Received on Saturday, 12 March 2022 02:47:19 UTC