This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

ycbcr2rgb

Convert YCbCr color values to RGB color space

Syntax

rgbmap = ycbcr2rgb(ycbcrmap)
RGB = ycbcr2rgb(YCBCR)

Description

example

rgbmap = ycbcr2rgb(ycbcrmap) converts the YCbCr color space values in ycbcrmap to the RGB color space. ycbcrmap is an m-by-3 matrix that contains the YCbCr luminance (Y) and chrominance (Cb and Cr) color values as columns. Each row in rgbmap represents the equivalent color to the corresponding row in ycbcrmap.

You optionally can perform the conversion using a GPU (requires Parallel Computing Toolbox™). For more information, see Image Processing on a GPU.

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

Examples

collapse all

This example shows how to convert an image from RGB to YCbCr color space and back.

Read an RGB image into the workspace.

RGB = imread('board.tif');

Convert the image to YCbCr color space.

YCBCR = rgb2ycbcr(RGB);

Convert the YCbCr image back to RGB color space.

RGB2 = ycbcr2rgb(YCBCR);

Display the luminance channel of the image in YCbCr color space alongside the image that was converted from YCbCr to RGB color space.

figure
subplot(1,2,1)
imshow(YCBCR(:,:,1))
title('Original Luminance (Y)');
subplot(1,2,2)
imshow(RGB2);
title('Image Converted to RGB');

Input Arguments

collapse all

YCbCr color space values, specified as a c-by-3 matrix representing c colors. The first column corresponds to luminance Y. The second and third columns correspond to chrominance Cb and Cr.

To perform the conversion using a GPU, specify ycbcrmap as a gpuArray that contains a c-by-3 matrix.

Data Types: single | double

YCbCr image, specified as an m-by-n-by-3 array.

To perform the conversion using a GPU, specify YCBCR as a gpuArray that contains an m-by-n-by-3 array.

Data Types: single | double | uint8 | uint16

Output Arguments

collapse all

RGB color space values, returned as a c-by-3 matrix. The three columns represent the red, green, and blue channels.

If the conversion is performed using a GPU, then rgbmap is returned as a gpuArray containing a c-by-3 matrix.

Image in RGB color space, returned as an m-by-n-by-3 array.

If the conversion is performed using a GPU, then RGB is returned as a gpuArray containing an m-by-n-by-3 array.

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.

Extended Capabilities

Introduced before R2006a