YCbCr
YCbCr, Y′CbCr, also written as YCBCR or Y′CBCR, is a family of color spaces used as a part of the color image pipeline in digital video and photography systems. Like YPBPR, it is based on RGB primaries; the two are generally equivalent, but YCBCR is intended for digital video, while YPBPR is designed for use in analog systems.
Y′ is the luma component, and CB and CR are the blue-difference and red-difference chroma components. Luma Y′ is distinguished from luminance Y, 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 equations 32, 33 in ITU-T H.273.
Rationale
Black and white television was in wide use before color television. Due to the number of existing TV sets and cameras, some form of backward compatibility was desired for the new color broadcasts. French engineer Georges Valensi developed and patented a system for transmitting RGB color as luma and chroma signals in 1938. This would allow existing black and white televisions to process only the luma information and ignore the chroma, essentially packaging a black and white video within the color video. Because of this backward compatibility, the system based on Valensi's idea was called compatible color. In the same way, a black and white broadcast could be received by a color television without any additional processing circuitry. To preserve existing broadcast frequency allocations, the new chroma information was given lower bandwidth than the luma information. This is possible because humans are more sensitive to the black-and-white information. This is called chroma subsampling.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 that can be stored with high resolution or transmitted at high bandwidth and two chroma components that can be bandwidth-reduced, subsampled, compressed, or otherwise treated separately for improved system efficiency.
Conversions
YCbCr is sometimes abbreviated to YCC.Typically the terms Y′CbCr, YCbCr, YPbPr, and Y′UV are used interchangeably, leading to some confusion. The main difference is that YPbPr is used with analog images and YCbCr with digital images, leading to different scaling values for Umax and Vmax when converting to/from YUV. Y′CbCr and YCbCr differ due to the values being gamma corrected or not.
The equations below give a better picture of the common principles and general differences between these formats.
RGB conversion
R'G'B' to Y′PbPr
Y′CbCr signals are called YPbPr and are created from the corresponding gamma-adjusted RGB source using three defined constants KR, KG, and KB as follows:where KR, KG, and KB are ordinarily derived from the definition of the corresponding RGB space and required to satisfy.
The equivalent matrix manipulation is often referred to as the "color matrix":
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 and 1 the maximum. The resulting luma value will then have a nominal range from 0 to 1, and the chroma values will have a nominal range from -0.5 to +0.5.
The reverse conversion process can be derived by inverting the above equations.
Y′PbPr to Y′CbCr
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 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 / = 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" can also be used for extension of the nominal color gamut as specified by xvYCC.
The value 235 accommodates a maximum overshoot of / = 9.1%, which is slightly larger than the theoretical maximum overshoot of about 8.9% of the maximum step. The toeroom is smaller, allowing only 16 / 219 = 7.3% overshoot—here in opposite direction—, which is less than the theoretical maximum overshoot of 8.9%. In addition, because values 0 and 255 are reserved in HDMI, the room is actually slightly less.
Y′CbCr to xvYCC
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 YCbCr color cube, there are some points within the Y′CbCr color cube that cannot be represented in the corresponding RGB domain. 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.ITU-R BT.601 conversion
The form of Y′CbCr that was defined for standard-definition television use in the ITU-R BT.601 standard for use with digital component video is derived from the corresponding RGB space as follows: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:
Digital Y′CbCr is derived from analog R'G'B' as follows:
or simply componentwise
The resultant signals have Y′ values ranging from 16 to 235, and Cb & Cr values ranging from 16 to 240. The values from 0 to 15 are called footroom, and the values from 236 to 255 are called headroom. The same quantisation ranges, different for Y and Cb, Cr also apply to BT.2020 and BT.709.
Alternatively, digital Y′CbCr can be derived from digital R'dG'dB'd according to the following equations:
In the formula below, the scaling factors are multiplied by. This allows for the value 256 in the denominator, which can be calculated by a single bitshift.
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 needs to be included in the equations.
The inverse transform is:
The inverse transform without any roundings is:
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
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. 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: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.
The conversion matrices for BT.709 are these:
The definitions of the R', G', and B' signals also differ between BT.709 and BT.601, differ within BT.601 depending on the type of TV system in use, 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 signal corresponds as closely as possible to a gamma-adjusted measurement of luminance.
ITU-R BT.2020 conversion
The ITU-R BT.2020 standard uses the same gamma function as BT.709. It defines:- Non-constant luminance Y'CbCr, similar to the previous entries, except with different and.
- Constant luminance Y'cCbcCrc, a formulation where Y' is the gamma-codec version of the true luminance.
For NCL, the definition is classical: ; ;. The encoding conversion can, as usual, be written as a matrix. The decoding matrix for BT.2020-NCL is this with 14 decimal places:
The smaller values in the matrix are not rounded; they are precise values. For systems with limited precision a lower precision of the above matrix could be used, for example, retaining only 6 digits after the decimal point.
The CL version, YcCbcCrc, codes:
- . This is the gamma function applied to the true luminance calculated from linear RGB.
- if otherwise. and are the theoretical minimum and maximum of corresponding to the gamut. The rounded "practical" values are,. The full derivation can be found in the recommendation.
- if otherwise. Again, and are theoretical limits. The rounded values are,.
BT.2020 does not define PQ and thus HDR; it is further defined in SMPTE ST 2084 and BT.2100. BT.2100 will introduce the use of ICTCP, a semi-perceptual colorspace derived from linear RGB with good hue linearity. It is "near-constant luminance".