www.gusucode.com > images 案例代码 matlab源码程序 > images/UseColorSpaceConversionToHandleOutofGamutColorsExample.m
%% 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. % Copyright 2015 The MathWorks, Inc. lab = [80 -130 85]; lab2rgb(lab) %% % 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. lab2rgb(lab,'ColorSpace','adobe-rgb-1998')