This is machine translation

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

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.


Convert RGB color values to lightness values


lightness = rgb2lightness(rgb)



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


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.

title('Input RGB Image')

title('Lightness Component of Image')

Input Arguments

collapse all

RGB color values, specified as an m-by-n-by-3 image array. The input rgb must 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 an m-by-n image array. If the input data type is double, the output data type is double. Otherwise, the output data type is single.

Data Types: single | double

Extended Capabilities

Introduced in R2019a