September 4th, 2024

sRGB Gamut Clipping (2021)

The article addresses RGB gamut clipping in image processing, criticizing clamping methods and proposing two novel techniques using the Oklab color space to reduce color distortion while preserving lightness and chroma.

Read original articleLink Icon
sRGB Gamut Clipping (2021)

The article discusses the issue of RGB gamut clipping in image processing, where RGB values can exceed the valid range, leading to color distortion. It categorizes out-of-gamut colors into two types: those that are too bright and those that have negative values, which can represent colors that are not physically possible. The common method of clamping RGB values is criticized for causing significant color distortions. The article introduces two main research areas: tone mapping and gamut mapping, focusing specifically on the latter. Gamut clipping aims to map out-of-gamut colors back into the valid range without introducing artifacts. The author proposes using the Oklab perceptual color space to maintain hue while adjusting lightness and chroma. Two novel methods for gamut clipping are introduced: one that projects colors towards a midpoint and another that adapts based on the color's lightness. Both methods aim to preserve lightness while effectively managing chroma compression. The article concludes with a comparison of results from different gamut clipping techniques, highlighting the effectiveness of the proposed methods in reducing color distortion.

- RGB gamut clipping can lead to significant color distortions in image processing.

- Clamping RGB values is a common but flawed technique for handling out-of-gamut colors.

- The article focuses on developing practical alternatives to RGB clipping using the Oklab color space.

- Two novel gamut clipping methods are introduced, aiming to preserve lightness while managing chroma.

- The effectiveness of these methods is demonstrated through comparative results.

Link Icon 8 comments
By @herf - 5 months
It's a good generalization of several techniques. The main thing I want to know is this: how does it look with actual HDR exposures, not the synthetic ones made by "increasing exposure and colorfulness significantly"? We shouldn't choose a method based on how natural the result is, when there is a "stretching" step like this that is not at all natural.
By @mattdesl - 5 months
I’ve implemented[1] some of these algorithms into @texel/color, a modern JS color library, and it also supports gamut mapping to certain wide gamut color spaces (Display P3, Rec2020, Adobe 1998) rather than just sRGB.

https://github.com/texel-org/color

Many popular color libraries (Colorjs.io, culori) attempt to match CSS gamut mapping spec, which is an order of magnitude slower than the approach in Ottosson’s blog post, and also less accurate (CSS gamut mapping may not fall neatly on the gamut boundary).

[1] “Ported” might be a better term as I used a combination of Ottosson’s own JS OKHSL picker, Colorjs.io code, and Coloraide (Python), and adjusted it for performance, more gamuts, and smaller bundle sizes.

By @smittywerben - 4 months
I used to ignore all of this color stuff until I made a custom health potion asset (Note: not an artist). It looked surprisingly good. I sent it to my friend on Discord and immediately noticed a change: it converted my beautiful Blood Red into Bog Water Brown. I had an existential crisis. Is every Blood Red on the web converted to to Bog Water Brown? Does sRGB's red not go more "red" than that? Now every red on the internet looks like brown to me.
By @cmovq - 5 months
In games it’s common to have a tone mapping step [1] to map the HDR image to sRGB while maintaining pleasant colors.

The exposure parameter is usually dynamically chosen by using the average brightness of a previous frame.

[1]: http://filmicworlds.com/blog/filmic-tonemapping-operators/

By @strogonoff - 4 months
Clipping is a danger not just with sRGB gamut but in any case where you process a wider dynamic or colour range into a narrower one—for example, that is essentially what photography is (because a sensor capable of capturing the full range of human sight does not exist, and neither does display media capable of reproducing the range of values captured by a modern digital camera sensor).

If you are a photographer, this process starts with camera settings at shooting time and ends with delivery to preferred display space. I believe the whole process can or even should be a creative one rather than purely algorithmic, and fitting dynamic range is an opportunity for you to accentuate/attenuate the right aspects of the image to convey a desirable effect.

(This is not unlike microphone placement in audio recording, or equalisation/compression in subsequent mixing. First you deal with extreme range of actual physical sound and limit it to capabilities of recording media, then you further fit it to the range of audio reproducing capabilities of consumer equipment and to modern listening conditions, and throughout the entire process you accentuate and attenuate.)

By @suzumer - 5 months
I haven't gone through the whole article, but it seems to be conflating chroma and saturation. If lightness of a color is scaled by a factor c, then chroma needs to be scaled by that same factor, or saturation won't be preserved, and the color will appear more vibrant then it should.
By @Rapzid - 5 months
Color management is such a shit show on PCs. Most phones these days support a large percentage of DCI-P3 and are configured for it.

But even if you have a monitor that supports DCI-P3 you have to slog through modes, profiles, and blog posts to get it setup.

Should you always have HDR on? Why does SDR content always look "wrong" when HDR is on? Oh, it's because the peak brightness and color saturation blah blah blah.

Gamma 2.0, 2.2, or 2.4?

Now you learn the hard way the "desktop" is not color managed, it's the individual applications.. If they want to be. Maybe they'll use the windows configured profile, maybe not.