| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Video and Image Processing Blockset |
| Contents | Index |
| Learn more about Video and Image Processing Blockset |
The Y'CbCr color space separates the luma (Y') component of an image from the chroma (Cb and Cr) components. Luma and chroma, which are calculated using gamma corrected R, G, and B (R', G', B') signals, are different quantities than the CIE chrominance and luminance. Because the human eye is more sensitive to changes in luma than to changes in chroma, you can reduce the bandwidth required for transmission or storage of a signal by removing some of the color information. For this reason, this color space is often used for digital encoding and transmission applications. In the following example, you use the Chroma Resampling block to downsample the Cb and Cr components of an image:
Define an RGB image in the MATLAB workspace. To read in an RGB image from a TIF file, at the MATLAB command prompt, type
I= imread('autumn.tif');
I is a 206-by-345-by-3 array of 8-bit unsigned integer values. Each plane of this array represents the red, green, or blue color values of the image.
To view the image this array represents, at the MATLAB command prompt, type
imshow(I)

Create a new Simulink model, and add to it the blocks shown in the following table.
Block | Library | Quantity |
|---|---|---|
Image From Workspace | Video and Image Processing Blockset > Sources | 1 |
Image Pad | Video and Image Processing Blockset > Utilities | 1 |
Color Space Conversion | Video and Image Processing Blockset > Conversions | 2 |
Chroma Resampling | Video and Image Processing Blockset > Conversions | 2 |
Video Viewer | Video and Image Processing Blockset > Sinks | 1 |
Selector | Simulink > Signal Routing | 3 |
Position the blocks as shown in the following figure.

The blocks to the left of and including the Chroma Resampling block represent the transmission portion of the model. The remaining blocks represent the receiving portion of the model. Once you have assembled these blocks, you are ready to set your block parameters. To do this, double-click the blocks, modify the block parameter values, and click OK.
Use the Image from Workspace block to import your image from the MATLAB workspace. Set the Value parameter to I.
Use the Image Pad block to change the dimensions of the I array from 206-by-345-by-3 to 206-by-346-by-3. You are changing these dimensions because the Chroma Resampling block requires that the dimensions of the input be divisible by 2. Set the block parameters as follows:
Method = Symmetric
Pad rows at = Right
Pad size along rows = 1
Pad columns at = No padding

The Image Pad block adds one column to the right of each plane of the array by repeating its border values. This padding minimizes the effect of the pixels outside the image on the processing of the image.
Use the Selector blocks to separate the individual color planes from the main signal. This simplifies the color space conversion section of the model. Set the Selector block parameters as follows:
Number of input dimensions = 3
1
Index Option = Select all
2
Index Option = Select all
3
Index Option = Index vector (dialog)
Index = 1
Set the Selector1 block parameters as follows:
Number of input dimensions = 3
1
Index Option = Select all
2
Index Option = Select all
3
Index Option = Index vector (dialog)
Index = 2
Set the Selector2 block parameters as follows:
Number of input dimensions = 3
1
Index Option = Select all
2
Index Option = Select all
3
Index Option = Index vector (dialog)
Index = 3
Use the Color Space Conversion block to convert the input values from the R'G'B' color space to the Y'CbCr color space. The prime symbol indicates a gamma corrected signal. Set the Image signal parameter to Separate color signals.
Use the Chroma Resampling block to downsample the chroma components of the image from the 4:4:4 format to the 4:2:2 format. Use the default parameters.

The dimensions of the output of the Chroma Resampling block are smaller than the dimensions of the input. Therefore, the output signal requires less bandwidth for transmission.
Use the Chroma Resampling1 block to upsample the chroma components of the image from the 4:2:2 format to the 4:4:4 format. Set the Resampling parameter to 4:2:2 to 4:4:4.
Use the Color Space Conversion1 block to convert the input values from the Y'CbCr color space to the R'G'B' color space. Set the block parameters as follows:
Conversion = Y'CbCr to R'G'B'
Image signal = Separate color signals
Use the Video Viewer block to display the recovered image. Set the Image signal parameter to Separate color signals.
Connect the blocks as shown in the following figure.

Configure Simulink to display signal dimensions next to each signal line. Click Format > Port/Signal Displays > Signal Dimensions.
Set the configuration parameters. Open the Configuration dialog box by selecting Configuration Parameters from the Simulation menu. Set the parameters as follows:
Solver pane, Stop time = 0
Solver pane, Type = Fixed-step
Solver pane, Solver = Discrete (no continuous states)
Run the model.
The recovered image appears in the Video Viewer window.

Examine the signal dimensions in your model. The Chroma Resampling block downsamples the Cb and Cr components of the image from 206-by-346 matrices to 206-by-173 matrices. These matrices require less bandwidth for transmission while still communicating the information necessary to recover the image after it is transmitted.
You have used the Chroma Resampling block to downsample the Cb and Cr components of an image. For more information about this block, see the Chroma Resampling block reference page in the Video and Image Processing Blockset Reference.
![]() | Color Space Conversion | Geometric Transformation | ![]() |

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |