Image Processing Toolbox    

Applications

This section presents a few of the many image processing-related applications of the Fourier transform.

Frequency Response of Linear Filters

The Fourier transform of the impulse response of a linear filter gives the frequency response of the filter. The function freqz2 computes and displays a filter's frequency response. The frequency response of the Gaussian convolution kernel shows that this filter passes low frequencies and attenuates high frequencies.

Figure 8-7: The Frequency Response of a Gaussian Filter

See Linear Filtering and Filter Design for more information about linear filtering, filter design, and frequency responses.

Fast Convolution

A key property of the Fourier transform is that the multiplication of two Fourier transforms corresponds to the convolution of the associated spatial functions. This property, together with the fast Fourier transform, forms the basis for a fast convolution algorithm.

Suppose that A is an M-by-N matrix and B is a P-by-Q matrix. The convolution of A and B can be computed using the following steps:

  1. Zero-pad A and B so that they are at least (M+P-1)-by-(N+Q-1). (Often A and B are zero-padded to a size that is a power of 2 because fft2 is fastest for these sizes.)
  2. Compute the two-dimensional DFT of A and B using fft2.
  3. Multiply the two DFTs together.
  4. Using ifft2, compute the inverse two-dimensional DFT of the result from step 3.

For example,

The FFT-based convolution method is most often used for large inputs. For small inputs it is generally faster to use imfilter.

Locating Image Features

The Fourier transform can also be used to perform correlation, which is closely related to convolution. Correlation can be used to locate features within an image; in this context correlation is often called template matching.

For instance, suppose you want to locate occurrences of the letter "a" in an image containing text. This example reads in text.tif and creates a template image by extracting a letter "a" from it.

Figure 8-8: An Image (left) and the Template to Correlate (right)

The correlation of the image of the letter "a" with the larger image can be computed by first rotating the image of "a" by 180o and then using the FFT-based convolution technique described above. (Note that convolution is equivalent to correlation if you rotate the convolution kernel by 180o.) To match the template to the image, you can use the fft2 and ifft2 functions.

Figure 8-9: A Correlated Image (left) and its Thresholded Result (right)

The left image above is the result of the correlation; bright peaks correspond to occurrences of the letter. The locations of these peaks are indicated by the white spots in the thresholded correlation image shown on the right.

Note that you could also have created the template image by zooming in on the image and using the interactive version of imcrop. For example, with text.tif displayed in the current figure window, enter

To determine the coordinates of features in an image, you can use the pixval function.


  Discrete Fourier Transform Discrete Cosine Transform