The relationship between YUV and RGB

RGB is a method of representing colors as three primary colors (red, green, and blue), and the intensity of each primary color can be represented in the range of 0 to 255. RGB encoding is most commonly used on output devices such as monitors and televisions.

YUV is a method of decomposing colors into brightness (Y) and chroma (U, V), where brightness represents the lightness and darkness of an image, while chroma represents the saturation and hue of a color.

Although RGB encoding is the most direct way to represent color images, it is not the most efficient encoding method because RGB encoding does not take into account the different perceptions of color and brightness by the human eye. In contrast, YUV encoding takes into account the characteristics of the human eye and decomposes color into two components: brightness (Y) and chroma (U, V). Luminance (Y) represents the lightness and darkness of the image, and chroma (U , V) represents the saturation and hue of the color. Because the human eye is more sensitive to brightness, using YUV encoding in video compression can compress images more efficiently while maintaining visual effects.

Right now:

RGB format is usually used during capture and playback;

During the transmission and compression process, it is usually necessary to convert the RGB format to YUV format to improve transmission efficiency and compression ratio.

The corresponding process is:

Of course, some students may ask, wouldn’t it reduce efficiency by going back and forth throughout the entire process?

Indeed, certain calculations are involved in the process of converting RGB format images or videos to YUV format, which will increase the processing complexity and computational burden. However, on the whole, using YUV format for video encoding and transmission can usually save more data and bandwidth resources during transmission and storage, and the coding efficiency and transmission efficiency are higher. Therefore, in practice, this method is used broadly used.

conversion relationship between

//RGB转YUV
Y=0.299*R+0.587*G+0.114*B
U=-0.147*R-0.289*G+0.436*B=0492*(B-Y)
V=0.615*R-0.515*G-0100*B=.877*(R-Y)

//YUV转RGB
R=Y+1.140*V
G =Y-0.394*U-0.581*V
B=Y +2.032*U

Guess you like

Origin blog.csdn.net/csdn_zmf/article/details/129337160