Steve on Image Processing and MATLAB

Concepts, algorithms & MATLAB

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the Original version of the page.

Out-of-gamut colors 4

Posted by Steve Eddins,

The set of colors that can be represented using a particular color space is called the gamut. Some L*a*b* color values may be out of gamut when converted to RGB. You know that a converted RGB color is out of gamut when any of its component values is less than 0 or greater than 1.

lab = [80 -130 85];
ans =

   -0.6210    0.9537   -0.1926

The negative values demonstrate that the L*a*b* color [80 -130 85] is not in the gamut of the sRGB color space, which is the default RGB color space used by lab2rgb. A different RGB color space, Adobe RGB (1998), has a larger gamut than sRGB. Use the 'ColorSpace' parameter to convert a L*a*b* color to the Adobe color space.

ans =

    0.1234    0.9522    0.1073

Because all the output values are between 0.0 and 1.0 (inclusive), you can conclude that the L*a*b* color [80 -130 85] is inside the Adobe RGB (1998) gamut.

Get the MATLAB code

Published with MATLAB® R2015a


Comments are closed.

4 CommentsOldest to Newest

Vlad Atanasiu replied on : 1 of 4
I was wondering what is the algorithm of the function 'makecform' to produce values within the RGB gamut. I am referring to a line of code such as . Although the documentation suggests you use 'lab2rgb' (why?), you often see the previous code. Maybe because it is gracefully taking care of out of gamut values.
Vlad Atanasiu replied on : 3 of 4
Steve, your explanation on this page would make a great addition to the online documentation of function 'lab2rgb'!
Steve Eddins replied on : 4 of 4
Vlad—applycform simply clips the out-of-range values. This can be a useful behavior, too, but if you want to do calculations based on out-of-gamut values, you're out of luck. That information has been lost in the output of applycform. The reason you see a lot of code that uses makecform and applycform is that these functions have been in the product for a long time, more than a decade, whereas lab2rgb and friends were added quite recently. I will pass along your suggestion about the documentation.