Image Processing Lecture 7
Image Enhancement in the Frequency Domain
• The frequency content of an image refers to the rate at which the
gray levels change in the image.
• Rapidly changing brightness values correspond to high frequency
terms, slowly changing brightness values correspond to low
frequency terms.
• The Fourier transform is a mathematical tool that analyses a signal
(e.g. images) into its spectral components depending on its
wavelength (i.e. frequency content).
2D Discrete Fourier Transform
The DFT of a digitized function f(x,y) (i.e. an image) is defined as:
1
( , )= ( , ) cos 2 +
− sin 2 +
The domain of u and v values u = 0, 1, ..., M-1, v = 0,1,…, N-1 is called
the frequency domain of f(x,y).
1
( , )= ( , ) cos 2 + is called real part
−1
( , )= ( , ) sin 2 + is called imaginary part
The magnitude of F(u,v), |F(u,v)|= [R2(u,v)+I 2(u,v)]1/2 , is called the
Fourier spectrum of the transform.
©Asst. Lec. Wasseem Nahy Ibrahem Page 1
Image Processing Lecture 7
The phase angle (phase spectrum) of the transform is:
( , )
∅( , ) =
( , )
Note that, F(0,0) = the average value of f(x,y) and is referred to as the dc
component of the spectrum.
It is a common practice to multiply the image f(x,y) by (-1)x+y. In this
case, the DFT of (f(x,y)(-1)x+y) has its origin located at the centre of the
image, i.e. at (u,v) = (M/2,N/2).
The figure below shows a gray image and its centered Fourier spectrum.
(a)
(b)
Figure 7.1 (a) Gray image. (b) Centered Fourier spectrum of (a)
©Asst. Lec. Wasseem Nahy Ibrahem Page 2
Image Processing Lecture 7
The original image contains two principal features: edges run
approximately at ±45°.
The Fourier spectrum shows prominent components in the same
directions.
Phase spectrum
Phase data contains information about where objects are in the image, i.e.
it holds spatial information as shown in the Figure below.
(a) Original image (b) Phase only image
(c) Contrast enhanced version of image (b) to show detail
Figure 7.2 Phase spectrum
Fourier transform does not provide simultaneously frequency as well as
spatial information.
©Asst. Lec. Wasseem Nahy Ibrahem Page 3
Image Processing Lecture 7
Inverse 2D-DFT
After performing the Fourier transform, if we want to convert the image
from the frequency domain back to the original spatial domain, we apply
the inverse transform. The inverse 2D-DFT is defined as:
( , )= ( , ) cos 2 +
+ sin 2 +
where x = 0,1,…, M-1 and y = 0,1,…, N-1.
Frequency domain vs. Spatial domain
Frequency domain Spatial domain
1. is resulted from Fourier is resulted from sampling and
transform quantization
2. refers to the space defined by refers to the image plane itself,
values of the Fourier i.e. the total number of pixels
transform and its frequency composing an image, each has
variables (u,v). spatial coordinates (x,y)
3. has complex quantities has integer quantities
©Asst. Lec. Wasseem Nahy Ibrahem Page 4
Image Processing Lecture 7
Filtering in the Frequency Domain
Filtering in the frequency domain aims to enhance an image through
modifying its DFT. Thus, there is a need for an appropriate filter function
H(u,v).
The filtering of an image f(x,y) works in 4 steps:
1. Compute the centered DFT, F(u, v) = ℑ((−1) f(x, y))
2. Compute G(u, v) = F(u, v)H(u, v).
3. Compute the inverse DFT of G(u,v), ℑ (G(u, v)).
4. Obtain the real part of ℑ (G(u, v)).
5. Compute the filtered image g(x, y) = (−1) R(ℑ (G(u, v))).
Generally, the inverse DFT is a complex-valued function. However, when
f(x,y) is real then the imaginary part of the inverse DFT vanishes. Thus,
for images step 4, above, does not apply.
The figure below illustrates the filtering in the frequency domain.
Figure 7.3 Basic steps for filtering in the frequency domain
©Asst. Lec. Wasseem Nahy Ibrahem Page 5
Image Processing Lecture 7
Low-pass and High-pass filtering
• Low frequencies in the DFT spectrum correspond to image values
over smooth areas, while high frequencies correspond to detailed
features such as edges & noise.
• A filter that suppresses high frequencies but allows low ones is
called Low-pass filter, while a filter that reduces low frequencies
and allows high ones is called High-pass filter.
• Examples of such filters are obtained from circular Gaussian
functions of 2 variables:
( , )= ( )/
Low-pass filter
( , )= ( )/
(1 − ) High-pass filter
The results of applying these two filters on the image in Figure 6.1(a) are
shown in the figure below.
(a) Low-pass filter function (b) Result of lowpass filtering
©Asst. Lec. Wasseem Nahy Ibrahem Page 6
Image Processing Lecture 7
(c) Highpass filter function (d) Result of highpass filtering
Figure 7.4 Low-pass and High-pass Filtering
Low-pass filtering results in blurring effects, while High-pass filtering
results in sharper edges.
In the last example, the highpass filtered image has little smooth gray-
level detail as a result of setting F(0,0) to 0. This can be improved by
adding a constant to the filter, for example we add 0.75 to the previous
highpass filter to obtain the following sharp image.
Figure 7.5 Result of highpass filter modified by adding 0.75 to the filter
©Asst. Lec. Wasseem Nahy Ibrahem Page 7