question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

irregular sRGB gamut boundary in OKLCH

See original GitHub issue

When plotting L,C gamut slices I noticed an odd irregularity in the gamut boundary, in OK LCH. I didn’t see the same irregularity in CIE LCH. The code is

        let swatch = new Color("oklch", [lightness, chroma, hue]);
        let rgb = swatch.to("sRGB");
        // console.log({swatch, rgb});
        if (rgb.inGamut("srgb")) {
            fill = rgb.toString();  // .to("srgb");
        }

I suspect this is due to the inGamut() call, rather than being an irregularity in OKLab/ OK LCH itself.

image

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:12 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
facelessusercommented, Sep 7, 2022

Yeah, it seems confined to a very small hue range and a small band within that very small hue range, so probably maybe not a huge deal, but yeah, not ideal either though.

I’ve personally constrained my color library to use LCh by default (for now), only because its weaknesses are well known in relation to gamut mapping. OkLCh is kind of new in this area, and I don’t think it has been stressed enough to know where all its weaknesses are. I know I created another issue over at the CSSWG related to some unexpected behavior with OkLCh and gamut mapping: https://github.com/w3c/csswg-drafts/issues/7071. This also may not be a huge deal in most cases, but I did find it unexpected.

With that said, I think Oklab works pretty well for color interpolation at least 🙂.

0reactions
ardovcommented, Sep 7, 2022

Yep, it’s definitely not a big deal. I tried it with oklch(30.57% 0.22 264.09). The binary search chroma reduction algorithm jumps over #000296 and stops at #001788. So it reduces chroma to 0.18 instead of 0.21. The difference is so subtle I can hardly see it 😅

Read more comments on GitHub >

github_iconTop Results From Across the Web

Better than Lab? Gamut reduction CIE Lab & OKLab - W3C
Snap (clip) to closest gamut boundary if imperceptible. intersecting gamut boundary. Display P3 yellow to sRGB: Strict gamut intersection. Out of P3 gamut...
Read more >
[css-color-4] Gamut Mapping with Oklch - Odd Results #7071
The first set of examples is gamut mapping the interpolated colors into sRGB with Oklch chroma reduction. Notice how poor the results are ......
Read more >
Two new color spaces for color picking - Okhsv and Okhsl
The main drawback of using these models directly for color picking is that the sRGB gamut has a quite irregular shape in these...
Read more >
More experiments with sRGB gamut boundary in L*a*b* space
I'm still playing around with RGB gamut calculations in $ L^* a^* b^* $ space. (See my last post on this topic, "Visualizing...
Read more >
Accurate gamut boundary descriptor for displays
Abstract: A new gamut boundary descriptor (GBD) is presented in this paper. ... standards, such as the traditional sRGB standard [1], ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found