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 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
Create a new Simulink® model, and add to it the blocks shown in the following table.
Image From Workspace
Computer Vision System Toolbox™ > Sources
Color Space Conversion
Computer Vision System Toolbox > Conversions
Computer Vision System Toolbox > Sinks
Use the Image
from Workspace block to import your image from the MATLAB
workspace. Set theValue parameter to
Use the Color
Space Conversion block to convert the input values from the
R'G'B' color space to intensity. Set the Conversion parameter
R'G'B' to intensity.
View the modified image using the Video Viewer block. View the original image using the Video Viewer1 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 Model Configuration Parameters from the Simulation menu. Set the parameters as follows:
Solver pane, Stop
Solver pane, Type =
Solver pane, Solver =
(no continuous states)
Run your model.
The image displayed in the Video Viewer window is the intensity
version of the
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.