1. What is YUV?

  • YUV: is a color coding method, andRGBIs a concept of the same level, widely used in the multimedia field. In other words, the color information of each pixel in the image can be expressed in RGB or YUV.
  • RGBData from theR, G, BThree components
  • YUVData from theY, U, VIt’s made up of three components, and now we usually say YUV is YCbCr.
  • Y: represents Luminance, Luma, accounting for 8 bits (1 byte)
  • Cb, Cr: Represents Chrominance (Chroma)
  • Cb (U): Blue chroma component, accounting for 8bit (1 byte)
  • Cr (V): Red chromaticity component, accounting for 8bit (1 byte)

2. What are the differences or advantages between YUV and RGB objects?

  • YUV is smaller:In RGB, such as RGB888, a pixel takes up 24 bits (3 bytes); With YUV, a pixel can be reduced to an average of only 12 bits (1.5 bytes)
  • YUV has better compatibility:YUV appeared in the transition period from black and white TV to color TV, and black and white TV only needed to receive Y component
  • Better composition structure:Because the human eye structure of Y component identification ability is particularly good, and the identification of UV component is weak, so the UV component can be appropriately compressed, without affecting the human eye recognition, to achieve a smaller data transmission volume

3. In the retina of the human eye, there are two types of photoreceptor cells. Which are they? What are the roles of the two?

  • Two types of photoreceptor cells: rods and cones
  • Rod cells:① Perception of light intensity ② no color recognition function ③ responsible for non-color vision at night
  • Cones:① Color perception ② Color vision during the day ③ If your cones don’t develop properly and there are too few of them, the perception of color is blocked, which can lead to achromatosis

4. What is the result of the different content of the two types of photoreceptor cells?

  • Of the hundreds of millions of light-sensitive cells in the eye, rods make up 95 percent and cones only 5 percent
  • Therefore, the human eye is rightbrightnessIs more sensitive than ischromaThe human eye is more sensitive to brightness than to color.
  • If the chromaticity component of the image is reduced, the human eye will not feel the change and difference at all.

5. What are the three common sampling formats of YUV?

  • Sampling formats are usually expressed in the form A: B: C, for example4:4:4、 4:2:2、 4:2:0And so on. The most important thing we need to pay attention to is4:2:0
  • A: A conceptual area of A*2 pixels, usually A=4
  • B: The number of chromaticity samples in the first row
  • C: Number of chromaticity samples in the second row

6. The storage formats of YUV can be divided into three categories, which three categories are they?

  • Planar: ①Y, U, and V components are stored separately ② Names usually end with a letter P
  • Semi-planarThe Y component is stored separately, and the U and V components are interlaced. The name usually ends with the letter SP
  • Packed (compact): Y, U, and V components are interleaved

7. Transfer other picture formats to YUV

ffmpeg -i in.png -s 512x512 -pix_fmt yuv420p out.yuv
Copy the code
  • The size of the YUV file generated by the preceding command is 393216 bytes = 512 * 512 * 1.5 bytes.

8. Show YUV pictures

ffplay -s 512x512 -pix_fmt yuv420p out.yuv
Copy the code

9. Display a single component

  • The individual components (R, G, B, Y, U, v) can be displayed using filters.
#Only r components are displayed
ffplay -vf extractplanes=r in.png
 
#Only the G component is displayed
ffplay -vf extractplanes=g in.png
 
#Only b components are displayed
ffplay -vf extractplanes=b in.png
 
#Only the y component is displayed
ffplay -video_size 512x512 -pixel_format yuv420p -vf extractplanes=y in.yuv
#Only the y component is displayed
ffplay -video_size 512x512 -pixel_format yuv420p -vf extractplanes=u in.yuv
#Only the y component is displayed
ffplay -video_size 512x512 -pixel_format yuv420p -vf extractplanes=v in.yuv

Copy the code