Color space conversion (4) YCbCr/YPbPr color space
YCbCr/YPbPr
YCbCr is a color space used for JPEG images, TV and videos.
In this color space, Y represents the luminance component and Cb and Cr represent the blue-difference chroma and red-difference chroma components.
YPbPr is similar system to YCbCr. The differences are:
- YPbPr is used for analog component video, and YCbCr is used mainly for digital component video. (outside Japan)
- YCbCr is used for SDTV video, and YPbPr is used for HDTV video. (in Japan)
These two definitions conflict with each other and confusing.
Here we will follow the definition 1.
YCbCr / YPbPr system is similar to the Lab color space because color is represented by luminosity and color-differences.
However, the Y value of XYZ is defined by linear RGB (without gamma correction), while the luminance of YCbCr / YPbPr is defined by gamma-corrected R'G'B'.
In order to avoid the confusion, here we will use Y'
for the luminance component of YCbCr / YPbPr.
The luminance Y' is defined by the following equation:
Y' = Kr
R'
+ Kg G' + Kb B' |
(1)
|
Here R', G', B'
are the gamma-corrected RGB values,
Kr + Kg
+ Kb = 1 is assumed, and
Y' varies from 0 to 1.
The blue-difference chroma and red-difference chroma are defined by the following equations:
Pb
=
[(1/2)/(1 − Kb)] (B' − Y' ) |
(2)
|
Pr
=
[(1/2)/(1 − Kr)] (R' − Y' ) |
(3)
|
The coefficients of (B' − Y' ) and
(R' − Y' ) are defined so that the values of
Pb and
Pr varies between
−0.5 and 0.5, respectively.
These equations are also written as:
Pb
=
(1/2) [ B'
− (Kr R' + Kg G')/(Kr
+ Kg)] |
(2')
|
Pr
= (1/2) [ R'
− (Kg G' + Kb B')/(Kg
+ Kb)]
|
(3')
|
From equation (2'), we see that Pb = 0.5 for blue, and
Pb = −0.5 for yellow.
In a similar way, from equation (3'), we see that
Pr = 0.5 for red, and
Pr = −0.5 for cyan.
The reason why the RGB values are converted to luminance and color differences is to prevent image degradation with a limited amount of image data size.
The color difference plays a smaller role in human vision than the luminance, and even if the resolution of the color difference channel is lowered, the image quality does not seem to be degraded much (see Fig. 1).
Because of this property, giving priority to the luminance data is effective in suppressing the degradation of image quality.
|
|
|
|
|
Original image |
Luminance Y |
Blue-difference Pb |
Red-difference Pr |
Image with low color difference resolution
|
Fig. 1.
Components of an image and a composed image with low color difference resolution
|
Since conversion given by (1)-(3) is a linear transformation, the calculation is easy for the machine.
For reference, the inverse conversion from YPbPr to R'G'B' can be written as follows:
R' = Y'
+ 2(1 − Kr) Pr
G' = Y'
− [2Kb(1 − Kb)/Kg] Pb
− [2Kr(1 − Kr)/Kg] Pr
B' = Y' + 2(1 − Kb) Pb
BT.601
In the specification BT.601 for SDTV (standard television), the coefficients for the illuminance are:
Kr
= 0.299, Kb
= 0.114
These values are taken from the RGB to XYZ color space conversion in the NTSC specification:
 Y = 0.299 R + 0.587 G + 0.114 B.
(BT.601 uses the NTSC color gamut.)
Actual conversion from R'G'B' to Y'PbPr is written as follows.
Figure 2 shows the YPbPr color space.
Figure 3 is the projection on the PbPr plane.
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'
Digitization to an 8-bit signal is performed as follows.
We see that all of 0 to 255 digits are not used (the rest are reserved for other purposes).
Digital video signals are transmitted and recorded with these values.
Y'digital
= 16
+ 219 Y' (16 ≤ Y'digital
≤ 235)
Cb = 128 + 224 Pb
(16 ≤ Cb ≤
240)
Cr = 128 + 224 Pr
(16 ≤ Cr ≤
240)
|
|
Fig. 2. YPbPr color space (SDTV)
|
Fig. 3. Projection on the PbPr plane
|
BT.709
In the specification BT.709 for HDTV (High Definition Television), the coefficients for the illuminance are:
Kr
= 0.2126, Kb
= 0.0722
These values are taken from the sRGB to XYZ color space conversion:
 Y = 0.2126 R + 0.7152 G + 0.0722 B.
(BT.709 uses sRGB color gamut.)
Actual conversion from R'G'B' to Y'PbPr is written as follows.
Figure 4 shows the YPbPr color space.
Figure 5 is the projection on the PbPr plane.
Y' =
0.2126 R'
+ 0.7152 G'
+ 0.0722 B'
Pb = − 0.114572 R' −
0.385428 G' + 0.5 B'
Pr = 0.5 R' − 0.454153 G'
− 0.045847 B'
Digitization to an 8-bit signal is performed as follows:
Y'digital
= 16
+ 219 Y' (16 ≤ Y'digital
≤ 235)
Cb = 128 + 224 Pb
(16 ≤ Cb ≤
240)
Cr = 128 + 224 Pr
(16 ≤ Cr ≤
240)
|
|
Fig. 4. YPbPr color space (HDTV)
|
Fig. 5. Projection on the PbPr plane
|
JPEG compression
YCbCr (BT.601) is also used for JPEG compression of RGB mode images. If R', G', and B' are already digitized and the values are in the range of 0-255, the conversion can be written as follows:
Y' =
0.299 R'
+ 0.587 G'
+ 0.114 B'
Cb = − 0.168736 R' −
0.331264 G' + 0.5 B'
Cr = 0.5 R' − 0.418688 G'
− 0.081312 B'
Unlike YCbCr for TV and videos, the values of
Y', Cb, Cr for JPEG are in the full range of 0-255.
JPEG compression is based on these YCbCr values.
Conversely, if a JPEG file is decompressed and inverse conversion is performed, an image with gamma-corrected RGB values will be reproduced.
Back to contents
Previous
T. Fujiwara, 2012/01