Main Content

Convert Data Type and Color Space of Image from RGB to HSV

This example shows you how to convert the data type and color space of an input image from the RGB to the HSV color space.

Example Model

Open the Simulink® model.

modelname = "ex_blkconvertdatatypeandcolorspace.slx";
open_system(modelname);

This model reads an input image using an Image From File block with the File name parameter set to peppers.png. The input image has a data type of uint8.

To convert the image data type to double, the model uses an Image Data Type Conversion block with Output data type set to double.

To convert the input image from the RGB to the HSV color space, the model uses a Color Space Conversion block with these parameters:

  • ConversionR'G'B' to HSV

  • Image signalOne multidimensional signal

The Video Viewer blocks display the input RGB image and the output HSV image.

Simulate the Model

Run the model. The Video Viewer blocks display the input image and the output image converted to the HSV color space.

sim(modelname);