Convert color information between color spaces
Computer Vision Toolbox / Conversions
The Color Space Conversion block converts color information between color spaces. Use the Conversion parameter to specify the color spaces you are converting between.
R'G'B' to Y'CbCr
Y'CbCr to R'G'B'
R'G'B' to intensity
R'G'B' to HSV
HSV to R'G'B'
sR'G'B' to XYZ
XYZ to sR'G'B'
sR'G'B' to L*a*b*
L*a*b* to sR'G'B'
Input
— InputInput color information, specified as an M-by-N-by-P color matrix of P color planes.
Data Types: single
| double
| int8
| uint8
R'
— R planeR plane of the RGB color information, specified as an M-by-N matrix.
Data Types: single
| double
| int8
| uint8
G'
— G planeG plane of the RGB color information, specified as an M-by-N matrix.
Data Types: single
| double
| int8
| uint8
B'
— B planeB plane of the RGB color information, specified as an M-by-N matrix.
Data Types: single
| double
| int8
| uint8
Y'
— Luma signal componentLuma signal component, specified as an M-by-N matrix.
Data Types: single
| double
| int8
| uint8
Cb
— Chrominance componentChrominance component, specified as an M-by-N matrix.
Data Types: single
| double
| int8
| uint8
Cr
— Chrominance componentChrominance component, specified as an M-by-N matrix.
Data Types: single
| double
| int8
| uint8
I'
— Intensity valuesIntensity values specified as an M-by-N matrix.
Data Types: single
| double
| int8
| uint8
H
— Hue componentHue component, specified as an M-by-N matrix.
Data Types: single
| double
S
— Saturation componentSaturation component, specified as an M-by-N matrix.
Data Types: single
| double
V
— Brightness componentBrightness component, specified as an M-by-N matrix.
Data Types: single
| double
X
— X componentX component, specified as an M-by-N matrix.
Data Types: single
| double
Y
— Y componentY component, specified as an M-by-N matrix.
Data Types: single
| double
Z
— Z componentZ component, specified as an M-by-N matrix.
Data Types: single
| double
L*
— Luminance portionLuminance component, specified as an M-by-N matrix.
Data Types: single
| double
a*
— a* componenta* component, specified as an M-by-N matrix.
Data Types: single
| double
b*
— b* componentb* component, specified as an M-by-N matrix.
Data Types: single
| double
Input
— InputInput color information, specified as an M-by-N-by-P color matrix of P color planes.
If the input is uint8
, then Y'CbCr
is
uint8
, where Y
is in the range
[16 235]
, and Cb
and Cr
are in the range [16 240]
.
If the input is a double
, then Y'
is in
the range [16/255 235/255]
and Cb
and
Cr
are in the range [16/255
240/255]
.
Data Types: single
| double
| int8
| uint8
R'
— R planeR plane of the RGB color information, specified as an M-by-N matrix.
Data Types: single
| double
| int8
| uint8
G'
— G planeG plane of the RGB color information, specified as an M-by-N matrix.
Data Types: single
| double
| int8
| uint8
B'
— B planeB plane of the RGB color information, specified as an M-by-N matrix.
Data Types: single
| double
| int8
| uint8
Y'
— Luma signal componentLuma signal component, specified as an M-by-N matrix.
Data Types: single
| double
| int8
| uint8
Cb
— Chrominance componentChrominance component, specified as an M-by-N matrix.
Data Types: single
| double
| int8
| uint8
Cr
— Chrominance componentChrominance component, specified as an M-by-N matrix.
Data Types: single
| double
| int8
| uint8
I'
— Intensity valuesIntensity values specified as an M-by-N matrix.
Data Types: single
| double
| int8
| uint8
H
— Hue componentHue component, specified as an M-by-N matrix.
Data Types: single
| double
S
— Saturation componentSaturation component, specified as an M-by-N matrix.
Data Types: single
| double
V
— Brightness componentBrightness component, specified as an M-by-N matrix.
Data Types: single
| double
X
— X componentX component, specified as an M-by-N matrix.
Data Types: single
| double
Y
— Y componentY component, specified as an M-by-N matrix.
Data Types: single
| double
Z
— Z componentZ component, specified as an M-by-N matrix.
Data Types: single
| double
L*
— Luminance portionLuminance component, specified as an M-by-N matrix.
Data Types: single
| double
a*
— a* componenta* component, specified as an M-by-N matrix.
Data Types: single
| double
b*
— b* componentb* component, specified as an M-by-N matrix.
Data Types: single
| double
Conversion
— ConversionR'G'B' to Y'CbCr
(default) | Y'CbCr to R'G'B'
| R'G'B' to intensity
| R'G'B' to HSV
| HSV to R'G'B'
| sR'G'B' to XYZ
| XYZ to sR'G'B'
| sR'G'B' to L*a*b*
Specify the conversion color spaces as one of the following:
R'G'B' to Y'CbCr
Y'CbCr to R'G'B'
R'G'B' to intensity
R'G'B' to HSV
HSV to R'G'B'
sR'G'B' to XYZ
XYZ to sR'G'B'
sR'G'B' to L*a*b*
L*a*b* to sR'G'B'
Use conversion specified by
— Conversion standardRec. 601 (SDTV)
(default) | Rec. 709 (HDTV)
Specify the standard to convert your values between the R'G'B' and Y'CbCr color
spaces as either Rec. 601 (SDTV)
or Rec. 709
(HDTV)
.
This parameter is visible when you set the Conversion to
R'G'B' to Y'CbCr
or Y'CbCr to
R'G'B'
.
Scanning standard
— Scanning standard1125/60/2:1
(default) | 1250/50/2:1
Specify the scanning standard to convert between the R'G'B' and Y'CbCr color spaces
as either 1125/60/2:1
or
1250/50/2:1
.
This parameter is visible when you set the Use conversion specified
by parameter to Rec. 709 (HDTV)
.
White point
— White pointD50
(default) | D55
| D65
Specify the reference white point.
This parameter is visible when you set the Conversion
parameter to sR'G'B' to L*a*b*
or L*a*b* to
sR'G'B'
.
Image signal
— Image signal inputOne multidimensional signal
(default) | Separate color signals
Specify how to input and output a color signal. If you select One
multidimensional signal
, the block accepts an
M-by-N-by-P color signal,
where P is the number of color planes, at one port. If you select
Separate color signals
, additional ports appear on the
block. Each port accepts one M-by-N plane of color
signal stream.
Note
The prime notation indicates that the signals are gamma corrected.
Data Types |
|
Multidimensional Signals |
|
Variable-Size Signals |
|
The following equations define R'G'B' to Y'CbCr conversion and Y'CbCr to R'G'B' conversion:
The values in matrices A
and B
are based on your
choices for the Use conversion specified by and Scanning
standard parameters.
Matrix | Use conversion specified by = Rec. 601 (SDTV) | Use conversion specified by = Rec. 709 (HDTV) | |
---|---|---|---|
Scanning standard = 1125/60/2:1 | Scanning standard = 1250/50/2:1 | ||
A | |||
B |
The following equation defines conversion from the R'G'B' color space to intensity:
The R'G'B' to HSV conversion is defined by the following equations. In these equations, MAX and MIN represent the maximum and minimum values of each R'G'B' triplet, respectively. H, S, and V vary from 0 to 1, where 1 represents the greatest saturation and value.
The HSV to R'G'B' conversion is defined by the following equations:
The sR'G'B' to XYZ conversion is a two-step process. First, the block converts the gamma-corrected sR'G'B' values to linear sRGB values using the following equations:
Then the block converts the sRGB values to XYZ values using the following equation:
The XYZ to sR'G'B' conversion is also a two-step process. First, the block converts the XYZ values to linear sRGB values using the following equation:
Then the block applies gamma correction to obtain the sR'G'B' values. This process is described by the following equations:
Note
Computer Vision Toolbox™ software uses a D65 white point, which is specified in Recommendation ITU-R BT.709, for this conversion. In contrast, the Image Processing Toolbox™ conversion is based on ICC profiles, and it uses a D65 to D50 Bradford adaptation transformation to the D50 white point. If you are using these two products and comparing results, you must account for this difference.
The Color Space Conversion block converts sR'G'B' values to L*a*b* values in two steps. First it converts sR'G'B' to XYZ values using the equations described in Conversion Between sR'G'B' and XYZ Color Spaces. Then it uses the following equations to transform the XYZ values to L*a*b* values. Here, , , and are the tristimulus values of the reference white point you specify using the White point parameter:
The block converts L*a*b* values to sR'G'B' values in two steps as well. The block transforms the L*a*b* values to XYZ values using these equations:
[1] Poynton, Charles A. A Technical Introduction to Digital Video. New York: John Wiley & Sons, 1996.
[2] Recommendation ITU-R BT.601-5, Studio Encoding Parameters of Digital Television for Standard 4:3 and Wide Screen 16:9 Aspect Ratios.
[3] Recommendation ITU-R BT.709-5. Parameter values for the HDTV standards for production and international programme exchange.
[4] Stokes, Michael, Matthew Anderson, Srinivasan Chandrasekar, and Ricardo Motta, “A Standard Default Color Space for the Internet - sRGB.” November 5, 1996.
[5] Berns, Roy S. Principles of Color Technology, 3rd ed. New York: John Wiley & Sons, 2000.
applycform
| Chroma
Resampling | hsv2rgb
| makecform
| rgb2gray
| rgb2hsv
| rgb2ycbcr
| ycbcr2rgb