This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.

vision.ColorSpaceConverter System object

Package: vision

Convert color information between color spaces


    Note:   The vision.ColorSpaceConverter System object will be removed in a future release. Use the rgb2gray, rgb2ycbcr, or the makecform and the applycform functions with equivalent functionality instead.

The ColorSpaceConverter object converts color information between color spaces.

    Note:   Starting in R2016b, instead of using the step method to perform the operation defined by the System object™, you can call the object with arguments, as if it were a function. For example, y = step(obj,x) and y = obj(x) perform equivalent operations.


H = vision.ColorSpaceConverter returns a System object, H, that converts color information from RGB to YCbCr using the conversion standard Rec. 601 (SDTV).

H = vision.ColorSpaceConverter(Name,Value) returns a color space conversion object, H, with each specified property set to the specified value. You can specify additional name-value pair arguments in any order as (Name1, Value1,...,NameN,ValueN).

Code Generation Support
Supports MATLAB® Function block: Yes
System Objects in MATLAB Code Generation
Code Generation Support, Usage Notes, and Limitations.



Color space input and output conversion

Specify the conversion color spaces as one of the following:

[RGB to YCbCr]
[YCbCr to RGB]
[RGB to intensity]
[RGB to HSV]
[HSV to RGB]
[sRGB to XYZ]
[XYZ to sRGB]
[sRGB to L*a*b*]
[L*a*b* to sRGB]

Note that the R, G, B and Y (luma) signal components in the preceding color space conversions are gamma corrected. The default is [RGB to YCbCr].


Reference white point

Specify the reference white point as one of D50 | D55 | D65. The default is D65. These values are reference white standards known as tristimulus values that serve to define the color "white" to correctly map color space conversions. This property applies when you set the Conversion property to [sRGB to L*a*b*] or [L*a*b* to sRGB].


Standard for RGB to YCbCr conversion

Specify the standard used to convert the values between the RGB and YCbCr color spaces as one of Rec. 601 (SDTV) | Rec. 709 (HDTV). The default is Rec. 601 (SDTV). This property applies when you set the Conversion property to [RGB to YCbCr] or [YCbCr to RGB].


Scanning standard for RGB-to-YCbCr conversion

Specify the scanning standard used to convert the values between the RGB and YCbCr color spaces as one of [1125/60/2:1] | [1250/50/2:1]. The default is [1125/60/2:1]. This property applies when you set the ConversionStandard property to Rec. 709 (HDTV).


cloneCreate color space converter object with same property values
getNumInputsNumber of expected inputs to step method
getNumOutputsNumber of outputs from step method
isLockedLocked status for input attributes and nontunable properties
release Allow property value and input characteristics changes
stepConvert color space of input image


Convert an image from an RGB to an intensity color space.

i1 = imread('pears.png');

hcsc = vision.ColorSpaceConverter;
hcsc.Conversion = 'RGB to intensity';
i2 = step(hcsc, i1);



This object implements the algorithm, inputs, and outputs described on the Color Space Conversion block reference page. The object properties correspond to the block parameters, except:

The Image signal block parameter allows you to specify whether the block accepts the color video signal as One multidimensional signal or Separate color signals. The object does not have a property that corresponds to the Image signal block parameter. You must always provide the input image to the step method of the object as a single multidimensional signal.

Introduced in R2012a

Was this topic helpful?