Image Processing Toolbox User's Guide 
Applications of the Fourier Transform
This section presents a few of the many image processingrelated 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.
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.
Note
The FFTbased convolution method is most often used for large inputs. For small inputs it is generally faster to use imfilter .

To illustrate, this example performs the convolution of A
and B
, where A
is an MbyN matrix and B
is a PbyQ matrix:
A
and B
so that they are at least (M+P1)by(N+Q1). (Often A
and B
are zeropadded to a size that is a power of 2 because fft2
is fastest for these sizes.) The example pads the matrices to be 8by8.
A
and B
using fft2
.
ifft2
.
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.
This example illustrates how to use correlation to locate occurrences of the letter "a" in an image containing text:
imcrop
, using the pixval
function to determine the coordinates of features in an image.
The following figure shows both the original image and the template.
Image (left) and the Template to Correlate (right)
a
with the original image bw
by rotating the template image by 180^{o} and then using the FFTbased convolution technique described in Fast Convolution. (Convolution is equivalent to correlation if you rotate the convolution kernel by 180^{o}.) To match the template to the image, use the fft2
and ifft2
functions.
Correlated, Thresholded Image Showing Template Locations
Discrete Fourier Transform  Discrete Cosine Transform 
© 19942005 The MathWorks, Inc.