JPEG Artefacts Test

This is a sample image 8x8 pixels encoded with minimum JPEG compression in Paintshop Pro v5.0 The image is not very suitable for JPEG consisting of highly saturated colour blocks 2x1 pixel wide. The intention is to demonstrate the sort of artefacts which can occur in practice in a very much simplified form. The problem is with heavy saturated colours and sharp discontinuities which are difficult for colour subsampling to represent accurately. It has actually done remarkably well in preserving luminance information, but when enlarged the difference between the original image and JPEG is more obvious. The artefacts are present but at a pretty low level even in such a difficult image.

Note that under normal circumstances and typical magnifications these would not be visible. Many commercial monitors are unable to resolve the differences at 1x or even 2x magnification. Images have been converted to GIF's for display purposes here using exact palette colour matching (there are only 64 pixels in the image). There are 4 colours in the original test image, and 40 distinct shades in the resulting JPEG reconstruction.

Original 1x 2x 4x 8x

JPEGs 1x 2x 4x 8x

Real photographic images seldom have such sharp transitions between regions and so the JPEG compression of real colour photographic images usually works much better than the above test images might imply. The moral of the tale is obviously that it is unwise to use JPEG compression with colour subsampling for line art colour images. However, the limitation is not with the JPEG standard - images can be saved as JPEG without subsampling.

The IJG CJPEG utility with suitable command line options or the PhotoShop JPEG codec at levels 6 and above can create full colour sampled JPEGs.

JPEGs. 1x{short description of image} 2x{short description of image} 4x{short description of image} 8x{short description of image}

The extra colour fidelity makes PhotoShop a good choice for saving scanned images as highest quality JPEG files. More recently PaintShop Pro v8.0 also permits options to save JPG files with a range of colour subsampling options. Unfortunately the chroma subsampling is seriously broken causing systematic errors in the JPEG encoding and it still doesn't do optimised Huffman coding. The following pure red and pure blue poker dot pattern demonstrates the faulty encoding of chroma subsampling vividly even at maximum quality.

Original 1x{short description of image} 2x{short description of image}

IJG Codec 2x2 subsampled1x{short description of image} 4x{short description of image}

The loss of red blue contrast is an unavoidable consequence of chroma subsampling, but from a distance and on a properly adjusted monitor the two images above should look similar once you can no longer resolve the colours of the individual pixels. Compare that with the same source image encoded by PSPro v8 below:

PSP v8 2x2 subsampled 1x{short description of image} 4x{short description of image}

PSP v8 2x1 subsampled 1x{short description of image} 4x{short description of image}

A page addressing the vexed question of JPEG Generational Losses or what happens when you repeatedly open, decode and re-encode save an image using JPEG. The short answer is that for a while the image will always be worse after each cycle of decoding and re-encoding even if the compression settings are identical every time. The first save causes the greatest loss of fidelity. But after a while the image will settle down block by block to the nearest stable attractor. That is an image in RGB space that when encoded gives self consistent JPEG coefficients that decode to give a new RGB image that is close enough to the previous generation that no further degradation occurs. This stable attractor image may lose considerable amounts of colour saturation if chroma subsampling is used. And of course if you alter the lossy compression settings even slightly the result is another disastrous loss of quality.


Email to Martin Brown

Send feedback suggestions and comments to Martin Brown
Last modified 27th July 2007