Video Code Convertor – RGB to YUV Pixel Conversation
Let me first give introduction about RGB and YUV.
RGB and YUV are two different way of storing video.
RGB (Red, Green and Blue)
The RGB color model is an additive model in which red, green and blue
are combined in various ways to reproduce other colors.The name of the
model and the abbreviation “RGB” come from the three primary colors,
Red, Green and Blue.
YUV (Brightness and color)
The color encoding system used for analog television worldwide
(NTSC, PAL and SECAM). The YUV color space (color model) differs
from RGB, which is what the camera captures and what humans view.
YUV also saves transmission bandwidth compared to RGB. For rendering on
screen, all these color spaces must be converted back again to RGB
by the TV or display system
The YUV model defines a color space in terms of one luminance and
two chrominance components.YUV is used in the analog variant of the
PAL system of television broadcasting, which is the standard in
much of the world.Y stands for the luminance component (the brightness)
and U and V are the chrominance (color) components
The Mathmatically conversion formula:
RGB to YUV Conversion
Y = (0.257 * R) + (0.504 * G) + (0.098 * B) + 16
V = (0.439 * R) – (0.368 * G) – (0.071 * B) + 128
U = -(0.148 * R) – (0.291 * G) + (0.439 * B) + 128
YUV to RGB Conversion
B = 1.164(Y – 16) + 2.018(U – 128)
G = 1.164(Y – 16) – 0.813(V – 128) – 0.391(U – 128)
R = 1.164(Y – 16) + 1.596(V – 128)