ListConvolve: An Image Processing Example
Mathematica 4 includes new and highly optimized sets of functions for performing
convolutions and correlations on lists of data. These operations are commonly used in
statistical data analysis and approximations to partial differential equations. Another
important application of convolution and correlation is in signal and image processing; we
will demonstrate one of the latter.
The new data import capabilities of Mathematica 4 allow us to directly read
in an image in JPEG format. In this case, the image is a black-and-white photograph of the
upper dial of the Astronomical Clock in Prague, adjacent to the crypt of the great
observational astronomer Tycho Brahe (1546-1601).
The image is 695 x 565 pixels in size, with nearly 400,000 data points.
We can perform edge detection on this picture using a discrete convolution with the
kernel .
The calculation is complete in about a second. Here is the resulting image, showing the
edges detected by the convolution; note that the markings on the dial have become more
legible.
Before ListConvolve, the user had
to create a list convolution routine from scratch, and the resulting routine was likely to
be both considerably slower and far more memory intensive. Here is an implementation of
the same problem without using ListConvolve;
note that this version only treats two-dimensional arrays, while Mathematica's ListConvolve can treat tensors of arbitrary
dimension.
In this version, the actual calculation takes much longer than before; it also requires
many times more memory to arrive at the same result.
|