This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Resample Image Chroma

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.

  1. Define an RGB image in the MATLAB workspace. To do so, at the MATLAB command prompt, type:

    I= imread('autumn.tif');
    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.

  2. To view the image this array represents, at the MATLAB command prompt, type:


  3. Configure Simulink to display signal dimensions next to each signal line. Select Display > Signals & Ports > Signal Dimensions.

  4. 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.

  5. 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.

Setting Block Parameters for This Example

The block parameters in this example are modified from default values as follows:

Image from WorkspaceImport your image from the MATLAB workspace. Set the Value parameter to I.
Image Pad

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:

  • Method = Symmetric

  • Add columns to = Right

  • Number of added columns = 1

  • Add row to = 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.


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, Slector2Separate 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:


  • Number of input dimensions = 3

  • Index 1 = Select all

  • Index 2 = Select all

  • Index 3 = Index vector (dialog) and Index = 1


  • Number of input dimensions = 3

  • Index 1 = Select all

  • Index 2 = Select all

  • Index 3 = Index vector (dialog) and Index = 2


  • Number of input dimensions = 3

  • Index 1 = Select all

  • Index 2 = Select all

  • Index 3 = Index vector (dialog) and Index = 3

Color Space ConversionConvert 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 ResamplingDownsample 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.
Chroma Resampling1

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 Conversion1Convert 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

Video Viewer Display the recovered image. Select File>Image signal to set Image signal to Separate color signals.

Configuration Parameters

Open the Configuration dialog box by selecting Model Configuration Parameters from the Simulation menu. Set the parameters as follows:

  • Stop time = 10

  • Type = Fixed-step

  • Solver = Discrete (no continuous states)