In brief, color space is a model representing color information, and there are many color spaces. RGB color space is more familiar to us. These are the three additive primary colors of light, any color may be reproduced by combining varying proportions of red, green and blue light. Because the three components have roughly equal importance to the final color, RGB system usually represents each component with the same precision (same number of bits).
However, RGB is not necessarily the most efficient representation of color. The human visual system is less sensitive to color than to luminance (brightness), but RGB color space does not provide an easy way to take advantage of this since each component is equally important, and the luminance is present in all three color components. It is possible to represent a color image more efficiently by separating the luminance from the color information.
Here comes the YCbCr color space. Y represents luminance component (i.e. brightness), and is a weighted average of R, G, and B.
Y = kr*R + kg*G + kb*B (Note that: kr + kg + kb = 1)
Cb = B – Y
Cr = R – Y
Cb and Cr are chrominance components which represent the variation between the color intensity and the background luminance of the image. In the equation, kr, kg and kb are coefficients pre-defined, and their values are related to the experiment result of our visual system. I have seen two versions about this set of coefficients, though they are slightly different, they still have similar scales, which can only lead to slightly different visual results that may not be perceived.
We can use equation above to convert RGB to YCbCr, on the contrary, we can also convert it back to RGB. The player we will build need this conversion.
ITU-R recommendation BT.601 defines kb = 0.114 and kr = 0.299. Substituting into equations above gives the following widely-used conversion equations:
(RGB->YCbCr)
Y = 0.299R + 0.587G + 0.114B
Cb = 0.564(B-Y)
Cr = 0.713(R-Y)
(YCbCr->RGB)
R = Y + 1.402*Cr
G = Y – 0.344*Cb – 0.714*Cr
B = Y + 1.772*Cb
part of materials in this section are referrenced from the book "H.264 and MPEG-4 video compression" by Iain E.G. Richardson
评论