Chroma Subsampling in JPG Compression

JPG is a lossy compression algorithm. This means that JPG trades quality
for smaller file size. One tradeoff that is commonly employed is chroma subsampling.
Chroma subsampling is a method that stores color information at lower resolution
than intensity information. The overwhelming majority of graphics programs perform
2x2 chroma subsampling, which breaks the image into 2x2 pixel blocks and only
stores the average color information for each 2x2 pixel group. This process
introduces two kinds of errors:

The major problem is that color is stored at only half the horizontal and
vertical resolution as the original image. This sounds terrible, but much
of the time it is not such a bad strategy for a couple of reasons:

The human eye has lower resolving power for color than for intensity.

Nearly all digital cameras have lower resolution for color than for intensity,
so there is no high resolution color informatoin present in digital camera
images.

The subsampling process demands two conversions of the image: from the original
red/green/blue representation to an intensity+color representation, and then
back again when the image is displayed. Since this conversion is done in integer
arithmetic, some round-off error is introduced. This is a much smaller effect,
but it does slightly affect the color of one or two percent of the pixels
in an image, typically.

Before looking at examples, you may want to read these related pages:

"JPG vs. GIF" explains how to choose
between these two formats, particularly for images intended for the web.

"How bad is JPG?" discusses the choice
between JPG and lossless formats such as TIFF and PNG. It documents the huge
savings in file size that JPG offers, as well as the kind of image degradation
that JPG can introduce.

"JPG or lossless for archiving?"
advances the thesis that, for a given file size, one is better served by scanning
at high resolution and using JPG compression to reduce file size than scanning
at low resolution to reduce file size and saving in a lossless format.

The JPG images on these pages were created using Paint Shop Pro version 8,
Public Beta 2. The original PNG can be seen here.Below
is 285K file created with a compression setting of 3 and with
the usual 2x2 chroma subsampling used by most graphics software:

Next consider the following 283K image, created with chroma subsampling
turned off and a higher compression setting of 6.

Look at the gentleman in the striped shirt kneeling at the bottom left of
the picture. In the second image, the red stripes are very, very close to
the color of the original. In the first image (chroma
subsampling), the red is more of a dull purple. See the original for
comparison, or look at the enlargement of this section below:

Note that 2x2 chroma subsampling severely alters colors of 1-pixel-wide stripes,
such as are present above. The second image, at least in this section, is a
much more faithful reproduction of the original, even though the file size is
slightly smaller.

Tom Lane notes that the point of JPG is to reproduce photographs that appear
as accurate to the eye as possible with minimum file size. Perhaps it is unfair
to blow up an image to the point where the pixels are visible. Nonetheless,
for web use, that is what we must do. Screen resolutions are not high enough
to approach the resolving power of the human eye. Chroma subsampling may be
a reasonable compression strategy for high resolution images, but for color
web images, one is better served by turning off chroma subsampling and compressing
more aggressively to achieve the same file size.

The above discussion should be a warning to us when we talk about the quality
of JPG compression. JPG images differ not only in the quality setting of the
compression program, but also in the algorithms used by the program authors
in achieving that compression. One of the most important algorithmic differences
is the the choice of whether or not to use chroma subsampling. Nearly all
graphics software employs 2x2 chroma subsampling. Adobe Photoshop switches
to 1x1 chroma subsampling at higher quality settings. Paint Shop Pro offers
the best approach, letting the user turn chroma subsampling on or off at any
compression setting.

One should note that turning off chroma subsampling may not always be the
wisest choice for compromising between file size and image quality. The eye
is less sensitive to high spatial frequencies in color information than to
high frequencies in intensity. For high resolution images, this means that
a good JPG algorithm
should store chroma information with less detail for optimum balance
between file size and quality. In very special images such as this one, the
problem is obvious even unmagnified. However, choosing 1x1 chroma subsampling
means that you must compress intensity information even more to achieve a
given file size. For web images (which are generally low resolution), turning
off chroma subsampling is nearly always a good idea. For images intended for
viewing on a monitor, small file size is best achieved by turning off chroma
subsampling and then cranking up the compression. (This is possible with Paint
Shop Pro, but unfortunately not with Photoshop, where the two approaches are
coupled in a single control.)

(Thanks to Tom Lane for explaining the differences and implications of chroma
subsampling size. Thanks also to Volker Jaeger of Singapore, who first brought
to my attention that the most dramatic JPG image degradation discussed on these
pages is not present when chroma subsampling is turned off.)

For more on the effects of chroma subsampling and variations in JPG compression,
see the nice page by Martin Brown, Probing JPEG Chroma Sampling. (I have removed
this link because the page is now missing.)