- WR = 0.299, WG = 0.587, WB = 0.114 are the weights for R, G, B respectively
- Umax = 0.436, Vmax = 0.615
- Y = WR * R + WG * G + WB * B
- U = Umax * (B – Y) / (1 – WB)
- V = Vmax * (R – Y) / (1 – WR)
The RGB values can be computed from the YUV values as follows:
- R = Y + V * (1 – WR) / Vmax
- G = Y – U * WB * (1 – WB) / Umax * WG – V * WR (1 – WR) / Vmax * WG
- B = Y + U * (1 – WB) / Umax
These transformations can be represented as matrix operations as follows:
The values of KB and KR above are determined based on the RGB color space used (this is dependent on the TV circuitry rendering the colors). Note that RGB values are in the range [0, 1], and Y is in the range [0, 1], PBPR are in the range [-0.5, 0.5]. For example, Standard Definition (SD) TV uses KB = 0.114 and KR = 0.299 (ITU-R BT.601 Standard), while High Definition (HD) TV uses KB = 0.0722 and KR = 0.2126 (ITU-R BT.709 Standard).
YCbCr is obtained from YPbPr as follows (Y is in the range [16, 235], CbCr are in the range [16, 240]):
So, why are the values scaled and offsets added to obtain YCbCr? Typically, the YCbCr encoding is used in DVDs, and needs to be converted into an analog signal to be fed into a TV. However, this signal processing can excurse beyond the levels acceptable to a TV, and will result in clipping artefacts. On computers where analog signal processing is not an issue, YCbCr uses the full [0-255] range, for example, in the JPEG/JFIF standard.
— Video Demystified by Keith Jack (Pg 20)
— MSDN YUV Video
— Clamping in YCbCr
— http://forum.videohelp.com/threads/101128-DVD2AVI-YUV-RGB-Question
— http://www.poynton.com/ColorFAQ.html
— http://forums.creativecow.net/thread/55/857353
— http://en.wikipedia.org/wiki/YPbPr