Documentation

This is machine translation

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

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan 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)
gpuarrayB = ycbcr2rgb(gpuarrayA)

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.

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

gpuarrayB = ycbcr2rgb(gpuarrayA) performs the conversion on a GPU. The input image, gpuarrayA, is a gpuArray containing YCbCr color space values or a YCbCr image. The output is a gpuArray containing RGB color space values or an RGB image, depending on the input type. This syntax requires the Parallel Computing Toolbox™.

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 an m-by-3 array. The first column corresponds to luminance Y. The second and third columns correspond to chrominance Cb and Cr.

Data Types: single | double

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

Data Types: single | double | uint8 | uint16

YCbCr color space values or YCbCr image to be processed on a graphics processing unit (GPU), specified as a gpuArray object.

Output Arguments

collapse all

RGB color space values, returned as an m-by-3 array. The three columns represent the red, green, and blue channels.

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

Output in RGB color space when run on a graphics processing unit (GPU), returned as a gpuArray object. The output is either an array of RGB color space values or an RGB image, depending on the input type.

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

Was this topic helpful?