YUV Color Encoding and Chroma Subsampling

Introduction

YUV is a color encoding system typically used as part of a color image pipeline, such as television streaming. In this blog post, I would like to discuss about YUV encoding and the chroma subsampling which is often used for YUV encoding signal compression.

YUV Color Encoding

Definition

Unlike RGB, the YUV encoding defines a color space in terms of one luminance component (Y) and two chrominance components, called U (blue projection) and V (red projection) respectively. There are YUV encoding derivatives, such as YUV/Y’UV/YCrCb/Y’CrCb, if luma (Y’) is used instead of luminance (Y), and CB/PB and CR/PR, which are deviations from grey on blue–yellow and red–cyan axes, are used instead of chrominance (U and V).

History

Y’UV was invented when engineers wanted color television in a black-and-white infrastructure. The black-and-white televisions only accepts the luma signal. To extend the color encoding of the pictures, two chrominance components U and V were added as separate additional signals specialized for color televisions.

Chroma Subsampling

YUV often does chroma subsampling to compress signal and improve transmission efficiency.

Subsampling Scheme

The chroma subsampling scheme is commonly expressed as a three-part ratio J:a:b (e.g. 4:2:2) or four parts, that describe the number of luminance and chrominance samples in a conceptual region that is J pixels wide and 2 pixels high. The parts are (in their respective order):

  • J: horizontal sampling reference (width of the conceptual region). Usually, 4.
  • a: number of chrominance samples (Cr, Cb) in the first row of J pixels.
  • b: number of changes of chrominance samples (Cr, Cb) between first and second row of J pixels. Note that b has to be either zero or equal to a (except in rare irregular cases like 4:4:1 and 4:2:1, which do not follow this convention).

The chroma subsampling scheme could be visualized using the following table from Wikipedia.

4:1:1 4:2:0 4:2:2 4:4:4 4:4:0
Y'CrCb  
 
= = = = =
Y'  
 
+ + + + +
1 2 3 4 J = 4 1 2 3 4 J = 4 1 2 3 4 J = 4 1 2 3 4 J = 4 1 2 3 4 J = 4
(Cr, Cb) 1 a = 1 1 2 a = 2 1 2 a = 2 1 2 3 4 a = 4 1 2 3 4 a = 4
1 b = 1 b = 0 1 2 b = 2 1 2 3 4 b = 4 b = 0
¼ horizontal resolution,
full vertical resolution
½ horizontal resolution,
½ vertical resolution
½ horizontal resolution,
full vertical resolution
full horizontal resolution,
full vertical resolution
full horizontal resolution,
½ vertical resolution

We could see that the Y/Y’ channel never reduce resolution, because our human eye is very sensitive to subtle luminance changes. Sometimes the value of b is awkward to understand. Basically, if the second row of J pixels shared the same chrominance samples (Cr, Cb) then b = 0, else b = a. For example, there is no change of chrominance samples (Cr, Cb) between first and second row of J pixels in 4:2:0 because the first and second row share the same chrominance samples (Cr, Cb). Similarly, the change of chrominance samples (Cr, Cb) between first and second row of J pixels in 4:2:2 is 2 because the chrominance samples (Cr, Cb) of the first and second row are completely different and the number of difference is 2.

Bandwidth

The color encoding streaming bandwidth could also be easily computed from the subsampling schema. Notice that if RGB signal was streamed instead of YUV signal, the bandwidth will be 24 bits per pixel.

The following table shows the number of bits required for streaming 8 pixels that consists of 2 rows and 4 pixels in each row using different subsampling scheme.

Encoding 4:1:1 4:2:0 4:2:2 4:4:4 4:4:0
Y’ Bits 64 64 64 64 64
Cr Bits 16 16 32 64 32
Cb Bits 16 16 32 64 32
Total Bits 96 96 128 192 128
Averaged Bits Per Pixel 12 12 16 24 16

We could see that 4:4:4 has exactly the same bandwidth as RGB, and thus it does not compress the signal at all. 4:1:1 and 4:2:0 could reduce the bandwidth by half compared to RGB.

References

YUV Color Encoding and Chroma Subsampling

https://leimao.github.io/blog/YUV-Color-Encoding/

Author

Lei Mao

Posted on

05-18-2022

Updated on

05-18-2022

Licensed under


Comments