Products & Services Solutions Academia Support User Community Company

Learn more about Video and Image Processing Blockset   

Color Space Conversion

Overview of Color Space Conversion Block

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.

Converting Color Information from R'G'B' to Intensity

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:

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

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

    imshow(I)
    

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

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

  5. Use the Image from Workspace block to import your image from the MATLAB workspace. Set theValue parameter to I.

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

  7. View the modified image using the Video Viewer block. Accept the default parameters.

  8. Connect the blocks so that your model is similar to the following figure.

  9. 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)

  10. Run your model.

    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.

  


Related Products & Applications

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