You are on page 1of 65

EE 610

Digital Image Processing

Chapter 4
Image Enhancement in the
Frequency Domain
(contd. ..)

Spectra of simple periodic patterns


The image shows 2
pixel wide vertical
stripes. The Fourier
transform of this
image is shown in

If we look carefully, we can see that it contains 3 main values: the DCvalue and, since the Fourier image is symmetrical to its center, two
points corresponding to the frequency of the stripes in the original image.
Note that the two points lie on a horizontal line through the image center,
because the image intensity in the spatial domain changes the most if we
go along it horizontally.

The Two-Dimensional DFT and Its Inverse

The 2D DFT F(u,v) can be obtained by


1. taking the 1D DFT of every row of image f(x,y), F(u,y),
2. taking the 1D DFT of every column of F(u,y)

(a)f(x,y)

(b)F(u,y)

(c)F(u,v)

The Two-Dimensional DFT and Its Inverse

shift

The Property of Two-Dimensional DFT


Rotation

DFT

DFT

The Property of Two-Dimensional DFT


Linear Combination
A
DFT
B
DFT

0.25 * A
+ 0.75 * B

DFT

The Property of Two-Dimensional DFT


Expansion
A
DFT

DFT

Expanding the original image by a factor of n (n=2), filling


the empty new values with zeros, results in the same DFT.

Two-Dimensional DFT with Different Functions

Sine wave

Rectangle

Its DFT

Its DFT

Two-Dimensional DFT with Different Functions

2D Gaussian
function

Impulses

Its DFT

Its DFT

Filtering in the Frequency Domain

Basics of Filtering in the Frequency Domain

f(x,y)(-1)x+y

g(x,y)(-1)x+y

12

Filtering in the Frequency Domain

Frequency Domain Processing

Frequency Domain Processing

Frequency Domain Processing

The form of the filter function determines the effects of the


operator.

There are basically three different kinds of filters:

lowpass, highpass and bandpass filters.

Low pass filtering


The most simple lowpass filter is the ideal low pass. It suppresses all
frequencies higher than the cut-off frequency and leaves smaller
frequencies unchanged:
In most implementations, Do is given as a fraction of the highest
frequency represented in the Fourier domain image.
The drawback of this filter function is a ringing effect that occurs
along the edges of the filtered spatial domain image. This
phenomenon is illustrated in the figure on the next slide, which
shows the shape of the one-dimensional filter in both the frequency
and spatial domains for two different values of Do .

Ideal low pass filter

We obtain the shape


of the twodimensional filter by
rotating these
functions about the
y-axis. As mentioned
earlier, multiplication
in the Fourier
domain corresponds
to a convolution in
the spatial domain.
Such a kernel will
have large positive
coefficients at its
center, but these will
be surrounded by a
ring of smaller,
negative coefficients.

Ideal low pass filter

Top: Original image.


Bottom: Image
filtered with ideal
lowpass filter on Y
axis, normalized
cutoff frequency .15.
X axis is an all pass.

Ideal low pass filter


When we try to use an rectangular lowpass filter in the
Y direction two things are illustrated.
First, an ideal rectangular filter cannot be used because
it creates "ringing" artifacts, the same as in a onedimensional transform.
The second and more important realization is that a
filter varying only in the Y frequency direction, and
equal across all X, has its effects only in the Y direction
of the image. We expect this from the rotation property,
and from this we can infer, properly it turns out, that a
filter is just as separable as the transform, and therefore
the direction of a filter will be the direction of its effect.
Notice the way the shadows ripple up and down from
horizonal lines in the original image, whereas vertical
lines such as the edge of the car door are unaffected.

Butterworth low pass filter


Better results can be achieved with a Gaussian shaped filter
function.
The advantage is that the Gaussian has the same shape in the
spatial and Fourier domains, and therefore, does not incur the
ringing effect in the spatial domain of the filtered image.
A commonly used discrete approximation to the Gaussian is the
Butterworth filter. Applying this filter in the frequency domain
shows a similar result to the Gaussian smoothing in the spatial
domain.
One difference is that the computational cost of the spatial filter
increases with the standard deviation (i.e. with the size of the filter
kernel), whereas the costs for a frequency filter are independent of
the filter function. Hence, the spatial Gaussian filter is more
appropriate for narrow lowpass filters, while the Butterworth filter
is a better implementation for wide lowpass filters.

Smoothing Through Low Pass Filters


Top: Original image.
Bottom: Image filtered
with 5th order Butterworth
lowpass filter, normalized
cutoff frequency .3

Highpass Filters and Band Pass Filters


The same principles apply to highpass filters. We obtain a
highpass filter function by inverting the corresponding lowpass
filter, e.g. an ideal highpass filter blocks all frequencies smaller
than Do and leaves the others unchanged.

Bandpass filters are a combination of both lowpass and highpass


filters. They attenuate all frequencies smaller than a frequency
Do and higher than a frequency D1 , while the frequencies
between the two cut-offs remain in the resulting output image.

Sharpening Through Highpass Filters

If we call the transform of the original image A


and a fully attenuating highpass filter H, then
the transform of the highpassed image B(u,v) =
A(u,v)*H(u,v). Therefore, we can create any
linear combination
C = aA + bB = aA + b(A*H), and therefore,
we can create our sharpening filter
H'(u,v) = (a + bH(u,v)). By selecting a good
ratio of a to b as well as choosing the right
cutoff frequency for the filter, we can therefore

Text orientation finding - Example


Finally, we present an example (i.e. text
orientation finding) where the Fourier
Transform is used to gain information
about the geometric structure of the spatial
domain image. Text recognition using
image processing techniques is simplified
if we can assume that the text lines are in a
predefined direction. Here we show how
the Fourier Transform can be used to find
the initial orientation of the text and then a
rotation can be applied to correct the error.

Text orientation finding - Example


The logarithm of the magnitude of its
Fourier transform are

We can see that the main


values lie on a vertical
line, indicating that the
text lines in the input
image are horizontal.

Some Basic Filters and Their Functions


Multiply all values of F(u,v) by the filter function (notch filter):
0 if (u, v) ( M / 2, N / 2)
H (u, v)
otherwise.
1
All this filter would do is set F(0,0) to zero (force the average value of
an image to zero) and leave all frequency components of the Fourier
transform untouched.

Some Basic Filters and Their Functions

Lowpass filter

Highpass filter

Some Basic Filters and Their Functions

Ideal Lowpass Filters (ILPFs)


The simplest lowpass filter is a filter that cuts off all highfrequency components of the Fourier transform that are at a
distance greater than a specified distance D0 from the origin of
the transform.
The transfer function of an ideal lowpass filter

1 if D(u, v) D0
H (u, v)
0 if D(u, v) D0
where D(u,v) : the distance from point (u,v) to the center of ther
frequency rectangle

D(u, v) (u M / 2) 2 (v N / 2)

1
2 2

Ideal Lowpass Filters (ILPFs)

Ideal Lowpass Filters (ILPFs)

Ideal Lowpass Filters

Ideal Lowpass Filters


Another Example

frequency

Figure 4.13 (a) A frequency-domain


ILPF of radius 5. (b) Corresponding
spatial filter. (c) Five impulses in the
spatial domain, simulating the values
of five pixels. (d) Convolution of (b)
and (c) in the spatial domain.
f ( x, y) h( x, y) F (u, v) H (u, v)

spatial

spatial

spatial

Butterworth Lowpass Filters (BLPFs)


With order n

1
H (u, v)
2n
1 D(u, v) / D0

Butterworth Lowpass
Filters (BLPFs)

n=2
D0=5,15,30,80,and 230

Butterworth Lowpass Filters (BLPFs)


Spatial Representation

n=1

n=2

n=5

n=20

Gaussian Lowpass Filters (FLPFs)

H (u, v) e

D 2 ( u ,v ) / 2 D02

Gaussian Lowpass
Filters (FLPFs)

D0=5,15,30,80,and 230

Additional Examples of Lowpass Filtering

Additional Examples of Lowpass Filtering

Ideal Highpass Filters

0
H (u, v)
1

if D(u, v) D0
if D(u, v) D0

Butterworth Highpass Filters

1
H (u, v)
2n
1 D0 / D(u, v)

Gaussian Highpass Filters

H (u, v) 1 e

D 2 ( u ,v ) / 2 D02

Highpass Filters
Spatial Representations

Sharpening Frequency Domain Filter

H hp (u, v) H lp (u, v)
Ideal highpass filter
0
H (u, v)
1

if D(u, v) D0
if D(u, v) D0

Butterworth highpass filter


H (u, v)

1
2n
1 D0 / D(u, v)

Gaussian highpass filter


H (u, v) 1 e

D 2 ( u ,v ) / 2 D02

Original image

Highpass filtering result

After histogram
equalisation

High frequency
emphasis result

Highpass Filtering Example

Highpass Filtering Example

The Laplacian in the Frequency Domain

The Laplacian filter


H (u, v) (u 2 v 2 )
Shift the center:
M
N

H (u, v) (u ) 2 (v ) 2
2
2

Frequency
domain

Spatial domain

g ( x, y ) f ( x , y ) 2 f ( x, y )
where
2 f ( x, y ) : the Laplacian - filtered
image in the spatial domain

For display
purposes only

Implementation
Some Additional Properties of the 2D Fourier Transform

Separability

Implementation
More on Periodicity
Convolution
f ( x ) h( x )
1
M

M 1

f ( m) h ( x m)

m 0

extend

extend

Summary of Some Important Properties


of the 2-D Fourier Transform

Summary of Some Important Properties


of the 2-D Fourier Transform

Summary of Some Important Properties


of the 2-D Fourier Transform

Summary of Some Important Properties


of the 2-D Fourier Transform

Homomorphic filtering
A simple image model
f(x,y): the intensity is called the gray level for
monochrome image
f(x, y) = i(x, y).r(x, y)
0 < i(x, y) < inf, the illumination
0< r(x, y) < 1, the reflectance

59

Homomorphic filter (cont)


f (x, y ) = i (x, y ) r (x, y )
z (x, y ) = ln f (x, y ) = ln i(x, y )+ ln r (x, y )
F {z (x, y )}= F {ln i (x, y )}+ F {ln r (x, y )}
Z (u , v) = Fi (u , v) + Fr (u, v)
S (u , v ) = H (u , v )Fi (u , v )+ H (u, v )Fr (u , v )
s(x, y ) = i(x, y )+ r (x, y )
g (x, y ) = exp[s(x, y )]= exp[i(x, y )]exp[r (x60, y )]

Homomorphic filter (cont)


The illumination component
Slow spatial variations
Low frequency

The reflectance component


Vary abruptly, particularly at the junctions of
dissimilar objects
High frequency

Homomorphic filters
Affect low and high frequencies differently
Compress the low frequency dynamic range
Enhance the contrast in high frequency 61

Homomorphic Filter (cont)

g H >1
g L <1

H (u, v) = (g H - g L )[1 - e

- c ( D 2 ( u ,v ) / D02 )

62

]+gL

Homomorphic filter - example

63

Summary
We examined image enhancement in the
frequency domain
The Fourier series & the Fourier transform
Image Processing in the frequency domain
Image smoothing
Image sharpening

Fast Fourier Transform


Homomorphic Filtering

Point processing

Mask processing
(spatial filters)

Simple gray level


transformations

Smoothing filters (blur


details)

Image negatives
Log transformations
Power-law
transformations
Contrast stretching
Gray-level slicing
Bit-plane slicing

Histogram processing
Histogram
equalization
*Histogram matching
(specification)

Arithmetic/logic
operations
Image averaging

Average, weighted
average
Order statistics (e.g.
median)

65
Frequency domain
filters

Smoothing filters (blur


details)

Unsharp masking
High-boost filters
Derivative filters
The Laplacian
The Gradient

Sharpening filters (highlight


details)

Sharpening filters
(highlight details)

Ideal lowpass filter


Butterworth lowpass
Gaussian lowpass

Unsharp masking
High-boost filters
Derivative filters - The
Laplacian

Ideal highpass filter


Butterworth highpass filter
Gaussian highpass filter

Homomorphic filtering

You might also like