The Image-Conscious Internet This article originally appeared in Geospatial Solutions Magazine's Net Results column of October 1, 2000. Other Net Results articles about the role of emerging technologies in the exchange of spatial information are also online.

1. Introduction and Glossary   2. Get the Right Shrink   3. Ride the Wave   4. Color Safe or Sophisticated?

Get the Right Shrink

The way to compress an image as much as possible is to use the right compression tools. Some tools work best for images with only a few different colors, such as a symbolic map, whereas others are better at compressing images with a scattered collection of many different color shades, such as an aerial photo image.

To understand image compression strategies, consider the original format of most images. Images begin life as a series of pixels, or individual points in a two-dimensional grid of points. The image in Figure 1 is 632 x 3,179 pixels. Each horizontal row of 632 pixels is a scan line. Each pixel in a scan line represents a color; when seen close together, the pixels appear to be continuous gradations of tones. Zooming in to the pixel level (Figure 2) reveals the jagged edges of individual pixels. The lowest scan line of Figure 2 (diagrammed in Figure 3) has 10 yellow (Y) pixels followed by 15 blue (B) pixels followed by 10 more yellow pixels. We can symbolize this scan line from the original bitmap format as YYYYYYYYYYBBBBBBBBBBBBBBBYYYYYYYYYY.

Most compression routines attempt to process the scan lines separately by summarizing repeating patterns or by simplifying complex patterns. RLE compression, for example, examines scan lines for repeated values and summarizes them with a number and value. Thus, the above scan line with with RLE compression is 10-Y-15-B-10-Y. This reduces the scan line from 35 bytes (if each pixel uses 1 byte of storage) to 6 bytes (3 for counts and 3 for color values) almost a 6:1 reduction. As one might expect, RLE works best on images with continuous colors such as Figure 1 s symbolic map. Another strategy, called the LZW algorithm, compresses images by searching for repeated patterns, storing them in a dictionary and referring to them by a single code that matches that dictionary entry. No data is lost, it is only represented by a space-saving short code rather than spelled out literally at each occurrence. In the scan line from Figure 3, the LZW algorithm compressed result might read YYYYY[1]1BBBBB[2]2211. The code for five yellow pixels in a row is 1, as marked following the pattern's first appearance (YYYYY[1]). Whenever this pattern reappears, it is compressed from YYYYY into 1. In this example, the compression turns 35 bytes into 17, a ratio of about 2:1.

To make images even more compressible, LZW applies a simplification technique called differencing, which replaces the value of a pixel with the difference between it and the adjacent pixel, repeating the process for the entire image. This evens out close values between adjacent pixels, producing more patterns and higher compression. TIFF and GIF formats use the standard features of the LZW algorithm and sometimes the RLE algorithm.

It's not a format. Often called an image format, JPEG is actually a collection of compression algorithms. It is best suited for compressing images that do not have contiguous, repeating pixels of the same color. Figure 4 shows the same area as Figure 1, but as a section of a digital orthophoto -- a good candidate for JPEG compression -- instead of a symbolic map. Closer inspection at the pixel level reveals few long repeating pixels and a variety of values -- not a good candidate for RLE compression.

Figure 1: This symbolic map image uses rows of individual pixels to simulate lines and areas of color.
Figure 2: The smooth lines and edges reveal their true nature as jagged pixels when the image in Figure 1 is magnified 1,600 percent.
Figure 3: This diagram of the lowest line of pixels from Figure 2 contains 10 yellow pixels followed by 15 blue pixels followed by 10 yellow pixels.
Figure 4: The same area as Figure 1, but with an orthophotograph, this aerial photo also uses rows of pixels to simulate roads, buildings and trees.
(Figures 1-4 courtesy of the Oakland Unified School District s Map Center, .
Unlike lossless RLE compression in which the original data remains encoded but intact, the JPEG strategy is lossy. Lossy schemes discard useless data during the encoding process to improve compression ratios. Some people might worry that their sharp, clear original images will look fuzzy and flat after a lossy JPEG compression conversion. But, lossy compression schemes can extensively alter images in ways that we humans cannot see, namely through slight changes in color (rather than slight changes in intensity [light and dark] values). In this way, lossy methods can achieve much higher compression ratios than lossless algorithms. Also, the balance between compression and image quality is adjustable, allowing users to raise the compression to the point at which the human eyes first detects image degradation.

After a decade of use, JPEG compression has recently changed; the DIG 2000 and the ISO JPEG 2000 working groups have standardized a new JPEG format that provides more compression options, including use of wavelet technology, already a feature of the MrSID and ECW formats (see below).

For an excellent discussion of these and other compression strategies, consult the Encyclopedia of Graphic File Formats, 2nd Edition, by James D. Murray and William vanRyper, published by O Reilly & Associates, Inc. (Particularly fascinating is a fractal image compression strategy based on the Benoit Mandelbrot theory.)

1. Introduction and Glossary   2. Get the Right Shrink   3. Ride the Wave   4. Color Safe or Sophisticated?