The Mathematica Journal
Volume 10, Issue 2

Search

In This Issue
Articles
In and Out
Trott's Corner
Beyond Sudoku
New Products
New Publications
Calendar
News Bulletins
New Resources
Classifieds

Download This Issue 

About the Journal
Editorial Policy
Staff and Contributors
Submissions
Subscriptions
Advertising
Back Issues
Contact Information

Dither Removal
Bart M. ter Haar Romeny

Dither Removal by Filtering

A "large" dithered and scanned input image follows ( pixels, 1.9MB). Note the periodic artifacts.

Figure 1. Image of a tiger, produced by printing a stock-art photo with an 85 lines per inch dot screen printer and then scanning.

The image is imported as a structure, in which the pixels and the header data are embedded. The pixels can be extracted as the LeftDoubleBracket1,1RightDoubleBracket element.

To develop the method, we do not need the whole image. For speed and lower memory use, we take a subimage. We can see the periodic dithering more clearly by zooming in.

Because the dithering has a high spatial frequency, we suspect these frequencies to be higher than most of the other frequencies in the image. We compute the Fourier spectrum of the input image and plot its absolute value. Because the origin is really large, the image is automatically scaled with a large factor, which reduces the contrast. We zoom in on a limited range () of spectral values.

The significant image frequencies are around the origin (i.e., in the corners of the periodic spectrum plot). The marked peaks at other locations are proof of the existence of strong periodic signals due to dithering. We will use a mask that allows only frequencies near the origin to be included: a low-pass filter for spatial frequencies.

The mask is most easily created by an elliptic Gaussian weighting function in the center (different standard deviations in the and directions), which is then shifted over half the image size in each dimension to put the kernel at the origin of the Fast Fourier Transform (FFT) domain, which is in the lower left. Note that the Fourier domain is periodic in either dimension, so we actually see a single tile of a whole tiled 2D space in the and directions. The standard deviations have to be estimated from the 2D plot of the spectrum. For speed, we exploit the separability of the 2D Gaussian kernel. We first make two 1D arrays of Gaussian values and then multiply them into a matrix with Outer in a compiled function. This is about 140 times faster than a 2D Table command. Sigmaxs and Sigmays are the standard deviations of the Gaussian in the and directions of the subimage.

We also can inspect the amplitude spectrum and the low-pass Gaussian filter (both functions are scaled for plotting) along the interpolated diagonal positions of the rectangular image.

Here we view the mask as a 2D height plot.

We multiply the Fourier spectrum with the mask and study it visually.

We mask out the unwanted frequencies by multiplying the spectrum with the mask, and we get the resulting image by the inverse Fourier transform. The Gaussian filtering is still letting some periodic frequencies through (we only like to keep the information near the corners), so we make it steeper by raising it to the third power.

The result is a markedly improved image, without the disturbing dithering frequencies.

The dither is clearly removed, and details, such as the local hair bundles, can now clearly be discriminated.

The following reads the whole image, processes the data in the Fourier domain (note that and are proportionally rescaled), and writes the restored image to disk, in this case as a GIF file.



     
About Mathematica | Download Mathematica Player 
© Wolfram Media, Inc. All rights reserved.