April 25, 2024

Color mode RGB & YUV format analysis

We look at the world like this

Color mode RGB & YUV format analysis

People know that it takes three steps to put an elephant in the refrigerator, and the human eye can put the world into the brain in three steps: the eye sensor senses the image (the sensor collects and converts it into a digital signal) - it turns into a nerve signal. Go to the brain (pass the signal to the processor through the communication system) - the brain processes and stores (the processor is converted into a screen that can be displayed and stored in a format).

Therefore, the image format that the human eye begins to see is transformed from an optical signal into an electrical signal and a chemical signal in the nerve, and the propagation format is different!

The machine is also to be converted.

1.1 The format in the brain - RGB image format

First of all, the screen is composed of pixels, and the brilliant colors are only from the three primary colors of red, green and blue. The representation of this color is called RGB color. Spatial representation (it is also one of the most used color space representations in multimedia computer technology), as shown in the following figure:

Color mode RGB & YUV format analysis

figure 1

According to the principle of three primary colors, any color light F can be added and mixed with different components of R, G, and B colors. As shown in Equation 1.1.

Equation 1.1 The principle of three primary colors

White light is a mixture of multiple lights, so when the three primary color coefficient is the largest, it is white, and when it is zero, it is black, and between the two is the world's Bose.

Each pixel is like a paint box. The larger the box, the more colors it has. The more colors the pixel can express, the size of the box is called the storage space in the computer. The way of coloring is To change the content of the three primary colors, the lower the table below, the larger the storage space required, but the more accurate the color that each pixel can describe, the more realistic the screen will be.

The common format of RGB is shown in Table 1.1. You don't need to look at it in detail.

Color mode RGB & YUV format analysis

Table 1.1 RGB common format

Color mode RGB & YUV format analysis

1.2 Format on the eyeball - YUV image format

Compared with RGB video signal transmission, the biggest advantage of YUV is that it only needs to occupy very little bandwidth (RGB requires three independent video signals to transmit at the same time). The difference in bandwidth between the two formats is as follows: RGB occupied The bandwidth is much larger.

Color mode RGB & YUV format analysis

figure 2

So when we store it, we need to use the brightness signal Y and two color difference signals R-Y (red-brightness, ie U), B-Y (blue-brightness) in order to save space (stolen work?) That is, V) is separately encoded, and then sent out to the display terminal and then converted back to the RGB format. This color representation is the so-called YUV color space representation. At this time, you may ask "Hey, G (green) where to go", in fact, the two colors plus brightness can also express the original color through the algorithm (surely cut corners), so even if it is integrated into R and B.

Is it just to save bandwidth, so we have chosen the YUV format without hesitation?

of course not! Ok, although low bandwidth is also important.

The use of YUV color space is more important because its luminance signal Y and chrominance signals U, V are separated, so the advantage of separation is not only to avoid mutual interference, but also to reduce the sampling rate of chrominance without affecting image quality too. Big. If U and V are zero, there is no color and it becomes a black and white TV. Of course, Y is also an important parameter. In fact, we usually see a color shade is very different, and the depth depends on the brightness Y, the effect of Y is shown below.

Color mode RGB & YUV format analysis

image 3

The following only introduces a YUV format, and everyone touches the class.

1) YUV 4:2:2

4 means that there are 4 Ys in the stored stream code, 2 means that there are 2 U color difference values ​​in the stored stream code, and the second 2 means there are 2 V color difference values ​​in the stored stream code.

The following four pixels are: [Y0 U0 V0] [Y1 U1 V1] [Y2 U2 V2] [Y3 U3 V3]

The stored code stream is: Y0 U0 Y1 V1 Y2 U2 Y3 V3

The mapped pixels are: [Y0 U0 V1] [Y1 U0 V1] [Y2 U2 V3] [Y3 U2 V3]

Color mode RGB & YUV format analysis

Figure 4

The picture above shows the sampling network of YUV4:2:2. The light sample (Y) is represented by a cross, and the color sample (U, V) is represented by a circle. Each point has a fork, and the circle is only half, so this is why the above stored stream code four Y is complete, and U, V is only half.

1.3 RGB/YUV format conversion

It can be seen that the two weapons have their own strengths, YUV is longer than processing and transmission, RGB is longer than expression, what do you do? Attached to both forged cheats!

The conversion relationship between YUV (YCrCb) and RGB can be described by Equation 1.2.

Color mode RGB & YUV format analysis

Equation 1.2 YUV and RGB conversion relationship

Convert to Equation 1.3.

Color mode RGB & YUV format analysis

Equation 1.3 YUV and RGB simplified conversion

The RGB values ​​range from 0 to 255.

Battery Pack Series

Portable Battery Pack,Wireless Battery Pack,Rechargeable Battery Pack,Nintendo Switch Battery Pack

Zhejiang Xinghai Energy Technology Co.,Ltd , https://www.headwayli-battery.com