In this topic the conversions from the RGB color space to the YUV/YCbCr (and similar) color spaces, and reverse, are derived. That is, we seek a conversion from [R, G, B] to [Y, X1,X2], and one from [Y, X1,X2] to [R, G, B].
In Sect. 3.3.3 it was stated that the luminance, Y, contains intensity information while X1 and X2 code the color information as weighted difference signals with respect to Y. That is:
The Output of a Colorless Signal
When a colorless signal is present, i.e., R = G = B ,we have
The Range of Xi and X2
The minimum value for X1 will be when (R,G, B) = (255, 255,0). We will then have
since Wr + Wg + Wb = 1. The maximum value for X1 will be when (R,G, B) = (0, 0, 255). We will then have
So the range for X1 is [—Wx1 · 255,WX1 · 255]. Note that a similar argument exists for X2.
YUV
The actual conversion from RGB to YUV is found by inserting the following weight factors into Eqs. F.1, F.2, and F.3: Wr = 0.299, Wg = 0.587, Wb = 0.114, Wx1 = 0.436, and Wx2 = 0.615. To simplify matter Eqs. F.2 and F.3 are first rewritten as
Inserting we get the following conversion from RGB to YUV:
The conversion from YUV to RGB is found by rearranging Eqs. F.1, F.2, and F.3 and inserting the weight factors as above. The equations for R and B follow trivially by rearranging Eqs. F.2 and F.3, respectively:
The equation for G is derived by inserting Eqs. F.11 and F.12 into F.1 and rearranging:
Inserting the weights for YUV yields the following conversion from YUV to RGB:
YC b Cr
The conversion from RGB to YCbCr is found by inserting the following weights into Eqs. F.1, F.8, and F.9: Wr = 0.299, Wg = 0.587, Wb = 0.114, Wx1 = 0.5, and Wx2 = 0.5
The conversion from YCbCr to RGB is found by inserting the same weights into Eqs. F.11,F.12, andF.13:
Note that 128 is added/subtracted in order to bring the values into the range [0, 255].