Jump to content

YCbCr: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
→‎Technical details: inverted the matrix, well I expected to find it here so I guess other people would too
Line 83: Line 83:
Cb, Cr in {16, 17, ..., 240}
Cb, Cr in {16, 17, ..., 240}


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 [[Cathode ray tube|CRT]]s.
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 [[Cathode ray tube|CRT]]s. The inverse transform equivalent to the above is:

8-bit R'G'B' from YCbCr (601)
=====================================================================
R'd = ( 298.082 * Y' + 408.583 * Cr ) / 256 - 222.921
G'd = ( 298.082 * Y' - 100.291 * Cb - 208.120 * Cr ) / 256 + 135.576
B'd = ( 298.082 * Y' + 516.412 * Cb ) / 256 - 276.836
.....................................................................



A different form of Y'CbCr is specified in the ITU-R BT.709 standard, primarily for [[High-definition television|HDTV]] use. The newer form is also used in some computer-display oriented applications. 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:
A different form of Y'CbCr is specified in the ITU-R BT.709 standard, primarily for [[High-definition television|HDTV]] use. The newer form is also used in some computer-display oriented applications. 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:

Revision as of 23:38, 15 December 2007

A color image and the Y, Cb and Cr elements of it. Note that the Y image is essentially a greyscale copy of the main image; that the white snow is represented as a middle value in both Cr and Cb; that the brown barn is represented by weak Cb and strong Cr; that the green grass is represented by weak Cb and weak Cr; and that the blue sky is represented by strong Cb and weak Cr.

YCbCr or Y'CbCr is a family of color spaces used in video and digital photography systems. Y' is the luma component and Cb and Cr are the blue and red chroma components. The prime on the Y is to distinguish the luma from luminance. Y'CbCr is often confused with the YUV color space, and typically the terms YCbCr and YUV are used interchangeably, leading to some confusion; when referring to signals in video or digital form, the term "YUV" probably really means "Y'CbCr" more often than not. YCbCr is sometimes abbreviated to YCC. When used for analog component video, Y'CbCr is often called YPbPr, although the term Y'CbCr is commonly used for both systems, with or without the prime.

Y'CbCr is not an absolute color space. It is a way of encoding RGB information, and the actual color displayed depends on the actual RGB colorants used to display the signal. Therefore a value expressed as Y'CbCr is only predictable if standard RGB colorants are used, or if an ICC profile is attached or implied which is used to translate value for the colorants in use.

Rationale

Video CRT displays are driven by red, green, and blue voltage signals, but these RGB color space signals are not efficient as a representation for storage and transmission, since they have a lot of mutual redundancy. Spaces such as Y'CbCr are 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.

Technical details

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 two defined constants Kb and Kr as follows:

YPbPr (analog version of Y'CbCr) 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]








where Kb and Kr are ordinarily derived from the definition of the corresponding RGB space.

Here, the prime (') symbols mean gamma correction is being used; thus R', G' and B' and to 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 (Cb and Cr) 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 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. This arbitrary "footprint" forces rescaling by the fraction (235-16)/(240-16) = 219/224 when doing color matrixing or processing in YCbCr space. This results in unnecessary quantization distortions which a choice of identical ranges would have rationalized.

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. The term "head-room" and "toe-room" has also been proposed to be used for extension of the nominal color gamut.

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 as follows:

Kb = 0.114
Kr = 0.299

From the above constants and formulas, the following can be derived for ITU-R BT.601:
Firstly 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 this is digitized for Y'CbCr:

Y'CbCr (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' and B' are given with 8-bit digital precision, then

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 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. The inverse transform equivalent to the above is:

8-bit R'G'B' from YCbCr (601)
=====================================================================
R'd = ( 298.082 * Y'                + 408.583 * Cr ) / 256 - 222.921
G'd = ( 298.082 * Y' - 100.291 * Cb - 208.120 * Cr ) / 256 + 135.576
B'd = ( 298.082 * Y' + 516.412 * Cb                ) / 256 - 276.836
.....................................................................


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. 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:

Kb = 0.0722
Kr = 0.2126

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.

Note that the definitions of the R', G', and B' color primary signals also differ between BT.601 and BT.709. So proper conversion of YCbCr from one form to the other is not just a matter of inverting one matrix and applying the other. In fact, when YCbCr is used correctly, 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).

Although the above two forms of Y'CbCr are the dominant ones, some other variants exist. For example, the SMPTE 240M standard specifies YCbCr using Kb = 0.087 and Kr = 0.212.

Since the equations defining YCbCr 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 YCbCr 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 YCbCr signals.

JPEG allows Y'CbCr where Y', Cb and Cr have the full 256 values[1]:

JPEG-Y'CbCr (601) from "digital 8-bit R'G'B'  "
========================================================================
Y' =       + 0.299    * R'd + 0.587    * G'd + 0.114    * B'd
Cb = 128   - 0.168736 * R'd - 0.331264 * G'd + 0.5      * B'd
Cr = 128   + 0.5      * R'd - 0.418688 * G'd - 0.081312 * B'd
........................................................................
R'd, G'd, B'd   in {0, 1, 2, ..., 255}
Y', Cb, Cr      in {0, 1, 2, ..., 255}

References