Main Content

rgb2lightness

Convert RGB color values to lightness values

Since R2019a

Description

example

lightness= rgb2lightness(rgb)converts RGB color values to lightness values, excluding the color components.lightnessis same as the L* component in the CIE 1976 L*a*b* color space.

Examples

collapse all

Read RGB image into the workspace.

rgb = imread('peppers.png');

Convert the RGB color values to lightness component, excluding the color information.

lightness = rgb2lightness(rgb);

Display the RGB image and the derived lightness component of image.

figure imshow(rgb) title('Input RGB Image')

Figure contains an axes object. The axes object with title Input RGB Image contains an object of type image.

figure imshow(lightness,[]) title('Lightness Component of Image') colorbar

Figure contains an axes object. The axes object with title Lightness Component of Image contains an object of type image.

Input Arguments

collapse all

RGB color values, specified as anm-by-n-by-3 image array. The inputrgbmust be in sRGB color space with a reference white point of D65.

Data Types:single|double|uint8|uint16

Output Arguments

collapse all

Converted lightness values, returned as anm-by-nimage array. If the input data type isdouble, the output data type isdouble. Otherwise, the output data type issingle.

Data Types:single|double

Extended Capabilities

版本History

Introduced in R2019a

expand all

Baidu
map