In this example, you use the Chroma Resampling block to downsample the Cb and Cr components of an image. 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. The human eye is more sensitive to changes in luma than to changes in chroma. Therefore, 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.
You can open the example model by typing at the MATLAB® command line.
Define an RGB image in the MATLAB workspace. To do so, at the MATLAB command prompt, type:
Iis 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:
Configure Simulink to display signal dimensions next to each signal line. Select Display > Signals & Ports > Signal Dimensions.
Run your model. The recovered image appears in the Video Viewer window. The Chroma Resampling block has downsampled the Cb and Cr components of an image.
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.
The block parameters in this example are modified from default values as follows:
|Image from Workspace||Import your image from the MATLAB workspace. Set the Value parameter
Change dimensions of the input
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.
When you process video streams, be aware that it is computationally expensive to pad every video frame. You should change the dimensions of the video stream before you process it with Computer Vision System Toolbox™ blocks.
|Selector, Selector1, Slector2||Separate the individual color planes from the main signal.
Such separation simplifies the color space conversion section of the
model. Set the Selector block parameters as follows:|
|Color Space Conversion||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 |
|Chroma Resampling||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.|
Upsample the chroma components of the image from the
4:2:2 format to the 4:4:4 format. Set the Resampling parameter
|Color Space Conversion1||Convert the input values from the Y'CbCr color space to the
R'G'B' color space. Set the block parameters as follows:|
|Video Viewer||Display the recovered image. Select File>Image
signal to set Image signal to |
Open the Configuration dialog box by selecting Model Configuration Parameters from the Simulation menu. Set the parameters as follows:
Stop time =
(no continuous states)