Main Content

ycbcr2rgb

Convert YCbCr color values to RGB color space

Description

example

RGB = ycbcr2rgb(YCBCR) converts the luminance (Y) and chrominance (Cb and Cr) values of a YCbCr image to red, green, and blue values of an RGB image.

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');

Figure contains 2 axes objects. Axes object 1 with title Original Luminance (Y) contains an object of type image. Axes object 2 with title Image Converted to RGB contains an object of type image.

Input Arguments

collapse all

YCbCr color values to convert, specified as a numeric array in one of these formats.

  • c-by-3 colormap. Each row specifies one YCbCr color value.

  • m-by-n-by-3 image.

Data Types: single | double | uint8 | uint16

Output Arguments

collapse all

Converted RGB color values, returned as a numeric array of the same size as the input. The output data type is the same as the input data 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

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

Version History

Introduced before R2006a