YUV Format & Pixel

Source: Internet
Author: User

What is the basic element of a color picture?

To put it bluntly, an image consists of the basic thing is binary data, its capacity size in essence that is the number of binary data. A YUV422 image of a 1920x1080 pixel, the size of which is 1920x1080x2=4147200 (decimal), or 3.95M. This size is related to the number of pixel points and the storage format of the data. The following describes the relationship between YUV and pixels:

YUV relation to Pixels:

YUV uses a brightness (Y), two chromatic aberration (u,v) to replace the traditional RGB three primary colors to compress the image. The traditional RGB three primary colors use red, green and blue three primary colors to represent a pixel, each primary color occupies one byte (8bit), so a pixel in RGB is required 8*3=24bit. If you use YUV to represent this pixel, suppose the YUV sample rate is: 4:2:0, that is, each pixel has a sample frequency of 1 for brightness y, and for the chromatic aberration U and V, each of the two pixels each adjacent to each of the U and V is taken. For a single pixel, the sample frequency of the chromatic aberration U and V is half the brightness. If there are three adjacent pixels, if the RGB primary colors are expressed, then the total need to occupy: 8*3*3=72bits; if YUV (4:2:0) is used, then only need to occupy: 8*3 (Y) + 8*3*0.5 (U) +8*3*0.5 (V) = 36bits. Only the original half of the space, you can represent the original image, the data rate compressed one times, and the effect of the image basically did not change.

In general, we will consider the following points when describing the parameters of an image:

1, Width: How many pixel points in a row. 2, High: A column of how many pixel points. 3, YUV format or RGB format. 4, the number of bytes in a row. 5, image size is how much. 6, the resolution of the image is how much.

The following is a preliminary analysis of YUV422, YUV420, and YUV444:

YUV422 format.

Divided into a number of small classes, according to the U, v arrangement can have yuyv,yvyu,uyvy,vyuy four species, of which, yuyvy generally referred to as YUV2 format.

And these four kinds of YUV422 format , each can be divided into 2 small classes, according to Y and UV arrangement can have packaging format and flat format. For example, a 640x480x2 YUV file, the packaging format is yuyvyuyv so that the arrangement, the plane format is the first 640x480 y arranged, then 640x240 a U, and then the 640x240 v this arrangement, as follows

Figure:


If there is a picture of 640x480, using yuv422 to express, then, the sampling method is each pixel sampling y signal, u,v signal from a sample, so that there will be 640x480 a y,640x240 u,640x240 V, a 640x The total number of bytes in the 480 size yuv picture is 640x480x2 bytes, 2 bytes per pixel, or 16 bits.

In the memory species, this arrangement: Y0u0y1v0 y2u1y3v1 ...

The YUV value of the first pixel is: Y0 U0 V0

The YUV value of the second pixel is: Y1 U0 V0

The YUV value of the third pixel is: Y2 U1 V1

..... Others with this push class, that is, every two pixel is a total of UV; On one line, the Y-value in each pixel's YUV value is sampled, the UV value is sampled 0, jumps to 3, then 5, so there are 640 on each line y, and 320 for each u,v.

The main sampling formats are YCbCr 4:2:0, YCbCr 4:2:2, YCbCr 4:1:1, and YCbCr 4:4:4. Which YCbCr 4:1:1 more commonly used, the meaning is: each point to save a 8bit brightness value (that is, Y value), each 2x2 point to save a Cr and CB value, the image in the naked eye of the feeling will not be too big changes. Therefore, the original use of RGB (R,g,b are 8bit unsigned) model, 4 points need to 8x3=24 bites (the first diagram below). And now only need 8+ (8/4) + (8/4) =12bites, an average of 12bites per point, so that the image of the data compression half.

The above only gives a theoretical example, which is likely to be different in the actual data store, with several specific forms of storage listed below:

(1) YUV 4:4:4

YUV three channels have the same sampling rate, so in the generated image, the three component information of each pixel is complete (usually 8 bits per component), after 8 bit quantization, the uncompressed pixel occupies 3 bytes.

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

The stream stored is: Y0 U0 V0 Y1 U1 V1 Y2 U2 V2 Y3 U3

(2) YUV 4:2:2

The sampling rate of each color-difference channel is half that of the luminance channel, so the chroma sampling rate in the horizontal direction is only half of the 4:4:4. For uncompressed images of 8-bit quantization, the macro pixel of each pixel that consists of two horizontal orientations is required to occupy 4 bytes of memory (2 bytes in brightness, two pixels per 1 bytes). .

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

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

Mapped pixel: [Y0 U0 V1] [Y1 U0 V1] [Y2 U2 V3] [Y3 U2 V3]

(3) YUV 4:1:1

The chroma sampling of 4:1:1 is a 4:1 sampling of chroma in the horizontal direction . This is still acceptable for low-end users and consumer products. For uncompressed video of 8-bit quantization, the macro pixel of each pixel that consists of 4 horizontal orientations is required to occupy 6 bytes of memory (4 bytes in brightness, two pixels per 1 bytes).

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 Y2 V2 Y3

Mapped pixel: [Y0 U0 V2] [Y1 U0 V2] [Y2 U0 V2] [Y3 U0 V2]

(4) yuv4:2:0

4:2:0 does not mean that there is only Y,CB but no CR component. it means that for each line of scan, only one chroma component is stored at a sample rate of 2:1. Adjacent scan rows store different chroma components , that is to say, if a row is 4:2:0, the next line is 4:0:2, and then the next line is 4:2:0 ... and so on. For each chroma component, the horizontal and vertical sampling rate is 2:1, so it can be said that the chroma of the sampling rate is 4:1. For uncompressed 8-bit-quantization video, a macro pixel consisting of pixels adjacent to a 2x2 2 row 2 column needs to occupy 6 bytes of memory (brightness 4 bytes, two chroma 1 bytes).

The following eight pixels are:[Y0 U0 V0] [Y1 U1 V1] [Y2 U2 v2][y3 U3 V3]

[Y5u5 V5] [Y6 U6 V6] [Y7u7 V7] [Y8 U8 V8]

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

y5v5 Y6 Y7 V7 Y8

The mapped pixel points are: [Y0 U0 V5] [Y1 U0 V5] [Y2 U2 V7] [Y3 U2 V7]

[y5u0 V5] [Y6 U0 V5] [y7u2 V7] [Y8 U2 V7] (information from the Internet, infringement please declare, thank you)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.