Bitmap Image Compression

Another aspect to consider when choosing an image format is the compression method used to store the image within a reasonable file size. Some formats store the colour information per pixel without using any compression, but with anything other than the smallest files this is impractical (think of a 800 x 600 x 24-bit image, an average screen-sized bitmap, which would be over 1.4 MB), especially when downloaded from the web. Compression allows us to store the same image in a much smaller file, which can be downloaded in a much more reasonable time.

There are two basic compression types, lossless and lossy. LOSSLESS COMPRESSION stores all the information exactly, without loss of quality or accuracy, a perfect copy. The image recreated on the screen is exactly the same as the image created by the original designer. Lossless compression works particularly well for images with large, solid blocks of colour, which it condenses very effectively. For example, if on a row of pixels there is a line of thirty red pixels, then we can store the colour value for `red' once, and store the fact that it's repeated thirty times, which would save us around twenty to twenty-five colour-value entries. This type of simple compression can make significant savings with certain types of image.

LOSSY COMPRESSION, on the other hand, has more advanced ways of compressing the image data, though this comes at the cost of precise reproduction. In lossy compression, the program creating the image looks for patterns of detail within the image, and compresses areas of low detail much more highly than areas of high detail. The patterns are converted into mathematical formulae describing the pattern's colours, with more complex formulae being used for more highly detailed regions. This can result in images that are significantly smaller than when encoded using other compression methods, especially with photographic images (see Figure 7.7, “Lossy Compression - High Quality”.

The compression is called lossless because these formulae never recreate the image with total precision; there is always some loss of information when the image is decompressed. This is most noticable when a high compression ratio is used, since the image will become blocky and details will become blurred (see Figure 7.8, “Lossy Compression - Low Quality”). The information loss also becomes apparent if the image is repeatedly saved and reopened; like copying a video-cassette, each time a copy is made more of the quality is irretrievably lost.

Figure 7.7. Lossy Compression - High Quality

Image saved as JPEG at 90% quality (10% compression, 15kB filesize). The image appears sharp and clear, and does not seem to have lost any quality due to the compression, even though the filesize has reduced from 75kB uncompressed to 15kB.

[Image from http://www.twardoch.com/download/wirtschaftsinformatik_multimedia.html]


Figure 7.8. Lossy Compression - Low Quality

Image saved as JPEG at 10% quality (90% compression, 1.5kB filesize). The image is much fuzzier, with artifacts or distortion created by the extreme compression.

[Image from http://www.twardoch.com/download/wirtschaftsinformatik_multimedia.html]