Conversion Between RGB and YUV/YCbCr (Introduction to Video and Image Processing)

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:

tmp7470-355

The Output of a Colorless Signal

When a colorless signal is present, i.e., R = G = B ,we have

tmp7470-356

The Range of Xi and X2

The minimum value for X1 will be when (R,G, B) = (255, 255,0). We will then have

tmp7470-357


since Wr + Wg + Wb = 1. The maximum value for X1 will be when (R,G, B) = (0, 0, 255). We will then have

tmp7470-358

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

tmp7470-359tmp7470-360

Inserting we get the following conversion from RGB to YUV:

tmp7470-361

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:

tmp7470-362

The equation for G is derived by inserting Eqs. F.11 and F.12 into F.1 and rearranging:

tmp7470-363

Inserting the weights for YUV yields the following conversion from YUV to RGB:

tmp7470-364

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

tmp7470-365

The conversion from YCbCr to RGB is found by inserting the same weights into Eqs. F.11,F.12, andF.13:

tmp7470-366

Note that 128 is added/subtracted in order to bring the values into the range [0, 255].

Next post:

Previous post: