Main Content

vision.ChromaResampler

Downsample or upsample chrominance components of images

Description

To downsample or upsample chrominance components of images:

  1. Create the vision.ChromaResampler object and set its properties.

  2. Call the object with arguments, as if it were a function.

To learn more about how System objects work, see What Are System Objects?.

Creation

Description

example

resampler = vision.ChromaResampler returns a chroma resampling object, Cresampler, that downsamples or upsamples chroma components of a YCbCr signal to reduce the bandwidth and storage requirements.

gammaCorr = vision.ChromaResampler(Name,Value) sets properties using one or more name-value pairs. Enclose each property name in quotes. For example, resampler = vision.ChromaResampler('InterpolationFilter','Linear')

Properties

expand all

Unless otherwise indicated, properties are nontunable, which means you cannot change their values after calling the object. Objects lock when you call them, and the release function unlocks them.

If a property is tunable, you can change its value at any time.

For more information on changing property values, see System Design in MATLAB Using System Objects.

Resampling format, specified as one of the following:

'4:4:4 to 4:2:2'
'4:4:4 to 4:2:0 (MPEG1)'
'4:4:4 to 4:2:0 (MPEG2)'
'4:4:4 to 4:1:1'
'4:2:2 to 4:2:0 (MPEG1)'
'4:2:2 to 4:2:0 (MPEG2)'


To upsample the chrominance components of images, set this property to one of the following:

'4:2:2 to 4:4:4'
'4:2:0 (MPEG1) to 4:4:4'
'4:2:0 (MPEG2) to 4:4:4'
'4:1:1 to 4:4:4'
'4:2:0 (MPEG1) to 4:2:2'
'4:2:0 (MPEG2) to 4:2:2'


Method used to approximate missing values, specified as Pixel replication or Linear. The default is Linear. When you set this property to Linear, the object uses linear interpolation to calculate the missing values. When you set this property to Pixel replication, the object replicates the chrominance values of the neighboring pixels to create the upsampled image. This property applies when you upsample the chrominance values.

Lowpass filter used to prevent aliasing, specified as Auto, Property , or None. When you set this property to Auto, the object uses a built-in lowpass filter. When you set this property to Property, the coefficients of the filters are specified by the HorizontalFilterCoefficients and VerticalFilterCoefficients properties. When you set this property to None, the object does not filter the input signal. This property applies when you downsample the chrominance values.

Horizontal filter coefficients, specified as a three-element vector. This property applies when you set the Resampling property to one of [4:4:4 to 4:2:2] | [4:4:4 to 4:2:0 (MPEG1)] | [4:4:4 to 4:2:0 (MPEG2)] | [4:4:4 to 4:1:1] and the AntialiasingFilterSource property to Property.

Specify the filter coefficients to apply to the input signal, specifie as a two-element vector. This property applies when you set the Resampling property to one of [4:4:4 to 4:2:0 (MPEG1)] | [4:4:4 to 4:2:0 (MPEG2)] | [4:2:2 to 4:2:0 (MPEG1)] | [4:2:2 to 4:2:0 (MPEG2)] and the AntialiasingFilterSource property to Property.

Input is row-major format , specified as true or false. Set this property to true when the input contains data elements from the first row first, then data elements from the second row second, and so on through the last row. Otherwise, the object assumes that the input data is stored in column-major format.

Usage

Description

example

[Cb1,Cr1] = resampler(Cb,Cr) resamples the input chrominance components Cb and Cr and returns Cb1 and Cr1, as the resampled outputs.

Input Arguments

expand all

Chrominance component of an image, specified as a matrix.

Chrominance component of an image, specified as a matrix.

Output Arguments

expand all

Chrominance component of an image, returned as a matrix.

Chrominance component of an image, returned as a matrix.

Object Functions

To use an object function, specify the System object™ as the first input argument. For example, to release system resources of a System object named obj, use this syntax:

release(obj)

expand all

stepRun System object algorithm
releaseRelease resources and allow changes to System object property values and input characteristics
resetReset internal states of System object

Examples

collapse all

Create a resampler object

resampler = vision.ChromaResampler;

Read an RGB image and convert it to YCbCr.

imageRGB = imread('peppers.png');
imageYCbCr = rgb2ycbcr(imageRGB);

Resample the Cb and Cr chrominance components.

[Cb,Cr] = resampler(imageYCbCr(:,:,2), imageYCbCr(:,:,3));

Extended Capabilities

See Also

Introduced in R2012a