Imagebeat

Mandala Thumbnails

Mandala uses the image server, Imago, to shrink images into thumbnails.

Problem: Because Web images come in unknown sizes, image shrinking can not be optimized in the standard way by pre-scaling the filter kernel.

Solution: great-looking thumbnails of even very large Web images can created very quickly and accurately with a novel hybrid algorithm that combines repeated halving with a minimal amount of unoptimized scaling.

 

Below are thumbnails created by scaling a 601-pixel test image to 100x100 pixels with three different algorithms and the indicated running times.

The timing tests were made on the same IRIX workstation with unoptimized code one night back in 1999. The times seem glacially slow now, and there are not enough data points, so why are they interesting?

The relationship between the times is significant: the relative times indicate that the hybrid scaling algorithm is only slightly slower than no filtering at all, yet it produces great-looking thumbnails.

 

 


uniform sampling
4 seconds

 


Lanczos
30 seconds

 


HDC/Lanczos hybrid
10 seconds

 

 

 

 

 

 

The most obvious way to shrink an image is to copy only some of the pixels from only some of the scan lines. This sort of scaling is called “decimation,” “uniform sampling,” or “scaling without filtering.” For example, to make a thumbnail of a 601x601 pixel test image, which is six times the size of the desired output, every sixth pixel from every sixth scan line could be copied into a new image. Imago uses decimation to make thumbnails when its “none” filter option is specified.

Decimation is fast and may be adequate for some blurry input images, but thumbnails created this way usually look terrible.

When sampling theory is applied to digital images, it explains why decimation doesn't work well for making thumbnails. Patterns in the input image that alternate from light to dark at rates higher than half the sampling frequency will not be sampled at a high enough frequency and are likely to result in jagged artifacts as the high input frequencies alias to lower frequencies in the output. In the test image used here, aliasing artifacts are most noticeable in the text “601 pixels.”

Aliasing artifacts associated with uniform sampling can be minimized by expanding each sampling point to a weighted sum of pixel values in the neighborhood around the sample. Sampling theory indicates that neighboring pixel values should be weighted according to an infinite sync function, centered at the sample point. In practice, sync functions are approximated with finite functions. Many different finite functions have been proposed for approximating sync functions [Turkowski 90]. They are typically instantiated as a real-valued matrix, which is thought of as a filter “kernel.” One typical optimization is to use filter kernels that are separable so the two dimensions of the input image can be scaled in separate passes.

Sampling theory dictates using kernels that are large enough to sample at twice the rate of the highest possible input frequency. Large kernels can be accurate, but they can also make the process of shrinking images very slow, especially if the scaling factor is not known in advance and the filter kernel must be scaled at run time.

Imago's lanczos filter option uses a general image scaling algorithm that creates and scales filter kernels at run time based on a scale factor parameter [Schumacher 94]. This algorithm uses separable kernels and, as an additional optimization, pre-computes the kernel contributions for each row and column. Despite these optimizations, however, scaling images with the lanczos option may take five to ten times longer than decimation. Thumbnails created with the lanczos filter option look great, but they take too long to make.

To make great-looking thumbnails of arbitrarily-sized input images quickly, Imago uses a hybrid algorithm, which is a combination of successive invocations of a fast halving method, HDC, and a single invocation of the general image scaling algorithm with the Lanczos kernel. The possible slowness of the final pass is minimized because scale factors are guaranteed to be less than one half. Scaling images with the hybrid option typically takes only a few seconds longer than uniform sampling, but produces results that are difficult to distinguish from the slower lanczos option.

 


plotting run time vs. input area for the different filter options shows
the hybrid algorithm only slightly slower than uniform sampling

Below are the results of several different inputs, shown together for easier comparison. On the left are thumbnails created with the hybrid, HDC/Lanczos algorithm. In the middle are the results of the Lanczos option. On the right are the results of uniform sampling with links to the corresponding input images . The number of seconds it took to compute each thumbnail is shown at the bottom right of each thumbnail.  
HDC/Lanczos lanczos uniform sampling
12 48 9 616x877 input
5 22 4 335x500 input
7 28 5 403x480 input
5 21 3 791x903 input
 

References

Peter J. Burt, Fast Filter Transforms for Image Processing, Computer Graphics and Image Processing, pages 20-51, volume 16, number 1, 1981.

Dale Schumacher, General Filtered Image Rescaling, in Graphics Gems III, editor David Kirk, Academic Press, pages 8-16, 1994.

Ken Turkowski, Filters for Common Resampling Tasks, in Graphics Gems, editor Andrew S. Glassner, Academic Press, pages 147-165, 1990.

 
 

Mandala | applications | thumbnails | layouts | imagemaps | components | documentation
return to ImageBeat home web mediasoftware

Copyright © 2002-2004 Jonathan Helfman