- From: Isaac Muse via GitHub <sysbot+gh@w3.org>
- Date: Wed, 18 Oct 2023 13:27:46 +0000
- To: public-css-archive@w3.org
Keep in mind that gamut mapping is an approximation of an out-of-gamut color within the chosen gamut. It is dependent on a couple of things. How well does the chosen gamut mapping color space preserve hues as chroma increases/decreases? How do the colors from your chosen gamut translate to the gamut mapping color space? When clipping `color(display-p3 1 0 0)`, we get `red`. It seems intuitive because the display P3 color is just a more intense red, so when we get red back, it seems reasonable. But when we convert to OkLCh, we can see that we will get a slightly different hue when we convert `color(display-p3 1 0 0)` and `red`. ```py >>> Color('display-p3', [1, 0, 0]).convert('oklch') color(--oklch 0.64857 0.29949 28.958 / 1) >>> Color('srgb', [1, 0, 0]).convert('oklch') color(--oklch 0.62796 0.25768 29.234 / 1) ``` So, we can see already that we most likely won't get a perfect sRGB `red` just by decreasing chroma. It is certainly possible if you use a different LCh-like color space that the degree of difference and how they render could be different. When just reducing chroma, we can sometimes reduce chroma too much (as explained [here](https://drafts.csswg.org/css-color-4/#GM-excessive-reduction) in the CSS spec). This is often just due to the geometry of the gamut mapping color space slice at that hue. To avoid reducing chroma too much, local clipping is used to employ a minimum ∆E (MINDE) allowing us to compare each chroma reduction to a clipped version of that chroma-reduced color, and if we are "close enough", we can just take that clipped version of the color and avoid reducing the chroma further. When this happens, we may introduce a slight hue and/or lightness shift, but depending on how good that JND value is, the difference in the clipped and non-clipped color shouldn't really be that noticeable to the human eye. So if you reduce the JND to a super small value, its significance becomes negligible and you will get much closer at times to the true chroma limit, but then you are removing the entire reason for employing MINDE, so it will, at times, reduce the chroma too much. Based on my observations (using a digital color meter on macOS to compare the sRGB colors), the results in your image seem to match mine. So it would _appear_ that our interpretation of the spec yields the same results. So as far as the spec is concerned, the `0.02` results would be the correct ones, based on the logic explained above. <img width="1331" alt="Screenshot 2023-10-18 at 7 10 04 AM" src="https://github.com/w3c/csswg-drafts/assets/1055125/3ea50bf9-432d-46a0-9fdb-ec34d345b7ba"> The reality of "What is the most correct gamut mapping?" is subjective to your requirements. CSS seems to have chosen to try to preserve hue and lightness (as much as possible) while trying to avoid excessive chroma reduction. -- GitHub Notification of comment by facelessuser Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/9489#issuecomment-1768461578 using your GitHub account -- Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Wednesday, 18 October 2023 13:27:48 UTC