I. Introduction
YUV (also known as ycrcb) is a color encoding method used by European television systems (PAL ). YUV is mainly used to optimize the transmission of color video signals, so that it is backward compatible with vintage black and white TVs. Compared with RGB video signal transmission, RGB requires three independent video signals to be transmitted at the same time ).
"Y" indicates the brightness (Lumina nce or Luma), that is, the grayscale value. It is a baseband signal. "U" and "V" represent chrominance or chroma, which describes the image color and saturation and is used to specify the pixel color. U and V are not baseband signals, and they are orthogonal modulated.
The "brightness" is created by an RGB input signal by overlapping specific parts of the RGB signal. "Color" defines two aspects of color-tone and saturation, expressed by Cr and CB respectively. Cr reflects the difference between the red part of the RGB input signal and the brightness value of the RGB signal. CB reflects the differences between the blue part of the RGB input signal and the brightness value of the RGB signal. After calculation, the three-part YUV can restore R (red), g (green), and B (blue ).
Ii. Concept
1) RGB Color Space
To accurately represent a colorBrightness,Color ToneAndColor saturationThree basic parameters.
Color visionIs the overall perception of these three parameters. Brightness is the brightness of the human eye.
Color ToneIs a color type. That is, red, green, and blue usually refer to the colors.
Color and degreeIt refers to the depth of the color displayed by the color light.
For color light of the same color, the thicker the color, the higher the color saturation. According to the description of the color theory, the color perception varies depending on the wavelength, but the same color perception can come from different spectral composition combinations. Almost all colors in nature can be mixed with three basic colors. In color TV technology, red, green, and blue are used as the three base colors. Other colors can be mixed with red, green, and blue in different proportions. The selected red, green, and blue space. It is short for RGB color space.
2) in a color broadcast TV, it does not directly transmit RGB signals. Instead, the three base colors are converted into three basic parameters that can represent the three base colors. That is, a Brightness Signal y and two chromatic aberration signals CB and Cr. The conversion relationship between the new Brightness Signal and the color difference signal and the three-color signal is as follows:
Y = 0.30 R + 0.59G + 0.11b
(R−y) = 0.70 r−0.59 g −0.11b
(B −y) = −0.30 r−0.59 G + 0.89 B
During transmission, the color difference signal after balanced orthogonal modulation is superimposed with the Brightness Signal to form a compliant signal.
Y + C sin (ω SC t + θ) is used as the color TV image signal. The color difference signals after orthogonal equilibrium modulation are as follows:
U c (t) = (B −y) sin ω SC t + (r −y) Cos ω SC t = C sin (ω SC T + θ)
Because the dynamic range of the color image is relatively large, the high level is (Y + C) the lowest level is (Y-C), so we need to compress the chromatic aberration signal, the formula is as follows:
U = 0.493 (B −y)
V = 0.877 (r −y)
The compressed color difference signal is the same as the Brightness Signal in the front to form a new color space, referred to as the YUV space.
Iii. Differences in conversion formulas between YUV and YCbCr and RGB
YUV <--> RGB
Y ''= 0.299 * r'' + 0.587 * g'' + 0.114 * B''
U'' =-0.147 * r''-0.289 * g'' + 0.436 * B '= 0.492 * (B'-y '')
V'' = 0.615 * r''-0.515 * g''-0.100 * B '= 0.877 * (r''-y '')
R'' = y' + 1.140 * v''
G'' = y'-0.394 * u''-0.581 * v''
B '= y' + 2.032 * u''
YCbCr <--> RGB
Y' = 0.257 * r'' + 0.504 * g'' + 0.098 * B '+ 16
CB ''=-0.148 * r''-0.291 * g'' + 0.439 * B '+ 128
Cr ''= 0.439 * r''-0.368 * g''-0.071 * B '+ 128
R'' = 1.164 * (y'-16) + 1.596 * (CR ''-128)
G'' = 1.164*(y'-16)-0.813 * (CR ''-128)-0.392 * (CB''-128)
B '= 1.164 * (y'-16) + 2.017 * (CB ''-128)
Note: The above symbols all carry an apostrophes, indicating that the symbol performs Gamma Correction Based on the original value.
Iii. Source differences
The YUV color model comes from the RGB model, which separates brightness and color and is suitable for image processing.
Application: Basic Color Model Used in analog color TV broadcasting. Used in the basic color model for simulating color television broadcasting
The YCbCr model comes from the YUV model. YCbCr is a scaled and offset version of the YUV color space.
Application: Digital Videos, ITU-R bt.601 recommendation
PS: We can confirm through the comparison above that the YUV we use in H.264, MPEG and Other encoding standards is actually YCbCr, and we should not be confused by the name.
Iv. knowledge aggregation
Human Visual systems (HVS) are less sensitive to colors than brightness. In the RGB color space, the three colors are treated equally and stored with the same resolution. However, by separating the brightness and color information, and obtaining a higher resolution for the brightness value, you can more effectively represent a color image.
YCbCr Color Space and Its Transformation (usually written as YUV) are a popular and efficient way to represent a color image. Y is the brightness value, obtained from the weighted average of R, G, and B: Y = krr + kgg + kbb where k is the weighting factor.
Color signals can be expressed by different colors:
CB = B-Y
Cr = R-Y
CG = G-Y
The complete description of a color image is represented by the given Y and three chromatic aberration: CB, Cr, CG.
So far, our representation method does not seem so good, because we use four parameters this time compared to the RGB representation. Then Cb + Cr + CG is a constant, so we only need two color parameters, and the third one can be calculated by the other two. In The YCbCr space, only y and CB, Cr values are transmitted and stored, and the resolution of CB and Cr can be lower than Y, because the human visual systemBrightnessMore Sensitive. This reduces the amount of data that represents the image. Normally, the images represented by RGB and YCbCr do not look very different.Sampling with a resolution lower than brightness is a simple and effective compression method..
An RGB image can be captured and converted to The YCbCr format to reduce storage and transmission workload. Before the image is displayed, it is converted back to RGB. note that there is no need to specify the respective weighted values kg (because kb + kr + KG = 1), and g can be extracted from YCbCr, which means no need to store or transmit CG parameters.
Y = KR r + (1-kb-kr) g + kb B
CB = 0.5/(1-kb) * (B-Y)
Cr = 0.5/(1-kr) * (R-Y)
R = Y + (1-kr)/0.5 * Cr
G = Y-2kb (1-kb)/(1-kb-kr) * CB-2kr (1-kr)/(1-kb-kr) * Cr
B = Y + (1-kb)/0.5 * CB
The ITU-R's bt.601 resolution defines kb = 0.114, Kr = 0.299, then the substitution parameter has the following equation:
Y = 0.299r + 0.587G + 0.114b
CB = 0.564 (B-y)
Cr = 0.713 (r-y)
R = Y + 1.402cr
G = Y-0.344cb-0.714cr
B = Y + 1.772cb
V. YCbCr sampling format
Sampling means that the three elements y, CB, and CR have the same resolution. In this way, the three elements are sampled on each pixel. Number 4 refers to the sampling rate of various elements in the horizontal direction. For example, each four brightness sampling points has four CB Cr sampling values. . All information values are fully retained during sampling.
During sampling (sometimes recorded as yuy2), the color element has the same resolution as the brightness value in the vertical direction, at the horizontal side, the video is half of the brightness resolution (represents two CB and Cr samples for every four brightness values) to construct a high-quality video color signal.
In the sampling format (usually yv12), CB and CR have half of the Y Resolution in the horizontal and vertical directions. is somewhat different, because it does not mean to use in actual sampling, but to define this encoding method in the coding history to distinguish
For and ). Sampling is widely used in consumer applications, such as video conferencing, digital TV, and DVD storage. Because each color difference element contains 1/4 y sample elements, the 4: 2: 0ycbcr video needs to be exactly or half of the RGB video sample quantity.
Sampling is sometimes described as a "12-bit per pixel" method. The reason for this can be seen from the sampling of Four pixels. Sampling at is performed for 12 times. For each y, CB, and Cr, 12*8 = 96 bits are required, with an average of 96/4 = 24 bits. 6*8 = 48 bits are required for, with an average of 48/4 = 12 bits per pixel.
In a sequence of videos scanned at, the samples corresponding to the Y, CB, AND Cr of a complete video frame are allocated to two fields. We can see that the total number of samples for the interlace scan is the same as the number of samples used in the progressive scan.