| Video and Image Processing Blockset™ | ![]() |
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. Your choices are 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*, and L*a*b* to sR'G'B'.
| Port | Input/Output | Supported Data Types | Complex Values Supported |
|---|---|---|---|
| Input / Output | M-by-N-by-P color video signal where P is the number of color planes |
| No |
R' | Matrix that represents one plane of the input RGB video stream | Same as the Input port | No |
G' | Matrix that represents one plane of the input RGB video stream | Same as the Input port | No |
B' | Matrix that represents one plane of the input RGB video stream | Same as the Input port | No |
Y' | Matrix that represents the luma portion of an image | Same as the Input port | No |
Cb | Matrix that represents one chrominance component of an image | Same as the Input port | No |
Cr | Matrix that represents one chrominance component of an image | Same as the Input port | No |
I' | Matrix of intensity values | Same as the Input port | No |
H | Matrix that represents the hue component of an image |
| No |
S | Matrix that represents represent the saturation component of an image | Same as the H port | No |
V | Matrix that represents the value (brightness) component of an image | Same as the H port | No |
X | Matrix that represents the X component of an image | Same as the H port | No |
Y | Matrix that represents the Y component of an image | Same as the H port | No |
Z | Matrix that represents the Z component of an image | Same as the H port | No |
L* | Matrix that represents the luminance portion of an image | Same as the H port | No |
a* | Matrix that represents the a* component of an image | Same as the H port | No |
b* | Matrix that represents the b* component of an image | Same as the H port | No |
The data type of the output signal is the same as the data type of the input signal.
Use the Image signal parameter to specify how to input and output a color video signal. If you select One multidimensional signal, the block accepts an M-by-N-by-P color video 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 an RGB video stream.
Note The prime notation indicates that the signals are gamma corrected. |
The R'G'B' to Y'CbCr conversion and the Y'CbCr to R'G'B' conversion are defined by the following equations:


The values in the A and B matrices are based on your choices for the Use conversion specified by and Scanning standard parameters. The following table summarizes the possible values:
| 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 conversion from the R'B'G' color space to intensity is defined by the following equation:

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:

For more information about the HSV color space, see HSV Color Space in the Image Processing Toolbox™ documentation.
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 Video and Image Processing Blockset 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:

The Color Space Conversion dialog box appears as shown in the following figure.

Specify the color spaces you are converting between. Your choices are 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*, and L*a*b* to sR'G'B'.
Specify the standard to use to convert your values between the R'G'B' and Y'CbCr color spaces. Your choices are Rec. 601 (SDTV) or Rec. 709 (HDTV). This parameter is only available if, for the Conversion parameter, you select R'G'B' to Y'CbCr or Y'CbCr to R'G'B'.
Specify the scanning standard to use to convert your values between the R'G'B' and Y'CbCr color spaces. Your choices are 1125/60/2:1 or 1250/50/2:1. This parameter is only available if, for the Use conversion specified by parameter, you select Rec. 709 (HDTV).
Specify the reference white point. This parameter is visible if, for the Conversion parameter, you select sR'G'B' to L*a*b* or L*a*b* to sR'G'B'.
Specify how to input and output a color video signal. If you select One multidimensional signal, the block accepts an M-by-N-by-P color video 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 an RGB video stream.
[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.
Video and Image Processing Blockset | |
| rgb2hsv | MATLAB |
| hsv2rgb | MATLAB |
| rgb2ycbcr | Image Processing Toolbox |
| ycbcr2rgb | Image Processing Toolbox |
| rgb2gray | Image Processing Toolbox |
| makecform | Image Processing Toolbox |
| applycform | Image Processing Toolbox |
![]() | Closing | Compositing | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |