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
on the MATLAB® command line.
Define an RGB image in the MATLAB workspace. To do so, at the MATLAB command prompt, type:
This command reads in an RGB image from a TIF file. The image 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:
Configure Simulink to display signal dimensions next to each signal line. Select Display > Signals & Ports > Signal Dimensions.
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 to I.|
Change dimensions of the input 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:
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.
|Selector, Selector1, Selector2||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 Separate color signals.|
|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 to 4:2:2 to 4:4:4.
|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 Separate color signals.|