# YCbCr

(Redirected from Y'CbCr)
A visualization of YCbCr color space
The CbCr plane at constant luma Y′=0.5
A color image and its Y′, CB and CR components. The Y′ image is essentially a greyscale copy of the main image.

YCbCr, Y′CbCr, or Y Pb/Cb Pr/Cr, also written as YCBCR or Y′CBCR, is a family of color spaces used as a part of the color image pipeline in video and digital photography systems. Y′ is the luma component and CB and CR are the blue-difference and red-difference chroma components. Y′ (with prime) is distinguished from Y, which is luminance, meaning that light intensity is nonlinearly encoded based on gamma corrected RGB primaries.

Y′CbCr color spaces are defined by a mathematical coordinate transformation from an associated RGB primaries and white point. If the underlying RGB color space is absolute, the Y′CbCr color space is an absolute color space as well; conversely, if the RGB space is ill-defined, so is Y′CbCr. The transformation is defined in ITU-T H.273. Nevertheless that rule does not apply to DCI-D65 primaries used by Netflix with BT.2020-NCL matrix.

## Rationale

Cathode ray tube displays are driven by red, green, and blue voltage signals, but these RGB signals are not efficient as a representation for storage and transmission, since they have a lot of redundancy.

YCbCr and Y′CbCr are a practical approximation to color processing and perceptual uniformity, where the primary colors corresponding roughly to red, green and blue are processed into perceptually meaningful information. By doing this, subsequent image/video processing, transmission and storage can do operations and introduce errors in perceptually meaningful ways. Y′CbCr is used to separate out a luma signal (Y′) that can be stored with high resolution or transmitted at high bandwidth, and two chroma components (CB and CR) that can be bandwidth-reduced, subsampled, compressed, or otherwise treated separately for improved system efficiency.

One practical example would be decreasing the bandwidth or resolution allocated to "color" compared to "black and white", since humans are more sensitive to the black-and-white information (see image example to the right). This is called chroma subsampling.

## YCbCr

YCbCr is sometimes abbreviated to YCC. Y′CbCr is often called YPbPr when used for analog component video, although the term Y′CbCr is commonly used for both systems, with or without the prime.

Y′CbCr is often confused with the YUV color space, and typically the terms YCbCr and YUV are used interchangeably, leading to some confusion. The main difference is that YUV is for analog TV and YCbCr is for digital TV, the difference is also that Umax and Vmax in YCbCr are both ${\displaystyle {1 \over 2}}$.

Y′CbCr signals (prior to scaling and offsets to place the signals into digital form) are called YPbPr, and are created from the corresponding gamma-adjusted RGB (red, green and blue) source using three defined constants KR, KG, and KB as follows:

{\displaystyle {\begin{aligned}Y'&=K_{R}\cdot R'+K_{G}\cdot G'+K_{B}\cdot B'\\P_{B}&={\frac {1}{2}}\cdot {\frac {B'-Y'}{1-K_{B}}}\\P_{R}&={\frac {1}{2}}\cdot {\frac {R'-Y'}{1-K_{R}}}\end{aligned}}}

where KR, KG, and KB are ordinarily derived from the definition of the corresponding RGB space, and required to satisfy ${\displaystyle K_{R}+K_{G}+K_{B}=1}$.

The equivalent matrix manipulation is often referred to as the "color matrix":

${\displaystyle {\begin{bmatrix}Y'\\P_{B}\\P_{R}\end{bmatrix}}={\begin{bmatrix}K_{R}&K_{G}&K_{B}\\-{\frac {1}{2}}\cdot {\frac {K_{R}}{1-K_{B}}}&-{\frac {1}{2}}\cdot {\frac {K_{G}}{1-K_{B}}}&{\frac {1}{2}}\\{\frac {1}{2}}&-{\frac {1}{2}}\cdot {\frac {K_{G}}{1-K_{R}}}&-{\frac {1}{2}}\cdot {\frac {K_{B}}{1-K_{R}}}\end{bmatrix}}{\begin{bmatrix}R'\\G'\\B'\end{bmatrix}}}$

And its inverse:

${\displaystyle {\begin{bmatrix}R'\\G'\\B'\end{bmatrix}}={\begin{bmatrix}1&0&2-2\cdot K_{R}\\1&-{\frac {K_{B}}{K_{G}}}\cdot (2-2\cdot K_{B})&-{\frac {K_{R}}{K_{G}}}\cdot (2-2\cdot K_{R})\\1&2-2\cdot K_{B}&0\end{bmatrix}}{\begin{bmatrix}Y'\\P_{B}\\P_{R}\end{bmatrix}}}$

Here, the prime (′) symbols mean gamma correction is being used; thus R′, G′ and B′ nominally range from 0 to 1, with 0 representing the minimum intensity (e.g., for display of the color black) and 1 the maximum (e.g., for display of the color white). The resulting luma (Y) value will then have a nominal range from 0 to 1, and the chroma (PB and PR) values will have a nominal range from -0.5 to +0.5. The reverse conversion process can be readily derived by inverting the above equations.

When representing the signals in digital form, the results are scaled and rounded, and offsets are typically added. For example, the scaling and offset applied to the Y′ component per specification (e.g. MPEG-2[1]) results in the value of 16 for black and the value of 235 for white when using an 8-bit representation. The standard has 8-bit digitized versions of CB and CR scaled to a different range of 16 to 240. Consequently, rescaling by the fraction (235-16)/(240-16) = 219/224 is sometimes required when doing color matrixing or processing in YCbCr space, resulting in quantization distortions when the subsequent processing is not performed using higher bit depths.

The scaling that results in the use of a smaller range of digital values than what might appear to be desirable for representation of the nominal range of the input data allows for some "overshoot" and "undershoot" during processing without necessitating undesirable clipping. This "headroom" and "toeroom"[2] can also be used for extension of the nominal color gamut, as specified by xvYCC.

The value 235 accommodates a maximum black-to-white overshoot of 255 - 235 = 20, or 20 / (235 - 16) = 9.1%, which is slightly larger than the theoretical maximum overshoot (Gibbs' Phenomenon) of about 8.9% of the maximum step. The toeroom is smaller, allowing only 16 / 219 = 7.3% overshoot, which is less than the theoretical maximum overshoot of 8.9%. But because values 0 and 255 are reserved in HDMI, it is actually slightly less.

Since the equations defining Y'CbCr are formed in a way that rotates the entire nominal RGB color cube and scales it to fit within a (larger) YCbCr color cube, there are some points within the Y'CbCr color cube that cannot be represented in the corresponding RGB domain (at least not within the nominal RGB range). This causes some difficulty in determining how to correctly interpret and display some Y'CbCr signals. These out-of-range Y'CbCr values are used by xvYCC to encode colors outside the BT.709 gamut.

RGB to YCbCr conversion

### ITU-R BT.601 conversion

The form of Y′CbCr that was defined for standard-definition television use in the ITU-R BT.601 (formerly CCIR 601) standard for use with digital component video is derived from the corresponding RGB space (ITU-R BT.470-6 System M primaries) as follows:

{\displaystyle {\begin{aligned}K_{R}&=0.299\\K_{G}&=0.587\\K_{B}&=0.114\end{aligned}}}

From the above constants and formulas, the following can be derived for ITU-R BT.601.

Analog YPbPr from analog R'G'B' is derived as follows:

{\displaystyle {\begin{aligned}Y'&=&0.299\cdot R'&+&0.587\cdot G'&+&0.114\cdot B'\\P_{B}&=-&0.168736\cdot R'&-&0.331264\cdot G'&+&0.5\cdot B'\\P_{R}&=&0.5\cdot R'&-&0.418688\cdot G'&-&0.081312\cdot B'\end{aligned}}}

Digital Y′CbCr (8 bits per sample) is derived from analog R'G'B' as follows:

{\displaystyle {\begin{aligned}Y'&=&16&+&(65.481\cdot R'&+&128.553\cdot G'&+&24.966\cdot B')\\C_{B}&=&128&+&(-37.797\cdot R'&-&74.203\cdot G'&+&112.0\cdot B')\\C_{R}&=&128&+&(112.0\cdot R'&-&93.786\cdot G'&-&18.214\cdot B')\end{aligned}}}

or simply componentwise

{\displaystyle {\begin{aligned}(Y',C_{B},C_{R})&=&(16,128,128)+(219\cdot Y,224\cdot P_{B},224\cdot P_{R})\\\end{aligned}}}

The resultant signals range from 16 to 235 for Y′ (Cb and Cr range from 16 to 240); the values from 0 to 15 are called footroom, while the values from 236 to 255 are called headroom.

Alternatively, digital Y′CbCr can derived from digital R'dG'dB'd (8 bits per sample, each using the full range with zero representing black and 255 representing white) according to the following equations:

{\displaystyle {\begin{aligned}Y'&=&16&+&{\frac {65.481\cdot R'_{D}}{255}}&+&{\frac {128.553\cdot G'_{D}}{255}}&+&{\frac {24.966\cdot B'_{D}}{255}}\\C_{B}&=&128&-&{\frac {37.797\cdot R'_{D}}{255}}&-&{\frac {74.203\cdot G'_{D}}{255}}&+&{\frac {112.0\cdot B'_{D}}{255}}\\C_{R}&=&128&+&{\frac {112.0\cdot R'_{D}}{255}}&-&{\frac {93.786\cdot G'_{D}}{255}}&-&{\frac {18.214\cdot B'_{D}}{255}}\end{aligned}}}

In the formula below, the scaling factors are multiplied by ${\displaystyle {\frac {256}{255}}}$. This allows for the value 256 in the denominator, which can be calculated by a single bitshift.

{\displaystyle {\begin{aligned}Y'&=&16&+&{\frac {65.738\cdot R'_{D}}{256}}&+&{\frac {129.057\cdot G'_{D}}{256}}&+&{\frac {25.064\cdot B'_{D}}{256}}\\C_{B}&=&128&-&{\frac {37.945\cdot R'_{D}}{256}}&-&{\frac {74.494\cdot G'_{D}}{256}}&+&{\frac {112.439\cdot B'_{D}}{256}}\\C_{R}&=&128&+&{\frac {112.439\cdot R'_{D}}{256}}&-&{\frac {94.154\cdot G'_{D}}{256}}&-&{\frac {18.285\cdot B'_{D}}{256}}\end{aligned}}}

If the R'd G'd B'd digital source includes footroom and headroom, the footroom offset 16 needs to be subtracted first from each signal, and a scale factor of ${\displaystyle {\frac {255}{219}}}$ needs to be included in the equations.

The inverse transform is:

{\displaystyle {\begin{aligned}R'_{D}&=&{\frac {298.082\cdot Y'}{256}}&&&+&{\frac {408.583\cdot C_{R}}{256}}&-&222.921\\G'_{D}&=&{\frac {298.082\cdot Y'}{256}}&-&{\frac {100.291\cdot C_{B}}{256}}&-&{\frac {208.120\cdot C_{R}}{256}}&+&135.576\\B'_{D}&=&{\frac {298.082\cdot Y'}{256}}&+&{\frac {516.412\cdot C_{B}}{256}}&&&-&276.836\end{aligned}}}

The inverse transform without any roundings (using values coming directly from ITU-R BT.601 recommendation) is:

{\displaystyle {\begin{aligned}R'_{D}={\frac {255}{219}}\cdot (Y'-16)&&&&&&&+{\frac {255}{224}}\cdot 1.402\cdot (C_{R}-128)\\G'_{D}={\frac {255}{219}}\cdot (Y'-16)&-&{\frac {255}{224}}\cdot 1.772&&\cdot {\frac {0.114}{0.587}}&&\cdot (C_{B}-128)&-{\frac {255}{224}}\cdot 1.402\cdot {\frac {0.299}{0.587}}\cdot (C_{R}-128)\\B'_{D}={\frac {255}{219}}\cdot (Y'-16)&+&{\frac {255}{224}}\cdot 1.772&&&&\cdot (C_{B}-128)\end{aligned}}}

This form of Y′CbCr is used primarily for older standard-definition television systems, as it uses an RGB model that fits the phosphor emission characteristics of older CRTs.

### ITU-R BT.709 conversion

Rec. 709 compared with Rec. 2020

A different form of Y′CbCr is specified in the ITU-R BT.709 standard, primarily for HDTV use. The newer form is also used in some computer-display oriented applications, as sRGB (though the matrix used for sRGB form of YCbCr, sYCC, is still BT.601). In this case, the values of Kb and Kr differ, but the formulas for using them are the same. For ITU-R BT.709, the constants are:

{\displaystyle {\begin{aligned}K_{B}&=0.0722\\K_{R}&=0.2126\\(K_{G}&=1-K_{B}-K_{R}=0.7152)\end{aligned}}}

This form of Y′CbCr is based on an RGB model that more closely fits the phosphor emission characteristics of newer CRTs and other modern display equipment.[citation needed] The conversion matrices for BT.709 are these:

{\displaystyle {\begin{aligned}{\begin{bmatrix}Y'\\Cb\\Cr\end{bmatrix}}&={\begin{bmatrix}0.2126&0.7152&0.0722\\-0.1146&-0.3854&0.5\\0.5&-0.4542&-0.0458\end{bmatrix}}{\begin{bmatrix}R\\G\\B\end{bmatrix}}\\{\begin{bmatrix}R\\G\\B\end{bmatrix}}&={\begin{bmatrix}1&0&1.5748\\1&-0.1873&-0.4681\\1&1.8556&0\end{bmatrix}}{\begin{bmatrix}Y'\\Cb\\Cr\end{bmatrix}}\end{aligned}}}

The definitions of the R', G', and B' signals also differ between BT.709 and BT.601, and differ within BT.601 depending on the type of TV system in use (625-line as in PAL and SECAM or 525-line as in NTSC), and differ further in other specifications. In different designs there are differences in the definitions of the R, G, and B chromaticity coordinates, the reference white point, the supported gamut range, the exact gamma pre-compensation functions for deriving R', G' and B' from R, G, and B, and in the scaling and offsets to be applied during conversion from R'G'B' to Y′CbCr. So proper conversion of Y′CbCr from one form to the other is not just a matter of inverting one matrix and applying the other. In fact, when Y′CbCr is designed ideally, the values of KB and KR are derived from the precise specification of the RGB color primary signals, so that the luma (Y′) signal corresponds as closely as possible to a gamma-adjusted measurement of luminance (typically based on the CIE 1931 measurements of the response of the human visual system to color stimuli).[3]

### ITU-R BT.2020 conversion

The ITU-R BT.2020 standard defines both BT.709 gamma corrected Y′CbCr and using the same gamma correction (except for Y', that is calculated differently), but with constant luminance Cb, Cr called YcCbcCrc.[4]

For both, the coefficients are:

{\displaystyle {\begin{aligned}K_{B}&=0.0593\\K_{R}&=0.2627\end{aligned}}}

The decoding matrix for BT.2020-NCL is this with 14 decimal places:

{\displaystyle {\begin{aligned}{\begin{bmatrix}R\\G\\B\end{bmatrix}}&={\begin{bmatrix}1&0&1.4746\\1&-0.16455312684366&-0.57135312684366\\1&1.8814&0\end{bmatrix}}{\begin{bmatrix}Y'\\Cb\\Cr\end{bmatrix}}\end{aligned}}}

The smaller values in the matrix are not rounded, they are precise values. For systems with limited precision (8 or 10 bit, for example) a lower precision of the above matrix could be used, for example, retaining only 6 digits after decimal point.[5]

YcCbcCrc may be used when the top priority is the most accurate retention of luminance information.[4] Color representation has true constant luminance (CL) when the luma channel (Y’ of Y′CbCr encoded with BT.709 transfer function or PQ, for example) matches with encoded luminance (BT.709 or PQ encoded luminance Y of XYZ), nevertheless YcCbcCrc does not provide for constant intensity (CI), that is done in ICTCP.[6][7] BT.2020 does not define PQ and thus HDR, it is further defined in SMPTE ST 2084 and BT.2100.

The derivation of BT.2020 coefficients from BT.2020 primaries further changes the space.[8]

### SMPTE 240M conversion

The SMPTE 240M standard defines YCC with these coefficients:

{\displaystyle {\begin{aligned}K_{B}&=0.087\\K_{R}&=0.212\end{aligned}}}

The coefficients are derived from SMPTE 170M primaries and white point, as used in 240M standard.

### JPEG conversion

JFIF usage of JPEG supports a modified Rec. 601 Y′CbCr where Y′, CB and CR have the full 8-bit range of [0...255].[9] Below are the conversion equations expressed to six decimal digits of precision. (For ideal equations, see ITU-T T.871.[10]) Note that for the following formulae, the range of each input (R,G,B) is also the full 8-bit range of [0...255].

{\displaystyle {\begin{aligned}Y'&=&0&+(0.299&\cdot R'_{D})&+(0.587&\cdot G'_{D})&+(0.114&\cdot B'_{D})\\C_{B}&=&128&-(0.168736&\cdot R'_{D})&-(0.331264&\cdot G'_{D})&+(0.5&\cdot B'_{D})\\C_{R}&=&128&+(0.5&\cdot R'_{D})&-(0.418688&\cdot G'_{D})&-(0.081312&\cdot B'_{D})\end{aligned}}}

And back:

{\displaystyle {\begin{aligned}R'_{D}&=&Y'&&&+1.402&\cdot (C_{R}-128)\\G'_{D}&=&Y'&-0.344136&\cdot (C_{B}-128)&-0.714136&\cdot (C_{R}-128)\\B'_{D}&=&Y'&+1.772&\cdot (C_{B}-128)&\end{aligned}}}

### Coefficients for BT.470-6 System B, G primaries

{\displaystyle {\begin{aligned}K_{B}&=0.0713\\K_{R}&=0.2220\end{aligned}}}

These coefficients are not in use and were never in use.[11]

### Chromaticity-derived luminance systems

H.273 also describes constant and non-constant luminance systems which are derived strictly from primaries, so that situations like sRGB/BT.709 default primaries of JPEG that use BT.601 matrix (that is derived from BT.470-6 System M) do not happen.

## References

1. ^ e.g. the MPEG-2 specification, ITU H.262 2000 E pg. 44
2. ^ "MFNominalRange (mfobjects.h) - Win32 apps". docs.microsoft.com. Retrieved 10 November 2020.
3. ^ Charles Poynton, Digital Video and HDTV, Chapter 24, pp. 291–292, Morgan Kaufmann, 2003.
4. ^ a b
5. ^ "ITU-T H Suppl. 18". October 2017. hdl:11.1002/1000/13441.
6. ^ "High dynamic range television for production and international programme exchange". www.itu.int. Retrieved 2021-01-16.
7. ^
8. ^ "H.273: Coding-independent code points for video signal type identification". www.itu.int. p. 10. Retrieved 2021-04-09.
9. ^ JPEG File Interchange Format Version 1.02
10. ^ T.871: Information technology – Digital compression and coding of continuous-tone still images: JPEG File Interchange Format (JFIF). ITU-T. September 11, 2012. Retrieved 2016-07-25.
11. ^ "EBU Tech 3237 Supplement 1" (PDF). p. 18. Retrieved 15 April 2021.