ycbcr2rgb

Convert YCbCr color values to RGB color space

Description

example

rgbmap = ycbcr2rgb(ycbcrmap) converts the YCbCr color space values in ycbcrmap to the RGB color space. ycbcrmap is a c-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™).

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 numeric matrix representing c colors. 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 numeric array.

Data Types: single | double | uint8 | uint16

Output Arguments

collapse all

RGB color space values, returned as a c-by-3 numeric matrix with values in the range [0, 1]. Each row is a three-element RGB triplet that specifies the red, green, and blue components of a single color of the colormap.

Image in RGB color space, returned as an m-by-n-by-3 numeric 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

GPU Code Generation
Generate CUDA® code for NVIDIA® GPUs using GPU Coder™.

Introduced before R2006a