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

> 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. 

That was more of a consideration when we were working in CIE LCH and using ΔE2000. Less so with the simple ΔEOK formula.

While it is an intent to make the computation  performant enough to be implementable, I wouldn't say speed was the primary criterion (else we would just use per-component clip which is super fast). The primary motivator was perceptual hue preservation with minimal chroma reduction.

> 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. 

That doesn't affect the speed that much, and is not done for speed. It is done to avoid excessive chroma reduction with slightly-concave upper gamut boundaries, which was a severe problem.

> 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.

That sounds very interesting and is entirely consistent with the aims of the CSS gamut mapping algorithm.

Could you take a shot at expressing it in terms of a modified [pseudocode from the spec](https://drafts.csswg.org/css-color-4/#binsearch)?

-- 
GitHub Notification of comment by svgeesus
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/7135#issuecomment-1065969260 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 21:41:26 UTC