YUV Pixels and YCbCr

Source: Internet
Author: User

What are the basic elements of a color image?

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

The relationship between YUV and pixels:

YUV is the use of a luminance (Y), two chromatic aberration (u,v) to replace the traditional RGB three colors to compress the image. The traditional RGB primary colors use red, green, and blue to represent a single pixel, and each primary color occupies one byte (8bit), so a pixel with RGB representation requires 8*3=24bit. If you use YUV to represent this pixel, assume that the YUV sample rate is: 4:2:0, that is, each pixel has a sampling frequency of 1 for luminance Y, and for chromatic aberration U and V, each of the adjacent two pixels takes one u and v. For a single pixel, the chromatic aberration U and V are sampled at half the luminance. If there are three adjacent pixels, if the RGB primary color is represented, then the total need to occupy: 8*3*3=72bits; if YUV (4:2:0) is used, it only needs 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 is compressed one times, and the effect of the image has not changed.

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

1, Width: How many pixels of a row. 2, High: The number of pixels in a column. 3, YUV format or RGB format? 4, how many bytes a row? 5. What is the image size? 6. What is the resolution of the image?

The following preliminary analysis of YUV422, YUV420 and YUV444:

YUV422 format.

Divided into many small categories, according to the arrangement of U, V can have yuyv,yvyu,uyvy,vyuy four kinds, of which, Yuyvy is generally referred to as YUV2 format.

And these four kinds of YUV422 format , each can be divided into 2 small class, by Y and UV arrangement can have packaging format and flat format. For example, a 640x480x2 YUV file, packaging format is yuyvyuyv so always lined up, the plane format is the first 640x480 y arranged, then 640x240 u, and then 640x240 v so arranged, 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 isolated a sampling, so calculate down, there is a 640x480 y,640x240 u,640x240 V, a 640x 480-size YUV images account for a total of 640x480x2 bytes, 2 bytes per pixel, or 16 bits.

This arrangement in memory species: 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

..... Other with this push class, that is, every two pixels is a common UV; In a row, the YUV value of each pixel is sampled, the UV value is sampled 0, jumps to 3, and then 5, so there are 640 on each line, U,v 320.

The main sampling formats are YCbCr 4:2:0, YCbCr 4:2:2, YCbCr 4:1:1, and YCbCr 4:4:4. Among them, YCbCr 4:1:1 is 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 does not feel much change. Therefore, the original use of RGB (R,g,b are 8bit unsigned) model, 4 points need to 8x3=24 bites (such as the first figure). Now only 8+ (8/4) + (8/4) =12bites is required, averaging 12bites per point, which compresses half the image's data.

The above only gives a theoretical example, in the actual data storage is likely to be different, the following gives several specific storage forms:

(1) YUV 4:4:4

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

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

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

(2) YUV 4:2:2

The sampling rate of each chromatic channel is half that of the luminance channel, so the chromaticity sampling rate in the horizontal direction is only half 4:4:4. For uncompressed 8-bit quantization images, a macro pixel consisting of two pixels adjacent to each other horizontally requires 4 bytes of memory (2 bytes of brightness, two shades 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 points: [Y0 U0 V1] [Y1 U0 V1] [Y2 U2 V3] [Y3 U2 V3]

(3) YUV 4:1:1

The chroma sampling of the 4:1:1 is a 4:1 sampling of the chroma in the horizontal direction . This is still acceptable for low-end users and consumer products. For uncompressed 8-bit quantization video, a macro pixel consisting of 4 pixels adjacent to each other horizontally requires 6 bytes of memory (brightness 4 bytes, two shades each 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 Y2 V2 Y3

Mapped pixel points: [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 and no CR component. it means that for each line of scanning, only one chroma component is stored at a sampling rate of 2:1. Adjacent scan rows store different chroma components , that is, if one line is 4:2:0, the next line is 4:0:2, and the next line is 4:2:0 ... and so on. For each chroma component, the sampling rate for both horizontal and vertical directions is 2:1, so the sampling rate of chromaticity is 4:1. For uncompressed 8-bit quantization video, a macro pixel of each pixel adjacent to a 2x2 2 rows and 2 columns consumes 6 bytes of memory (4 bytes of brightness and two shades of 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 stream is:Y0 U0 Y1 Y2 U2 Y3

y5v5 Y6 Y7 V7 Y8

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]

YCBCR Sampling format

4:4:4 sampling means that three elements y,cb,cr have the same resolution, so that the three elements are sampled at each pixel. The number 4 refers to the horizontal direction
On the sample rate for various elements, for example, every four luminance sample points have four CB of the CR sample value. 4:4:4 Sampling completely preserves all information values. 4:2:2 Sampling
(sometimes recorded as YUY2), chroma elements in the longitudinal and luminance values have the same resolution, while in the landscape is half the brightness resolution (4:2:2 means that every four brightness value of two CB
and CR sampling.) 4:2:2 video is used to construct high quality video color signals.

In the popular 4:2:0 sampling format (usually YV12) CB and CR have half of the y resolution in both horizontal and vertical directions. 4:2:0 is somewhat different because it does not refer to the actual sampling
Using 4:2:0 in coding history, this coding method is used to differentiate between 4:4:4 and 4:2:2 methods. 4:2:0 sampling is widely used in consumer applications, such as
Video conferencing, digital TV and DVD storage. Because each color difference element contains one-fourth of the Y-sampled elements, the 4:2:0YCBCR video needs to be just 4:4:4
or half of the sample amount in RGB video.

4:2:0 sampling is sometimes described as a "12-bit per pixel" approach. The reason for this is that it can be seen from the sampling of four pixels. With 4:4:4 sampling, there are 12 times
Sampling, for each Y,CB and CR, requires a 12*8=96 bit, averaging down to 96/4=24 bit. Using 4:2:0 requires 6*8=48 bits, averaging 48/4=12 bits per pixel.

In a 4:2:0 interlaced video sequence, the Y,CB,CR sample corresponding to a complete video frame is allocated to two fields. Can be obtained, the total number of samples of interlaced scanning
The number of samples used in the progressive scan is the same.

YUV Pixels and YCbCr

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.