Main Content

Determine If L*a*b* Value Is in RGB Gamut

This example shows how to use color space conversion to determine if an L*a*b* value is in the RGB gamut. The set of colors that can be represented using a particular color space is called its gamut . Some L*a*b* color values may be out-of-gamut when converted to RGB.

Convert an L*a*b* value to RGB. The negative values returned 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. An RGB color is out of gamut when any of its component values are less than 0 or greater than 1.

lab = [80 -130 85];
ans = 1×3

   -0.6209    0.9537   -0.1927

Convert the L*a*b* value to RGB, this time specifying a different RGB colorspace, the Adobe RGB (1998) color space. The Adobe RGB (1998) has a larger gamut than sRGB. Use the 'ColorSpace' name-value pair. Because 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.

ans = 1×3

    0.1236    0.9522    0.1072