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:
Before looking at examples, you may want to read these related pages:
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.)
Other pages on chroma subsampling:
Please send suggestions on this page to email@example.com.