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.

Convert R'G'B' to Intensity Images

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:

  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


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


    Video Viewer

    Computer Vision System Toolbox > Sinks


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

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

  6. View the modified image using the Video Viewer block. View the original image using the Video Viewer1 block. Accept the default parameters.

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

  8. 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 time = 0

    • Solver pane, Type = Fixed-step

    • Solver pane, Solver = Discrete (no continuous states)

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