Re: [csswg-drafts] [css-color-4] Clamping of color values (#3845)

> reducing C in an out-of-gamut LCH color is not always amenable to the bisection method, due to the weird shape around yellows

Yes, when doing gamut mapping from display-p3 to sRGB (or rec2020 to display-p3) I also found problems due to gamut surface concavities around yellow (and cyan). The solution was, at each iteration of the bisection method, to calculate the deltaE between the current iteration and a channel-clamped copy of current iteration (which by definition will be in gamut). If the deltaE is less than some threshold (so the two values are not easily distinguishable), terminate bisection and return the clamped value.

This is better explained, and with diagrams, on the [color.js gamut mapping page](https://colorjs.io/docs/gamut-mapping.html). In that code, deltaE2000 is used with a threshold of 2. It made a huge difference and eliminated the spurious, ultra-low-Chroma results we were seeing with the more straightforward methods.

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


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

Received on Wednesday, 21 October 2020 17:39:32 UTC