Out of gamut colors, matrix, hsv

Based on my opinion that HSV color space (from linear RGB) is one of the best color spaces for gamut reduction (it’s used in adobe dcp) I’ve done a matrix that reduce the OOG colors.

step 1)
i’ ve started with the channel mixer with this parameters:

red: 0 0 1
green: 0 0 1
blu: 0 0 1
blending at 33% opacity and HSV color mode

step 2)
tweaked the hue in the blu colors too much shifted toward purple

red: 0 0 0.8
green: 0 0 1.1
blu: 0 0 1
blending at 33% opacity and HSV color mode

step3)
tweaked other channels so the perceived hue and saturation look the same as before (overall a little less saturation)

red: 0.5 0.2 0.8
green: 0.1 0.3 1.1
blu: 0.1 0.1 1
blending at 33% opacity and HSV color mode

final step)
normalize the matrix so it could be blended at 100% and tweaked a little again

  • red destination :
    • R = 0.888
    • G = 0.066
    • B = 0.265
  • green destination :
    • R = 0.033
    • G = 0.799
    • B = 0.362
  • blue destination :
    • R = 0.033
    • G = 0.033
    • B = 1.00

blending at 100% in normal or hsv color mode.

Some before-after comparison


However it would be very useful to have a HSV equalizer and use it after the conversion to the linear working space

4 Likes

No. No. And no again. Do you even understand what HSL is ? It’s bloody RGB 3D space turned into polar coordinates.

It sucks. It deeply sucks. For soooo many reasons:

  1. not perceptually uniform, aka 10% hue shift in blue will be 200% bigger than a 10% hue shift in red,
  2. 100% dependent on the base RGB space, aka sRGB HSL ≠ Rec2020 HSL,
  3. it’s not hue-invariant, aka reduce HSL “saturation” by 50% and you have changed the (really perceptual) hue too,
  4. not chromaticity-related, aka no connection with light spectrum as well,
  5. the very name “hue-saturation-value/lightness” is misleading because it has actually nothing to do with psychological color perception at all.

HSL spaces go back to the 1980’s. If they were good for gamut mapping, by now we would know it. And yet, CIE is still looking for the perfect gamut-mapping space : CIECAM02 failed, CIECAM16 doesn’t do HDR, IPT-HDR is still not perfectly hue-invariant, JzAzBz is kind of ok but still experimental.

Just because HSL/HSV produces ok-ish results in some cases doesn’t make it a reliable working space.

Please read https://last.hit.bme.hu/download/firtha/video/Colorimetry/Fairchild_M._Color_appearance_models__2005.pdf

There are only 2 ways to do image processing:

  1. the psychological/perceptual way, with color adaptation models like Lab, IPT, CIECAM02, CIECAM16, Hunt-Lab and so on. Problem → they all fail in HDR
  2. the physical/radiometric way, with linear RGB code values as a metric for a light emission.

HSV/HSL is none of the above.

Gamut mapping is a well-known problem of shrinking color spaces and remap source colors to the closest available color in the target space. Again, you can either choose a perceptually based strategy (minimizing the delta E or any other metric of visual color distance) or a chromaticity based strategy (minimizing the wavelength spectral difference).

But HSL/HSV allows none of the above.

The only valid case of HSL use is to “simplify” the GUI of artistic RGB operations. But then, translate the params from HSL to RGB before applying the actual pixel operation.

3 Likes

It is a shame that papers in 2020 still use the HSV/HSL pair. Come on! :unamused: As for gamut expansion and compression, they aren’t common but there are a few interesting papers out there.


That said, @age could you break down your explanation a bit more? It isn’t very clear. I am still interested in your method.

1 Like

Be aware, the only things that really suck are vacuum cleaners :wink: !!!

I personally have a more pragmatic approach… any color space and formula is mostly a tool to achieve a certain result. As for any tool, it can be used properly or not…
HSV is certainly a very limited and simplified model, but @age’s final results look quite convincing to me, even if I they are likely neither perceptually nor radiometrically correct. Given that many of those saturated blues have negative Y components, and do not even know what would be the radiometric truth…

I have spent the past week playing with such “imaginary” colors, trying to find a good method to compress them in a pleasing way, and I must say that I have not yet come up with a good solution based on LCh and/or linear RGB. Hence I am interested in any idea you could have, and we might work together to improve it…

As @afre dais, it would be great of @age could give some more details of his method!

3 Likes

It reminds me that @anon41087856 provided in Step 6 : channel mixer of darktable 3.0 for dummies: hardcore edition a matrix adapted to REC2020 working space from ACES to mitigate the OOG blue.

It is very simple to use these matrix in the ART channel mixer and results are satisfying, even if I dont know the theoretical principle.
I find the second matrix (ACES) an effect more specifically aimed at the OOG blue.

1 Like

I am loaded with stuff to do, but on the topic of recovering sensor imaginary colours (hence, at input, not at the output), the first idea that comes to my mind is to use the piece-wise 1st order smoothness property of the chrominance to unroll a PDE optimization (Fourier/Navier-Stokes like) in an YUV kind of space. Iterate over negative regions in U and V components, until you don’t have negative anymore.

I’m currently writing an article on the use of 2nd order PDE for denoising, it’s the same idea but on the Y component, and adjusted for 2nd order smoothness.

Of course, the clean way would be to have LUT profiles matching RGB sensor garbage to proper XYZ (or, better, spectral data).

4 Likes

The idea was to desaturate the image using the hsv color space where the grayscale (value) image is max(r,g,b).
Then we mix the rgb color (at 67%) with the grayscale (at 33%)

It’s not possible with a color matrix to obtain the Value channel in hsv, so I’ve used the formula grayscale=blu channel, at least in this way the desaturation is “correct” for the blue hue.

The problem is how to do this:

red (r * 0.0 + g * 0.0 + b * 1.0 )
green ( r * 0.0 + g * 0.0 + b * 1.0)
blu ( r * 0.0 + g * 0.0 + b*1.0)
blending the channel mixer layer at 33% with the original

with the matrix only itself.

The equivalent formula for the channel mixer tool is:

red (r * 0 + g * 0 + b * 1) * 0.33 + r * 0.67
green (r * 0 + g * 0 + b * 1) * 0.33 + g * 0.67
blu (r * 0 + g * 0 + b * 1) * 0.33 + b * 0.67

==>

red 0.67 0.00 0.33
green 0.00 0.67 0.33
blu 0.00 0.00 1.00

Edit:

After this global desaturation is possible to restore the saturation in red and green channels using the channel mixer, ideally the blu channel doesn’t change.

1 Like