Main Content

ycbcr2rgbwide

Convert YCbCr color values to wide-gamut RGB color values

    Description

    example

    RGB = ycbcr2rgbwide(YCbCr,BPS) converts non-constant luminance YCbCr values into wide-gamut RGB values in the BT.2020 or BT.2100 color spaces. BPS specifies the number of bits required to represent each channel in the output image.

    Examples

    collapse all

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

    Convert 12-bit YCbCr Color Value to Wide-Gamut RGB Color Value

    Create a 12-bit YCbCr color value in the workspace.

    ycbcrlist = uint16([3760 2048 2048]);

    Convert the YCbCr color value to wide-gamut RGB color value.

    rgblist = ycbcr2rgbwide(ycbcrlist, 12);

    Convert 10-bit YCbCr Image to Wide-Gamut RGB Image

    Create a synthetic YCbCr image in the workspace.

    YCBCR = reshape(uint16([64 512 512; 940 512 512]),[2 1 3]);

    Convert the YCbCr image to a wide-gamut RGB image.

    RGB = ycbcr2rgbwide(YCBCR,10);

    Input Arguments

    collapse all

    YCbCr 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

    Data Types: uint16

    Bits per sample for each channel of the input image, specified as the numeric scalar 10 or 12.

    Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

    Output Arguments

    collapse all

    Wide-gamut RGB values, returned as a numeric array of the same size as the input YCbCr values, of class uint16.

    The following table shows the data range for the wide-gamut, integer color values for 10- and 12-bit data. The minimum value in the range maps to black, and the maximum value in the range maps to white. The ycbcr2rgbwide 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]

    Tips

    • This table shows the data ranges of the YCbCr values for 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

    [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

    Extended Capabilities

    C/C++ Code Generation
    Generate C and C++ code using MATLAB® Coder™.

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

    Introduced in R2020b