What is chroma subsampling?
Chroma subsampling is a technique used with YCbCr color spaces where you throw away some of the color data in your image in order to compress the image more efficiently. The goal is to remove color data in a way that is not noticeable to viewers. Luma (also called brightness) information is retained for all data. This works in part because the human eye is far more sensitive to brightness than color.
If you'd prefer to watch this explanation as a video, check it out here:
<iframe src="https://embed.api.video/vod/vi75jhpmvVaokPWDFq9ISvrg" width="100%" height="100%" frameborder="0" scrolling="no" allowfullscreen="true"></iframe>
Chroma subsampling is commonly done using blocks of pixels that are 2 rows where each row contains 4 pixels. The color for each pixel is then evaluated and then depending on the type of subsampling, some or none of the color data is thrown away. Let's take a quick look at three common types of subsampling, here's the notation:
And I drew some examples we can use for the discussion:
In the first example, 4:4:4, let's apply that to a block of pixels 2x4 wide. The notation states that for each of the 4 pixels, sample each of the 4 in the first row and each of the 4 pixels in the second row. So for this subsampling, you're not throwing away any color, you're keeping it all.
In the second example, 4:2:2, we again apply the notation to a block of pixels 2x4 wide. The notation states that for each of the 4 pixels, sample 2 pixels in the first row and 2 pixels in the second row. So we lose half the color information for the pixels in each row.
In the third example, 4:2:0, we get our sample block of pixels 2x4 wide again. In this case the notation tells us that we should sample 2 pixels from the first row and none for the second row. So now we're keeping only about 25% of the color data.
If that sounds like you're losing a lot of color information - you'd perhaps be surprised to learn that a lot of video cameras record video where the chroma subsampling is at 4:2:2 or 4:2:0!
Another way of explaining the notation is to say it uses the format x:y:z. x is the number of luma samples. y is the number of chroma samples relative to the number of luma samples on every other line starting from the first. z is the number of chroma samples relative to luma samples on the alternating lines.