Documentation

ycbcr2rgb

Convert YCbCr color values to RGB color space

Syntax

rgbmap = ycbcr2rgb(ycbcrmap)
gpuarrayRGBmap = ycbcr2rgb(gpuarrayYcbcrmap)
RGB = ycbcr2rgb(Ycbcr)
gpuarrayRGB = ycbcr2rgb(gpuarrayYcbcr)

Description

rgbmap = ycbcr2rgb(ycbcrmap) converts the YCbCr values in the colormap ycbcrmap to the RGB color space. If ycbcrmap is M-by-3 and contains the YCbCr luminance (Y) and chrominance (Cb and Cr) color values as columns, rgbmap is returned as an M-by-3 matrix that contains the red, green, and blue values equivalent to those colors.

gpuarrayRGBmap = ycbcr2rgb(gpuarrayYcbcrmap) performs the conversion on a GPU. The input image, gpuarrayYcbcrmap, is a gpuArray containing a YCbCr colormap. The output is a gpuArray containing an RGB colormap. This syntax requires the Parallel Computing Toolbox™.

RGB = ycbcr2rgb(Ycbcr) converts the YCbCr image Ycbcr to the equivalent truecolor image RGB.

gpuarrayRGB = ycbcr2rgb(gpuarrayYcbcr) performs the conversion on a GPU. The input image, gpuarrayYcbcr, is a gpuArray containing a YCbCr image. The output is a gpuArray containing an RGB image. This syntax requires the Parallel Computing Toolbox.

Code Generation support: Yes.

MATLAB Function Block support: Yes.

Class Support

If the input is a YCbCr image, it can be of class uint8, uint16, or double. The output image is of the same class as the input image. If the input is a colormap, the input and output colormaps are both of class double.

If the input is a YCbCr gpuArray image, it can contain uint8, uint16, single or double. The output gpuArray image contains the same class as the input image. If the input is a gpuArray colormap, the input and output gpuArray colormaps can contain single or double.

Examples

Convert image from RGB space to YCbCr space and back.

rgb = imread('board.tif');
ycbcr = rgb2ycbcr(rgb);
rgb2 = ycbcr2rgb(ycbcr);

Convert image from RGB space to YCbCr space and back on a GPU.

rgb = gpuArray(imread('board.tif'));
ycbcr = rgb2ycbcr(rgb);
rgb2 = ycbcr2rgb(ycbcr);

More About

collapse all

Code Generation

This function supports the generation of C code using MATLAB® Coder™. Note that if you choose the generic MATLAB Host Computer target platform, the function generates code that uses a precompiled, platform-specific shared library. Use of a shared library preserves performance optimizations but limits the target platforms for which code can be generated. For more information, see Understanding Code Generation with Image Processing Toolbox.

MATLAB Function Block

You can use this function in the MATLAB Function Block in Simulink.

References

[1] Poynton, C. A.A Technical Introduction to Digital Video, John Wiley & Sons, Inc., 1996, p. 175.

[2] Rec. ITU-R BT.601-5, Studio Encoding Parameters of Digital Television for Standard 4:3 and Wide-screen 16:9 Aspect Ratios, (1982-1986-1990-1992-1994-1995), Section 3.5.

Introduced before R2006a

Was this topic helpful?