Fast gamut detection and gamut limiter [CTL]

gamut.7z (1.2 KB)

I just want to share my gamut limiter algo

The idea is originated from the following observation:

Saturation in HSV color model

Cmax = max(R’, G’, B’)

Cmin = min(R’, G’, B’)

S= (Cmax - Cmin ) / Cmax

Saturation in HSI color model

They both can be rewritten as follow:

saturation = 1 - (minvalue/luminance)

minvalue=min(r,g,b)

Luminance is HSV color space is max(r,g,b)

This is convenient because using this formula values greater than 1 are out-of-gamut colors

I calculate luminance in this way
lum = r* 0.25 +g* 0.50 + b * 0.25;

This is close to the real luminance but it doesn’t becomes negative with real images with strong blue neon colors.

The saturation correction is done in this way:

rgb=(rgb-lum)*saturation_correction+lum;

The default gamut limiter value is 89% of the max possible saturation because it gives a good path to white if used before a rgb tonemapping (like sigmoid)

1 Like

JFYI maybe checkout this post to learn how to format math formulas Let's use math my nerds

1 Like