Adam7 algorithm


Adam7 is an interlacing algorithm for raster images, best known as the interlacing scheme optionally used in PNG images. An Adam7 interlaced image is broken into seven subimages, which are defined by replicating this 8×8 pattern across the full image.


The subimages are then stored in the image file in numerical order.
Adam7 uses seven passes and operates in both dimensions, compared to only four passes in the vertical dimension used by GIF. This means that an approximation of the entire image can be perceived much more quickly in the early passes, particularly if interpolation algorithms such as bicubic interpolation are used.

History

Adam7 is named after Adam M. Costello, who suggested the method on February 2, 1995, and after the seven steps involved.
It is a rearrangement of this five-pass scheme that had earlier been proposed by Lee Daniel Crocker:


Alternative speculative proposals at the time included square spiral interlacing and using Peano curves, but these were rejected as being overcomplicated.

Passes

The pixels included in each pass, and the total pixels encoded at that point are as follows:
When rendering, the image will generally be interpolated at earlier stages, rather than just these pixels being rendered.

Related algorithms

Adam7 is a multiscale model of the data, similar to a discrete wavelet transform with Haar wavelets, though it starts from an 8×8 block, and downsamples the image, rather than decimating. It thus offers worse frequency behavior, showing artifacts at the early stages, in return for simpler implementation.

Iteration

Adam7 arises from iteration of the following pattern:


which may be interpreted as "folding" in the vertical and horizontal dimensions. Similarly, GIF interlacing can be seen as iteration of the pattern, but only in the vertical direction.
Using this 3-pass pattern means the first pass is 2 = 1/4 of the image.
Iterating this pattern once yields a 5-pass scheme; after 3 passes this yields


which is then filled in to:


In the 5-pass pattern, the first pass 2 = 1/16 of the image.
Iterating again yields the 7-pass Adam7 scheme, where the first pass 2 = 1/64 of the image.
In principle this can be iterated, yielding a 9-pass scheme, an 11-pass scheme, and so forth, or alternatively an adaptive number of passes can be used, as many as the image size will allow, as is usual in scale-free multiscale modeling. In the context that PNG was developed, a 7-pass scheme was seen as sufficient, and preferable to a simple 5-pass scheme.