Thursday, March 4, 2010

Subsampling Explained

One of the first things we ask a new JPEG or H.264 customer about their requirements is: "What subsampling will you use?"

Many of them respond: "What's subsampling?" Here's a brief explanation.

Sampling is used to represent the Red, Blue, and Green (RBG) information defining each pixel in an image. In a group of 4 x 4 pixels, there are 16 Red samples, 16 Blue samples and 16 Green samples (48 total samples). This is called 4:4:4 format.

One technique for compressing image data is to switch the way an image is represented to a format that can more readily be subsampled.

For example, instead of using RGB, we can represent the exact same image information with values of luminance and chrominance. Luminance values are represented by Y, and chrominance by U and V. Hence this representation is called YUV format.

A perfect, lossless, transformation from RBG 4:4:4 to YUV 4:4:4 still uses the same abount of data for each pixel (16 samples for each channel). It turns out, though, that the human visual system is more sensitive to luminance than it is to chrominance.

We can exploit this fact to use fewer U and V samples -- subsampling -- but still keep the image looking pretty much the same to the human eye.

Three popular YUV subsampling schemes are 4:2:2 (24 samples), 4:2:0 (20 samples), and 4:1:1 (18 samples). They each require less data than the full 4:4:4 format, at the expense of discarding some of the image information (lossy compression). How far an image can be down-sampled and still look good depends on the nature of the image and the definition of "good" for the particular application.

Different compression algorithms work best with different image formats. So that's why one of our first questions as you consider our image and video compression IP cores is "What subsampling will you use?"

This also helps us understand if you might need something like our Color Space Converter core to get the best results in your system.

No comments: