YCbCr
lastmod 2018-08-17created 2014-09-012 edits
YCbCr is a type of color space used in video systems. Y is the luma component, and Cb and Cr are the chroma components. YCbCr is sometimes abbreviated to YCC. YCbCr is not an absolute color space but a way of encoding RGB information; the actual color of the displayed image depends on the original RGB information used to display the signal. Therefore, values expressed in YCbCr are predictable only if standard RGB colors are used, or if an ICC profile to be used for color conversion is attached.
Conversion formulas
The YCbCr signal (before the scaling and offset adjustment steps that convert it to a digital format) is called YPbPr, and it can be obtained from a gamma-corrected RGB source using two constants, Kb and Kr, with the following formulas:
YPbPr (analog version of YCbCr) from R'G'B'
====================================================
Y' = Kr * R' + (1 - Kr - Kb) * G' + Kb * B'
Pb = 0.5 * (B' - Y') / (1 - Kb)
Pr = 0.5 * (R' - Y') / (1 - Kr)
....................................................
R', G', B' in [0; 1]
Y' in [0; 1]
Pb in [-0.5; 0.5]
Pr in [-0.5; 0.5]
Kb and Kr are usually derived from the definition of the corresponding RGB space. Above, the prime (') symbol means gamma correction has been applied; that is, R', G', B' take values between 0 and 1, where 0 is the minimum (i.e. black in an image) and 1 is the maximum (white in an image). The resulting luma value (Y) ranges from 0 to 1, and the chroma values (Cb and Cr) range from -0.5 to +0.5. The inverse conversion can be derived directly from the formulas above.
When the signal is represented in digital form, the results are scaled and rounded, and an offset is usually added. For example, with scaling and offset applied, the Y' component in an 8-bit format is 16 for black and 235 for white.
The YCbCr format used for digital standard-definition television is defined in the ITU-R BT.601 (formerly CCIR 601) standard, which converts from RGB space to the digital component video format using the following coefficients:
With the constants and formulas above, ITU-R BT.601 can be written as follows. First, analog YPbPr:
YPbPr (ITU-R BT.601)
========================================================
Y' = + 0.299 * R' + 0.587 * G' + 0.114 * B'
Pb = - 0.168736 * R' - 0.331264 * G' + 0.5 * B'
Pr = + 0.5 * R' - 0.418688 * G' - 0.081312 * B'
........................................................
R', G', B' in [0; 1]
Y' in [0; 1]
Pb in [-0.5; 0.5]
Pr in [-0.5; 0.5]
Then digitize to YCbCr:
YCbCr (601) from R'G'B'
========================================================
Y' = 16 + 65.481 * R' + 128.553 * G' + 24.966 * B'
Cb = 128 - 37.797 * R' - 74.203 * G' + 112.0 * B'
Cr = 128 + 112.0 * R' - 93.786 * G' - 18.214 * B'
........................................................
R', G', B' in [0; 1]
Y' in {16, 17, ..., 235}
with footroom in {1, 2, ..., 15}
headroom in {236, 237, ..., 254}
sync. in {0, 255}
Cb, Cr in {16, 17, ..., 240}
If R', G', B' are given as 8-bit digital values:
YCbCr (601) from "digital 8-bit R'G'B' "
========================================================================
Y' = 16 + 1/256 * ( 65.738 * R'd + 129.057 * G'd + 25.064 * B'd)
Cb = 128 + 1/256 * ( - 37.945 * R'd - 74.494 * G'd + 112.439 * B'd)
Cr = 128 + 1/256 * ( 112.439 * R'd - 94.154 * G'd - 18.285 * B'd)
........................................................................
R'd, G'd, B'd in {0, 1, 2, ..., 255}
Y' in {16, 17, ..., 235}
with footroom in {1, 2, ..., 15}
headroom in {236, 237, ..., 254}
sync. in {0, 255}
Cb, Cr in {16, 17, ..., 240}
This YCbCr format was used mainly for older digital standard-definition television systems, and uses an RGB model that matches the phosphor emission characteristics of older CRTs.
Another form of YCbCr is defined in the ITU-R BT.709 standard and is used mainly for digital high-definition television. The new form is also used in some computer display applications. In this case the values of Kb and Kr differ, but the formulas are the same. The constants defined in ITU-R BT.709 are:
This form of YCbCr is based on an RGB model that better matches the phosphor emission characteristics of newer CRTs and other modern display devices such as LCDs and PDPs. Note that the values of the R', G', B' signals defined in BT.601 and BT.709 differ.