Sunteți pe pagina 1din 94

Chapter4 Image Enhancement in the

Frequency Domain
Enhance: To make greater (as in value, desirability, or
attractiveness.
Frequency: The number of times that a periodic function
repeats the same sequence of values during a unit variation of
the independent variable.
Websters New Collegiate Dictionary
1


Content

Background
Introduction to the Fourier Transform and the
Frequency Domain
Smoothing Frequency-Domain Filters
Sharpening Frequency-Domain Filters
Homomorphic Filtering
Implementation
Summary
2

This chapter is concerned primarily with helping the reader develop a
basic understanding of the Fourier transform and the frequency
domain, and how they apply to image enhancement.
4.1 Background
3
Any function that periodically repeats itself can be
expressed as the sum of sines and/or cosines of different
frequencies, each multiplied by a different coefficient
(Fourier series).
Even functions that are not periodic can be expressed as
the integral of sines and/or cosines multiplied by a
weighting function (Fourier transform).
The advent of digital computation and the discovery of
fast Fourier Transform (FFT) algorithm revolutionized the
field of signal processing.
4
The frequency domain
refers to the plane of
the two dimensional
discrete Fourier
transform of an image.
The purpose of the
Fourier transform is to
represent a signal as a
linear combination of
sinusoidal signals of
various frequencies.
4.2 Introduction to the Fourier Transform
and the Frequency Domain
5
The one-dimensional Fourier transform and its inverse
Fourier transform (continuous case)

Inverse Fourier transform:

The two-dimensional Fourier transform and its inverse
Fourier transform (continuous case)


Inverse Fourier transform:

}


= du e u F x f
ux j t 2
) ( ) (
} }


+
= dy dx e y x f v u F
vy ux j ) ( 2
) , ( ) , (
t
1 where ) ( ) (
2
= =
}



j dx e x f u F
ux j t
} }


+
= dv du e v u F y x f
vy ux j ) ( 2
) , ( ) , (
t
u u
u
sin cos j e
j
+ =
4.2.1The one-dimensional Fourier transform and its
inverse (discrete time case)
6
Fourier transform (DFT)


Inverse Fourier transform (IDFT)



The 1/M multiplier in front of the Fourier transform sometimes is
placed in the front of the inverse instead. Other times both
equations are multiplied by
Unlike continuous case, the discrete Fourier transform and its
inverse always exist, only if f(x) is finite duration.


1 ,..., 2 , 1 , 0 for ) ( ) (
1
0
/ 2
= =

=
M x e u F x f
M
u
M ux j t
1 ,..., 2 , 1 , 0 for ) (
1
) (
1
0
/ 2
= =

M u e x f
M
u F
M
x
M ux j t
1/ M
Since and the fact
then discrete Fourier transform can be redefined





u u
u
sin cos j e
j
+ =
7
1
0
1
( ) ( )[cos 2 / sin 2 / ]
for 0,1, 2,..., 1
M
x
F u f x ux M j ux M
M
u M
t t

=
=
=

u u cos ) cos( =
F(u) can be expressed in polar coordinates:




R(u): the real part of F(u)
I(u): the imaginary part of F(u)
Power spectrum:
( )
1/2
2 2
1
( ) ( )
where ( ) ( ) ( ) (magnitude or spectrum)
( )
( ) tan (phase angle or phase spectrum)
( )
j u
F u F u e
F u R u I u
I u
u
R u
|
|

=
( = +

(
=
(

8
) ( ) ( ) ( ) (
2 2
2
u I u R u F u P + = =
9
Some One-Dimensional Fourier Transform Examples
Please note the relationship between the value of K and the height of
the spectrum and the number of zeros in the frequency domain.
The transform of a constant function is a DC value only.




The transform of a delta function is a constant.
10
The transform of an infinite train of delta functions spaced by
T is an infinite train of delta functions spaced by 1/T.




The transform of a cosine function is a positive delta at the
appropriate positive and negative frequency.
11
The transform of a sin function is a negative complex delta
function at the appropriate positive frequency and a negative
complex delta at the appropriate negative frequency.




The transform of a square pulse is a sinc function.
12
The 2-D Fourier transform & its inverse
13
Fourier transform (DFT)




Inverse Fourier transform (IDFT)




u, v : the transform or frequency variables
x, y : the spatial or image variables
1 ,..., 2 , 1 , 0 , 1 ,..., 2 , 1 , 0 for
) , ( ) , (
1
0
1
0
) / / ( 2
= =
=

=
+
N y M x
e v u F y x f
M
u
N
v
N vy M ux j t
1 ,..., 2 , 1 , 0 , 1 ,..., 2 , 1 , 0 for
) , (
1
) , (
1
0
1
0
) / / ( 2
= =
=

=
+
N v M u
e y x f
MN
v u F
M
x
N
y
N vy M ux j t
We define the Fourier spectrum, phase anble, and power
spectrum of the two-dimensional Fourier transform as follows:





R(u,v): the real part of F(u,v)
I(u,v): the imaginary part of F(u,v)
| |
spectrum) (power ) , ( ) , ( ) , ( ) (
angle) (phase
) , (
) , (
tan ) , (
spectrum) ( ) , ( ) , ( ) , (
2 2
2
1
2
1
2 2
v u I v u R v u F u,v P
v u R
v u I
v u
v u I v u R v u F
+ = =
(

=
+ =

|
14
Some properties of Fourier transform:





| |
) (symmetric ) , ( ) , (
symmetric) (conujgate ) , ( * ) , (
(average) ) , (
1
) 0 , 0 (
(shift) )
2
,
2
( ) 1 )( , (
1
0
1
0
v u F v u F
v u F v u F
y x f
MN
F
N
v
M
u F y x f
M
x
N
y
y x
=
=
=
=

=
+
15
(a) f(x,y) (b) F(u,y) (c) F(u,v)

16
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)

Steps and some example of 2-D DFT
y or v
x or u
Convention of coordination:
17
DFT
DFT
The Property of Two-Dimensional
DFT Rotation
18
DFT
DFT
DFT
A
B
0.25 * A
+ 0.75 * B
The Property of Two-Dimensional
DFT Linear Combination
19
DFT
DFT
A
Expanding the original image by a factor of n (n=2), filling
the empty new values with zeros, results in the same DFT.
B
The Property of Two-Dimensional
DFT Expansion
20
Two-Dimensional DFT with
Different Functions
Sine wave
Rectangle
Its DFT
Its DFT
21
Two-Dimensional DFT with
Different Functions
2D Gaussian
function
Impulses
Its DFT
Its DFT
Filtering in the Frequency Domain
22
Frequency is directly related to rate of change. The frequency of fast
varying components in an image is higher than slowly varying components.
23
Slowest varying component (u=v=0) shows average intensity of
image in F domain.
Strong edges at +/- 45 degree( shown by diagonal lines)
White edges (vertical line)
24
Basics of Filtering in the Frequency Domain
Including multiplication the input/output image by (-1)
x+y
.
What is zero-phase-shift filter?
Multiply all values of F(u,v) by the filter function (notch filter):


All this filter would do is set F(0,0) to zero (force the average value of an
image to zero) and leave all other frequency components of the Fourier
transform untouched and make prominent edges stand out

=
=
otherwise. 1
) 2 / , 2 / ( ) , ( if 0
) , (
N M v u
v u H
25
Some Basic Filters and Their Functions
26
Some Basic Filters and Their Functions
Lowpass filter
Highpass filter
Circular symmetry
27
28
Some Basic Filters and Their Functions
Low frequency filters: eliminate the gray-level detail and keep the general
gray-level appearance. (blurring the image)
High frequency filters: have less gray-level variations in smooth areas and
emphasized transitional (e.g., edge and noise) gray-level detail. (sharpening
images)
29
Padding of zeros
Correspondence between Filtering in the Spatial and
Frequency Domain

30
Convolution theorem:
The discrete convolution of two functions f(x,y) and h(x,y) of size M
N is defined as




The process of implementation:
1) Flipping one function about the origin;
2) Shifting that function with respect to the other by changing the
values of (x, y);
3) Computing a sum of products over all values of m and n, for each
displacement.
1 1
0 0
1 1
0 0
1
( , ) ( , ) ( , ) ( , )
1
( , ) ( , )
M N
m n
M N
m n
f x y h x y f m n h x m y n
MN
h m n f x m y n
MN

= =

= =
- =
=

31
) , ( ) , ( ) , ( ) , ( v u H v u F y x h y x f -
) , ( ) , ( ) , ( ) , ( v u H v u F y x h y x f -
Let F(u,v) and H(u,v) denote the FT of f(x,y) and h(x,y), then
an impulse function of strength A, located at coordinates
(x
0
,y
0
): and is defined by
:



where : a unit impulse located at the origin
The Fourier transform of a unit impulse at the origin :

=
=
1
0
1
0
0 0 0 0
) , ( ) , ( ) , (
M
x
N
y
y x As y y x x A y x s o
) , (
0 0
y y x x A o

=
=
1
0
1
0
) 0 , 0 ( ) , ( ) , (
M
x
N
y
s y x y x s o

=
+
= =
1
0
1
0
) / / ( 2
1
) , (
1
) , (
M
x
N
y
N vy M ux j
MN
e y x
MN
v u F
t
o
) , ( y x o
The shifting property of impulse
function
Let , then the convolution



Combine Eqs. (4.2-35) (4.2-36) with Eq. (4.2-31), we obtain:


) , (
1

) , ( ) , (
1
) , ( ) , (
1
0
1
0
y x h
MN
n y m x h n m
MN
y x h y x f
M
m
N
n
=
= -

=
o
32
) , ( ) , ( y x y x f o =
| |
) , ( ) , (
) , (
1
) , (
1
) , ( ) , ( ) , ( ) , (
) , ( ) , ( ) , ( ) , (
v u H y x h
v u H
MN
y x h
MN
v u H y x y x h y x
v u H v u F y x h y x f

-
-
o o
That is to say, the response of
impulse input is the transfer
function of filter.
Summary of steps for filtering in F domain
1.Given input image f(x,y) of size MxN, obtain the
padding parameters P & Q .
P= 2M & Q= 2N
2. Form a padded image fp(x,y) of size PxQ.
3. Multiply fp(x,y) by (-1)^x+y to center its
transform.
4. Find DFT, F(u,v)
5. Generate symmetric filter function H(u,v) with
center at (P/2,Q/2)
Get the product G(u,v)= F(u,v) H(u,v)

33
6. Obtain the processed image
Gp(x,y) = {real [IDFT(G(u,v)]}(-1)^x+y
7. Obtain the final processed image g(x,y) by
extracting MxN region from the top left
quadrant of gp(x,y)
34


35
The distinction and links between spatial and frequency filtering
The link b/w spatial & frequency filtering is Convolution.
If the size of spatial and frequency filters is same, then the computation
burden in spatial domain is larger than in frequency domain;
However, whenever possible, it makes more sense to filter in the spatial
domain using small filter masks.
Filtering in frequency is more intuitive. We can specify filters in the
frequency, take their inverse transform, and the use the resulting filter
in spatial domain as a guide for constructing smaller spatial filter masks.
Fourier transform and its inverse are linear process, so the following
discussion is limited to linear processes.
36
Let H(u) denote a frequency domain, Gaussian filter function
given the equation

where : the standard deviation of the Gaussian curve.
The corresponding filter in the spatial domain is




2 2 2
2
2 ) (
x
Ae x h
o t
o t

=
o
37
2 2
2 /
) (
o u
Ae u H

=
There is two reasons that filters based on Gaussian functions are of
particular importance: 1) their shapes are easily specified; 2) both
the forward and inverse Fourier transforms of a Gaussian are real
Gaussian function.
38
39
2 2 2 2
1 2
/ 2 / 2
1 2
( ) , ( , )
u u
H u Ae Be A B
o o
o o

= > >
The corresponding filter in the spatial domain is
2 2 2 2 2 2
1 2
2 2
1 2
( ) 2 2
x x
h x Ae Be
t o t o
to to

=
We can note that the value of this types of filter has both negative and
positive values. Once the values turn negative, they never turn positive again.

Filtering in frequency domain is usually used for the guides to design the
filter masks in the spatial domain.
Both it and its Fourier transform are real valued
In addition, the values are always positive. So, if we convolve an image
with a Gaussian function, there will never be any negative output values
to deal with.
If we make the width of the function smaller, the width of the Fourier
transform gets larger. This is controlled by the variance parameter o
2
in
the equations.
The amount of blur is controlled by o
2
.

40
Some important properties of Gaussian filters funtions
Smoothing Frequency-Domain Filters
41
The basic model for filtering in the frequency domain

where F(u,v): the Fourier transform of the image to be
smoothed
H(u,v): a filter transfer function

Smoothing is fundamentally a lowpass operation in the
frequency domain.
There are several standard forms of lowpass filters (LPF).
Ideal lowpass filter
Butterworth lowpass filter
Gaussian lowpass filter
) , ( ) , ( ) , ( v u F v u H v u G =
The simplest lowpass filter is a filter that cuts off all high-
frequency components of the Fourier transform that are at a
distance greater than a specified distance D
0
from the origin of
the transform.
The transfer function of an ideal lowpass filter


where D(u,v) : the distance from point (u,v) to the center of
ther frequency rectangle (M/2, N/2)

| |
2
1
2 2
) 2 / ( ) 2 / ( ) , ( N v M u v u D + =
42
Ideal Lowpass Filters (ILPFs)

>
s
=
) , ( if 0
) , ( if 1
) , (
0
0
D v u D
D v u D
v u H
43
cutoff frequency
ILPF is a type of nonphysical filters and cant be realized with electronic
components and is not very practical.
44
Specified amount of total power in circle

M-1 N-1
Pt = P(u,v)
u=0 v=0

If DFT has been centered , a cicle of radius D0 with origin
at the center of the frequency rectngle encloses percent
of the power where

= 100[ P(u,v)/Pt]
u v




45
46
The blurring and ringing
phenomena can be seen, in
which ringing behavior is
characteristic of ideal filters.
47
Another example of
ILPF
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.
frequency
spatial
spatial
spatial
) , ( ) , ( ) , ( ) , ( v u H v u F y x h y x f -
Notation: the radius of center
component and the number of
circles per unit distance from
the origin are inversely
proportional to the value of the
cutoff frequency.
diagonal scan line of (d)
48
| |
n
D v u D
v u H
2
0
/ ) , ( 1
1
) , (
+
=
Butterworth Lowpass Filters (BLPFs) with order n
Note the relationship
between order n and
smoothing
The BLPF may be viewed as a transition between ILPF AND GLPF, BLPF of
order 2 is a good compromise between effective lowpass filtering and
acceptable ringing characteristics.
49
Butterworth Lowpass
Filters (BLPFs)


n=2
D
0
=5,15,30,80,and 230
50
Butterworth Lowpass Filters (BLPFs)
Spatial Representation
n=1
n=2 n=5
n=20
51
Gaussian Lowpass Filters (GLPFs)
GLPF in 2-D is given by

H (u,v) = e ^( -D(u,v) / 20 )

Where D(u,v) = distance from the center of the
frequency rectangle.

is the measure of spread about the center. By
letting = D0 , we get the notation as




52
2
0
2
2 / ) , (
) , (
D v u D
e v u H

=
53
Gaussian Lowpass
Filters (FLPFs)


D
0
=5,15,30,80,and 230
54
Additional Examples of Lowpass Filtering
Character recognition in machine perception: join the broken character
segments with a Gaussian lowpass filter with D
0
=80.
55
Application in cosmetic processing and produce a smoother,
softer-looking result from a sharp original.
56
Gaussian lowpass filter for reducing the horizontal sensor scan lines and
simplifying the detection of features like the interface boundaries.
Sharpening Frequency Domain Filter
57
( , ) 1 ( , )
hp lp
H u v H u v =
Ideal highpass filter
Butterworth highpass filter
Gaussian highpass filter

>
s
=
) , ( if 1
) , ( if 0
) , (
0
0
D v u D
D v u D
v u H
| |
n
v u D D
v u H
2
0
) , ( / 1
1
) , (
+
=
2
0
2
2 / ) , (
1 ) , (
D v u D
e v u H

=
58
Highpass Filters Spatial Representations
59
Ideal Highpass Filters (IHPFs)

>
s
=
) , ( if 1
) , ( if 0
) , (
0
0
D v u D
D v u D
v u H
non-physically realizable with electronic component and have the
same ringing properties as ILPFs.
60
Butterworth Highpass Filters
| |
n
v u D D
v u H
2
0
) , ( / 1
1
) , (
+
=
The result is smoother than that of IHPFs and sharper than that of GHPFs
61
Gaussian Highpass Filters
2
0
2
2 / ) , (
1 ) , (
D v u D
e v u H

=
The result is the smoothest in three types of high-pass filters
2 2
2 2 2 2 2
2 2
( , ) ( , )
[ ( , )] [ ] ( ) ( , ) ( ) ( , ) ( ) ( , )
f x y f x y
f x y ju F u v jv F u v u v F u v
x y
c c
V = + = + = +
c c
2 2 2
( , ) ( / 2) ( / 2) ( , ) f x y u M v N F u v ( V +

62
The Laplacian in the Frequency Domain
) ( ) , (
2 2
v u v u H + =
2 2
( , ) ( / 2) ( / 2) H u v u M v N ( = +

The FT of n-order differential of a function f(x) is
( ) / ( ) ( )
n n n
d f x dx ju F u ( =

For a two-dimensional function f(x,y), it can be shown that
So, Laplacian can be implemented in the frequency domain by using the filter
Shift the center to (M/2, N/2) and obtain
We have the following Fourier transform pairs
63
Frequency
domain
Spatial domain
The plot of Laplacian in frequency and spatial domain
64
2 1 2 2
( , ) ( , ) ( , ) 1 (( ) ( ) ) ( , )
2 2
M N
g x y f x y f x y u v F u v


(
= V = + +
`
(

)
For display
purposes only
A integrated operation
in frequency domain

65

Unsharp masking, high-boost filtering, and high-frequency emphasis
filtering (refers to page187-191)
Homomorphic filtering
66



Problems:
When the illumination radiating to an object is non-
uniform, the detail of the dark part in the image is
more discernable.
aims:
Simultaneously compress the gray-level range and
enhance contrast, eliminate the effect of non-uniform
illumination, and emphasis the details.
Principal:
Generally, the illumination component of an image is
characterized by slow spatial variations, while the
reflectance components tends to vary abruptly,
particularly at the junctions of dissimilar objects.
These characteristics lead to associating the low
frequencies of the Fourier transform of the logarithm
of an image with illumination and the high
frequencies with reflectance.

67
) , ( ) , ( ) , ( y x r y x i y x f =
The illumination-reflectance model of an image
) , ( y x i ) , ( y x r Illumination coefficient: reflectance coefficient:
Steps:
) , ( ln ) , ( ln ) , ( ln ) , ( y x r y x i y x f y x z + = =
)] , ( [ln )] , ( [ln )] , ( [ y x r y x i y x z F F F + =
) , ( ) , ( ) , ( v u R v u I v u Z + =
) , ( ) , ( ) , ( ) , ( ) , ( v u R v u H v u I v u H v u S + =
2)
1)
3)
Determine the H(u, v), which must compress the dynamic
range of i(x,y), and enhance the contrast of r(x,y) component.
2 2
0
( ( , )/ )
( , ) ( )[1 ]
c D u v D
H L L
H u v e

= +
68
r
L
<1
r
H
>1
The following function meet the above requires
The curve shape shown in above figure can be approximated using basic form
of the ideal highpass filters, for example, using a slightly modified form of the
Gaussian highpass filter and can obtain
69
)] , ( ) , ( [ ) , (
1 '
v u I v u H y x i

=F
)] , ( ) , ( [ ) , (
1 '
v u R v u H y x r

=F
)] , ( exp[ ) , (
'
0
y x i y x i =
)] , ( exp[ ) , (
'
0
y x r y x r =
) , ( ) , ( ) , (
0 0
y x r y x i y x g =
Steps: 4)
5)
70
ln FFT H(u,v)
FFT
-1

exp
f(x,y)
g(x,y)
The flow-chart of Homomorphic filtering
71
Two examples
72
4.6 Implementation
4.6.1Some Additional Properties of the 2D Fourier Transform
73
, distributivity, scaling, and :
0 0
0 0
2 ( / / )
0 0
2 ( / / )
0 0
( , ) ( , )
( , ) ( , )
j ux M vy N
j xu M yu N
f x x y y F u v e
f x y e F u u v v
t
t
+
+


1 2 1 2
[ ( , ) ( , )] [ ( , )] [ ( , )]
1
( , ) ( / , / )
f x y f x y f x y f x y
f ax by F u a v b
ab
+ = +

0 0
( , ) ( , ) f r F w u u u + +
Translation
Distributivity and
scaling
rotation
74
Periodicity, conjugate symmetry, and back-to-back properties
shift
( , ) ( , ) ( , ) ( , )
( , ) ( , ) ( , ) ( , )
( , ) ( , )
F u v F u M v F u v N F u M v N
f u v f u M v f u v N f u M v N
F u v F u v
-
= + = + = + +
= + = + = + +
=
Separability
75
1 1 1
2 / 2 / 2 /
0 0 0
1 1 1
( , ) ( , ) ( , )
M N M
j ux M j vy N j ux M
x y x
F u v e f x y e F x v e
M N M
t t t


= = =
= =

A similar process can be applied to computing the 2-D inverse Fourier
transform.
4.6.2 computing the inverse FF using a forward
transform algorithm
1 1
2 ( / / )
0 0
1 1
( , ) ( , )
M N
j ux M vy N
u v
f x y F u v e
MN MN
t

- - +
= =
=

76
Repeat the one-dimensional inverse FF:
1
2 /
0
( ) ( )
M
j ux M
u
f x F u e
t

=
=

Take the complex conjugate of two side and multiply M


1
2 /
0
1 1
( ) ( )
M
j ux M
u
f x F u e
M M
t

- -
=
=

Which is the form of forward FF. Take the complex conjugate of the result of
the above equation and will get the inverse FF by forward transform.
For two-dimensional case, similarly have
Here, we can treat F(u,v) as a simple function presenting on the forward
transform equation
77
4.6.3 More on Periodicity: the need for padding
1
0
( ) ( )
1
( ) ( )
M
m
f x h x
f m h x m
M

=
- =

Convolution process
Aliasing or wraparound error
78
extend
extend
The methods of solving the
aliasing problem is to
extend and pad.
( ) 0 1
( )
0 1
( ) 0 1
( )
0 1
where 1
e
e
f x x A
f x
A x P
h x x B
h x
B x P
P A+B
s s

s s

s s

s s

>
79
For two-dimensional case
80
An example
*
=
4.6.4 convolution and correlation theorems
1 1
0 0
1
( , ) ( , ) ( , ) ( , )
M N
m n
f x y h x y f m n h x m y n
MN

= =
- =

1 1
0 0
1
( , ) ( , ) ( , ) ( , )
M N
m n
f x y h x y f m n h x m y n
MN

-
= =
= + +

81
Except for the complex of f and h not mirrored about the origin, everything
else in the implementation of correlation is identical to convolution,
including the need for padding.
convolution
correlation
( , ) ( , ) ( , ) ( , )
( , ) ( , ) ( , ) ( , )
f x y h x y F u v H u v
f x y h x y F u v H u v
-
-
=
=
Correlation theorem
Correlation includes across- and auto-correlation, and its main use is for
matching and sure the location where h (template) finds a correspondence
in f.
82
83
4.6.5 Summary of Some Important Properties
of the 2-D Fourier Transform
84
85
86
Summary
The basic concept about Fourier Transform (FT)
The algorithm of FT and the process of frequency filtering
The physical meaning related to FT
The relationship of resolution between spatial and frequency domain
Correspondence between filtering in the spatial and frequency
domains
The general type of smoothing and sharpening filters and their main
features
Homomorphic filtering
Some important properties of FT
Convolution and correlation theorems
87
Spatial and frequency filtering are both highly subjective processes

88

89

90

91

92

93

94

S-ar putea să vă placă și