跳至主要内容

RGB and YCbCr Color Space

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

评论

此博客中的热门博文

反转剧

这两天明显感到天气转冷,呱呱的家里也已经下起了大雪,南京则是阴冷潮湿,让人没有了出行的欲望。没想到躲在被子里看反转剧也成了度过寒冬的一剂良药。在PPLive越来越让人失望的时候,PPStream横空出世,虽然广告仍是少不了的主题,但从视频质量和播放连续性上来说都超过PPLive,实为居家必备之良品(由此可见,新事物一定会战胜旧事物......)。韩国的反转剧最近似乎比较流行,称之为反转剧就在于其结果总是让人出乎意料,不合常理,其间又不乏各种搞怪搞笑的镜头,各种当红帅哥美女也一定让DDMM们爱不释手,20~30分钟一集的剧情一改韩剧拖沓的风貌,想看就看,容易切入。 反转剧,今天你看了吗?

from cpp to java

when i start to study java with a cpp background, i find it is very difficult to convert my mind. i always think how some features in cpp was implemented in java, this give me a little reject to java language. though java is born from c, i think they still have different applicable domains, so try to study both is good for me, and java is a pure OO language, i believe it will give me a better understanding on OOD.

低谷

近段时间,小猪的身体不好,连续好几个周末游走于各个医院,两人的心情也坏到了极点。现在的小猪已俨然成为一个药罐子,不再提当年之勇。这个周末又发起烧来,像一滩烂泥似地躺在床上,真是祸不单行。 而我呢,由于前任离职的缘故,现在出奇地忙,每天就像打仗似地,压得人喘不过气来,工作与家庭,真有些夹缝中求生存的感觉,两头都要兼顾,我想这一次我们是真的走到一个低谷了吧。 希望这一切都会过去,一切都能圆满地解决。