Compression of retinal images

Keith A. Goatman (K.A.Goatman@abdn.ac.uk)
Department of Radiology, Aberdeen University, Scotland.

Some notes following the Four Nations Camera and Software Working Group meeting 10th May 2006.

Image resolution

The goal posts for choosing camera resolution have not so much shifted as been completely dug up in the past three years. Not so long ago it was safe to go for the highest possible resolution. In the early days this meant video screen resolution; 640x480 or 768x576 pixels and a bulky three-chip video camera. As camera resolution improved the ultimate goal became to match the resolution of 35mm slide film.

However, rapid improvements in sensor technology driven by a market which judges cameras only on the number of pixels they produce means that the highest possible resolution today is probably too high. It wastes valuable bandwidth and processing time for no gain whatsoever.

Modern cameras usually allow the user to save downscaled images, primarily in order to fit more images on memory cards. For instance, at full resolution a typical JPEG compressed image (i.e. not a retinal image) from the 12MP Canon EOS-5D averages around 5.5 megabytes, so 180 would fit on a gigabyte memory card. It also has settings for 6.7MP and 4.2MP. Similarly the EOS-30D, an 8MP camera, has 4.3MP and 2MP settings. Nikon's D200 is a 10MP camera with 5.6MP and 2.5MP settings.

Downsampling of large images, providing it's done properly, doesn't lose any information from the image (it wasn't there to start with) but can actually improve the image by reducing the noise level. In contrast, any JPEG compression increases the noise in the image.

What resolution should we aim for?

  1. To exceed the resolution of the smallest "clinically relevant" object: Unfortunately this is a little subjective. It depends on an agreed definition of (a) what is clinically relevant and (b) what the smallest relevant size is. Even if these are agreed upon, new evidence could change them at any time. For reference, small microaneurysms are approximately 30 microns in diameter. These should be visible with the original specification of 20 pixels/degree, which should be met by a 2MP camera, assuming a 45 degree field of view.
  2. To exceed the resolution of the optics of the eye: The optics of the eye are not perfect and limit the minimum size of object visible on the retina. The resolving power is limited by diffraction and chromatic aberrations, even in healthy eyes. A more stringent resolution limit is therefore to exceed the resolution of the eye itself, since above this resolution there is nothing more to see. The smallest object which may be resolved on the retina is usually taken to be approximately 10 microns. There is nothing to be gained by having pixels smaller than 5 microns; they will not contain any additional information, only noise. Roughly speaking this limit is exceeded at 6MP, or approximately 50 pixels/degree.
  3. The highest possible resolution: (a.k.a. what we're given). This is not a sensible option. If the resolution of the camera exceeds the physical optics of the imaging system no further detail is recorded. However, the resulting images are larger and more cumbersome to transfer, store and view than necessary.

Image compression

Why compress images?

The biggest problem with large images is not so much storage (large terabyte disc arrays are available and are relatively inexpensive) as transmission bandwidth. Even if all the graders' workstations are connected by a 100MB/s network to the server, there is still the problem of transferring the image from the camera to the host computer. Although USB2 has improved the situation (or at least it would if cameras fully utilised the available USB2 bandwidth) the difference between transferring a 12MB raw Canon 6MP image file and a 1.5MB high quality JPEG version of it is considerable.

Lossy and loss-less compression

Image compression may be categorised as lossy or loss-less. In loss-less compression the uncompressed image is identical to the original image. In contrast, lossy compression introduces some errors into the uncompressed image to allow much greater compression of the image. The degree of compression which is possible depends greatly on the image content. "Busy" images (which can be imagined to contain a lot of information) do not compress as well as smoother images with fewer changes in colour and brightness and less detail.

Compression ratios

The compression ratio describes the relative size of the original, uncompressed image with respect to the (hopefully) smaller compressed image.

The following two images have both been compressed using the same JPEG algorithm (immitating that from the image Trevor sent us). The images below are large thumbnails click on the image to see the full-size compressed image.
Natural landscape
Scottish glen. Compression ratio 18:1. Using loss-less PNG compression (deflate algorithm, same as used by zip) a compression ratio of 1.4:1 was achieved. Here is the original uncompressed image.
Typical colour retinal image
A typical retinal image (Canon DGi with EOS-10D back note the mask Digital Healthcare add to the image, its sharp edges are seen on the original uncompressed image). JPEG compression ratio 140:1. Using loss-less PNG compression a ratio of 3.9:1 was achieved, i.e. better than the landscape image with JPEG compression!
Note that colour retinal images compress much more, using the same algorithm, than natural colour images. One reason for this is the large blank region surrounding the image. If this is cropped to a minimum-sized square containing the field of view, the compression ratio drops from 140:1 to 114:1. However, this is still much better than the natural scene, and the blank border clearly does not account for the difference. However, the main reasons for the unusually high compression ratio is that the image contains a very limited range of colours (in particular very little information in the blue region of the spectrum) and limited fine detail information.

What are the pitfalls of lossy compression

Applying this to retinal images

The JPEG compression algorithm was carefully designed to disguise errors in typical images for normal viewing. The algorithms on the commercial equipment have not been optimised for ophthalmic images. Nevertheless, overall performance can be remarkable. Trevor's example image looked stunning even at a compression ratio of 150:1 much better than I would have expected. The important distinction is between a visually acceptable image (which may be suitable for GP notes for instance) and one which is considered of diagnostic quality for grading from.

Large regions of exudates will be visible even at extreme compression ratios. More subtle features, such as microaneurysms, isolated small exudates and new vessels are a completely different matter. Probably the best place to look in the image to see the effect of compression on subtle features is the macula, where faint vessels and subtle brightness gradients are found, as these are the features JPEG is not good at reproducing. Below is the macula region (with contrast increased) from Trevor's image.
macula region
Trevor's image
Macula region from Trevor's example image (whole image in colour).

Note the "blocky" appearance and the brightness contouring. Below is the same region from one of our images, also using a Canon 10D back, showing the original image and the same JPEG compression used in the above image.
macula region
Keith's image (no compression)
Macula region from our Canon DGi and 10D back using the best quality camera compression setting (whole image in colour).
Keith's image with
As above but using JPEG parameters from Trevor's image (whole image in colour).

Comparing the high quality compression with the lower quality compression we can see the degradation we must avoid in images intended for diagnostic purposes. Note in the more compressed image the false contouring and loss of low contrast detail (parts of the vessels disappearing). This could obscure microaneurysms (remember their size is of the same order of magnitude as the 8 by 8 blocks) and subtle new vessels.

Higher compression or downscaling?

Once the resolution limit of the eye has been exceeded no more information about the retina is added to the image. With low noise modern cameras this results in images which achieve higher compression ratios than smaller images with less redundancy.

However, I would recommend downscaling the image first (if it is larger than 6MP), since in theory this does not lose any image information and may improve the noise characteristics of the image. Then apply the best quality JPEG compression, which should only add structure-less noise which should have less impact on edge definition and subtle shading than applying more aggresive JPEG compression on the larger image, which introduces unnatural artefacts in the image.

What compression ratio is acceptable?

There are many variables which affect the compression ratio achieved:

Since there are so many factors which affect the compression ratio, it is difficult to specify an acceptable compression ratio for retinal images, let alone for medical images in general.

Measuring image quality following compression

We have a number of ideas and work in progress to validate image quality following lossy compression, which we can discuss in more detail at a later date. One way of testing the quality of the compression is to acquire a simultaneous compressed and uncompressed version of the same image (some cameras have this facility writing to the memory card). Look at the error map (difference between the images) and look for structural noise. In Aberdeen we have compared a number of lossy compression algorithms, including JPEG and JPEG 2000, with visual appearance and an automated image quality measurement [1].


  1. AD Fleming, S Philip, KA Goatman, JA Olson, PF Sharp. Automated assessment of diabetic retinal image quality based on clarity and field definition. Investigative Ophthalmology and Visual Science 2006;47(3):1120-1125.

   Copyright 2006, Keith A. Goatman, Department of Radiology, University of Aberdeen, Aberdeen, Scotland.