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

The basic idea with my implementation is:

- if the out of gamut color is out of gamut, but under the JND when you start, to just clip it and return it
- if it is beyond the JND, reduce chroma just until it is in the high end of the JND.

It's honestly similar to Color.js's approach but cuts the ∆E calls by probably half.

With the way the current CSS algorithm works, you can end up reducing one color to the low end of the JND  and an adjacent color on the high end of the JND. If this happens, you have something like 2 * JND difference between them, plus any natural color difference between the two colors. That creates the banding.

Also, keeping the JND on the high end lets you catch any weird geometric quirks of a color space. When gamut mapping with Lch instead of Oklch, there was a problem with Display P3 yellow being reduced too aggressively, and this was just because of the weird shape of the LCH slice. Reducing chroma on the high end helps it catch the peak. This is obviously less of a problem when using Oklch, but Oklch seems to have other issues in the green-ish blue region.

Below, you can see how the gamut mapping line would have missed the peak had it not been reduced to the high end of the JND.

![gamut-lch-chroma-yellow](https://user-images.githubusercontent.com/1055125/160476998-f2e96bf5-7357-4c7b-9948-09ad3ad9f321.png)




-- 
GitHub Notification of comment by facelessuser
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/7135#issuecomment-1081083146 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 20:02:58 UTC