Main Content

rgbwide2ycbcr

Convert wide-gamut RGB color values to YCbCr color values

Since R2020b

Description

example

ycbcr = rgbwide2ycbcr(RGB,BPS) converts wide-gamut RGB values in the BT.2020 or BT.2100 color spaces into the nonconstant luminance YCbCr color space. BPS specifies the number of bits required to represent each channel of the input values.

Examples

collapse all

Convert 10-bit or 12-bit wide-gamut RGB color values in the BT.2020 or BT.2100 color space to the YCbCr color space.

Convert 10-bit BT.2020 or BT.2100 Wide-Gamut RGB White Color Value to YCbCr

Create a 10-bit wide-gamut RGB value for the color white.

rgblist = uint16([940 940 940]);

Convert the wide-gamut white color value to a YCbCr color value.

ycbcrlist = rgbwide2ycbcr(rgblist,10) 
ycbcrlist = 1x3 uint16 row vector

   940   512   512

Convert 12-bit BT.2020 or BT.2100 Wide-Gamut RGB Image to YCbCr

Simulate a wide-gamut RGB image. Read a normal RGB image into the workspace, convert the image to the XYZ color space, then convert the resulting image to the wide-gamut RGB color space.

RGBWide = imread('peppers.png');
XYZ = rgb2xyz(RGBWide);
RGBWide = xyz2rgbwide(XYZ,12);

Convert the wide-gamut RGB image to the YCbCr color space.

YCBCR = rgbwide2ycbcr(RGBWide,12);

Input Arguments

collapse all

Wide-gamut RGB color values, specified as one of these options:

  • p-by-3 numeric matrix of color values (one color per row)

  • m-by-n-by-3 numeric array representing an image

This table shows the data range for wide-gamut, integer color values for 10- and 12-bit data. The minimum value in each range maps to black, and the maximum value in each range maps to white. The rgbwide2ycbcr function maps only pixels with RGB values within the supported data range to valid YCbCr values.

Data TypeFull Data RangeData Range for Wide-Gamut RGB
10-bit[0, 1023][64, 940]
12-bit [0, 4095][256, 3760]

Data Types: uint16

Bits per sample for each channel of the input wide-gamut RGB image, specified as 10 or 12.

Output Arguments

collapse all

YCbCr color values, returned as a numeric array of the same size as the input RGB color values.

Data Types: uint16

Tips

  • This function does not support the full data range of 10-bit and 12-bit RGB values, [0, 1023] and [0, 4095] respectively. The table shows the data ranges of the YCbCr values for the BT.2020 and BT.2100 color spaces.

    Component10-bit12-bit
    Y[64, 940][256, 3760]
    Cb, Cr[64, 960][256, 3840]

References

[1] Rec. ITU-R BT.2020-2 (10/2015). "Parameter values for ultra-high definition television systems for production and international programme exchange." International Telecommunication Union; Broadcasting service (television). https://www.itu.int/rec/R-REC-BT.2020.

[2] Rec. ITU-R BT.2100-2 (07/2018). "Image parameter values for dynamic range television for use in production and international programme exchange." International Telecommunication Union; Broadcasting service (television). https://www.itu.int/rec/R-REC-BT.2100.

Extended Capabilities

GPU Arrays
Accelerate code by running on a graphics processing unit (GPU) using Parallel Computing Toolbox™.

Version History

Introduced in R2020b