| 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 |
| On this page… |
|---|
The Color Space Conversion block enables you to convert color information from the R'G'B' color space to the Y'CbCr color space and from the Y'CbCr color space to the R'G'B' color space as specified by Recommendation ITU-R BT.601-5. This block can also be used to convert from the R'G'B' color space to intensity. The prime notation indicates that the signals are gamma corrected.
Some image processing algorithms are customized for intensity images. If you want to use one of these algorithms, you must first convert your image to intensity. In this topic, you learn how to use the Color Space Conversion block to accomplish this task. You can use this procedure to convert any R'G'B' image to an intensity image:
Define an R'G'B' image in the MATLAB workspace. To read in an R'G'B' image from a JPG file, at the MATLAB command prompt, type
I= imread('greens.jpg');
I is a 300-by-500-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 matrix 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 |
Color Space Conversion | Video and Image Processing Blockset > Conversions | 1 |
Video Viewer | Video and Image Processing Blockset > Sinks | 1 |
Position the blocks as shown in the following figure.

Once you have assembled the blocks needed to convert a R'G'B' image to an intensity image, 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 theValue parameter to I.
Use the Color Space Conversion block to convert the input values from the R'G'B' color space to intensity. Set the Conversion parameter to R'G'B' to intensity.

View the modified image using the Video Viewer block. Accept the default parameters.
Connect the blocks so that your model is similar to the following figure.

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)
The image displayed in the Video Viewer window is the intensity version of the greens.jpg image.

In this topic, you used the Color Space Conversion block to convert color information from the R'G'B' color space to intensity. For more information on this block, see the Color Space Conversion block reference page in the Video and Image Processing Blockset Reference.
![]() | Intensity to Binary Conversion | Chroma Resampling | ![]() |

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 |