You are on page 1of 42

ImageEnhancement inFrequencyDomain

Prof. D. S. Pandya Computer Dept. U. V. Patel College of Engg. Mahesana

ImageEnhancementin FrequencyDomain F D i
ImageEnhancementinSpatialDomainvs. g p ImageEnhancementinFrequencyDomain FourierSeries Fourier Series FourierTransform

Background: Fourier Series

Fourier series: Any periodic signals can be yp g viewed as weighted sum of sinusoidal signals with different frequencies Frequency Domain: view frequency as an independent variable
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.

Fourier Tr. and Frequency Domain

Time, spatial Domain Signals

Fourier Tr. Inv Fourier Tr.

Frequency Domain Signals

1-D, Continuous case

Fourier Tr.: Inv. Fourier Tr.:

F (u ) = f ( x) =

f ( x )e

j 2ux

dx

F ( u )e

j 2ux

du

Fourier Tr. and Frequency Domain (cont.) 1 D, 1-D, Discrete case Fourier Tr.: Inv. Fourier Tr.:

1 F (u ) = M f ( x) =
M 1 u =0

M 1 x =0 =0

f ( x )e

j 2ux / M

u = 0,,M-1 x = 0,,M-1

F (u )e j 2ux / M

F(u) can be written as

F (u ) = R(u ) + jI (u )
where

or

F (u ) = F (u ) e j ( u )
I (u ) (u ) = tan R( ) (u
1

F (u ) = R (u ) + I (u )
2

Example of 1-D Fourier Transforms 1-

Notice that the longer the time domain signal, The shorter its Fourier transform

(Images from Rafael C. Gonzalez and Richard Wood, Digital Image Processing, 2nd Edition.

Relation Between x and u


For a signal f(x) with M points, let spatial resolution x be space between samples in f(x) and let frequency resolution u be space between frequencies components in F(u), we have

1 u = M Mx
Example: for a signal f(x) with sampling period 0.5 sec, 100 point we will get frequency resolution equal to

1 u = = 0.02 Hz 100 0.5


This means that in F(u) we can distinguish 2 frequencies that ar apart by 0.02 Hertz or more.

2-Dimensional Discrete Fourier Transform For an image of size MxN pixels 2-D DFT

1 F ( u, v ) = MN

M 1 N 1

x =0 y =0

f ( x, y )e j 2 ( ux / M + vy / N )

u = frequency in x direction, u = 0 ,, M-1 v = frequency in y direction, v = 0 ,, N-1

2-D IDFT

f ( x, y ) =

M 1 N 1 u =0 v =0

F (u, v )e

j 2 ( ux / M + vy / N )

x = 0 ,, M-1 y = 0 ,, N-1

2-Dimensional Discrete Fourier Transform (cont.) F(u,v) can be written as or F (u, v ) = F (u, v ) e j ( u ,v ) F ( u, v ) = R ( u, v ) + j ( u, v ) jI where

F ( u, v ) = R ( u, v ) + I ( u, v )
2

I (u, v ) (u, v ) = tan R ( u, v )


1

For the purpose of viewing, we usually display only the Magnitude part of F(u v) F(u,v)

Discrete Fourier Transform (cont.) DFT can be formulated as matrix operations DFTcanbeformulatedasmatrixoperations forconvenience.Itcanbevisualizedas WhereWiskernel,WN istheNth root

10

Discrete Fourier Transform (cont.)

TheinverseDFTcanbewrittenas

11

Discrete Fourier Transform (cont.) Example: Apply DFT to following sequence Example:ApplyDFTtofollowingsequence x={1289} Solution:N=4,hence S l i h

12

Impulses and shifting property A unit impulse of t located at t=0 denoted as Aunitimpulseoft,locatedatt=0denotedas (t)isdefinedas

Animpulsehassiftingpropertywithrespect tointegration,

13

Impulses and shifting property

14

Convolution Convolutionoftwofunctions

15

Convolution FT of the con ol tion of t o f nctions in the FToftheconvolutionoftwofunctionsinthe spatialdomainisequaltotheproductinthe frequencydomainofFTofthetwofunctions. frequency domain of FT of the two functions Conversely,convolutioninfrequencydomain isanalogoustomultiplicationinthespatial domain.

16

Example of 2-D DFT 2-

Notice that th l N ti th t the longer th ti the time d domain signal, i i l The shorter its Fourier transform
(Images from Rafael C. Gonzalez and Richard Wood, Digital Image Processing, 2nd Edition.

Example of 2-D DFT 2-

Notice that direction of an object in spatial image and Its Fourier transform are orthogonal to each other other.
(Images from Rafael C. Gonzalez and Richard Wood, Digital Image Processing, 2nd Edition.

Example of 2-D DFT 2-

2D DFT

Original image

2D FFT Shift

Example of 2-D DFT 2-

2D DFT

Original image

2D FFT Shift

Basic Concept of Filtering in the Frequency Domain


From Fourier Transform Property:

g ( x , y ) = f ( x , y ) h ( x , y ) F ( u, v ) H ( u, v ) = G ( u, v )
We cam perform filtering process by using

Multiplication in the frequency domain is easier than convolution in the spatial Domain.

(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.

Filtering in the Frequency Domain with FFT shift


F(u,v) H(u,v) (User defined) g(x,y)

FFT shift

2D IFFT

2D FFT

FFT shift

f(x,y)

G(u,v)

In this case, F(u,v) and H(u,v) must have the same size and have the zero frequency at the center.

Filtering in the Frequency Domain : Example


In this example we set F(0 0) to zero example, F(0,0) which means that the zero frequency component is removed.

Note: Zero frequency = average intensity of an image

(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.

Filtering in the Frequency Domain : Example

Lowpass Filter

Highpass Filter

(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.

Filter Masks and Their Fourier Transforms

(Images from Rafael C. Gonzalez and Richard Wood, Digital Image Processing, 2nd Edition.

Ideal Lowpass Filter


Ideal LPF Filter Transfer function

1 H (u, v ) = 0

D (u, v ) D0 D (u, v ) > D0

where D(u,v) = Distance from (u,v) to the center of the mask.

(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.

Examples of Ideal Lowpass Filters

( (Images from Rafael C. Gonzalez and Richard E. g Wood, Digital Image Processing, 2nd Edition.

The smaller D0, the more high frequency components are remov

Results of Ideal Lowpass Filters

Ringing effect can be obviously seen!

(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.

How ringing effect happens


1 H (u, v ) = 0 D (u, v ) D0 D (u, v ) > D0
Surface Plot
1 0.8 0.6

Ideal Lowpass Filter with D0 = 5

0.4 0.2 0 20 0 20 -20 0 -20

Abrupt change in the amplitude

How ringing effect happens (cont.)

Surface Plot
x 10
-3

15

Spatial Response of Ideal Lowpass Filter with D0 = 5 p

10 5 0

20

Ripples that cause ringing effect

20 -20 0 -20

How ringing effect happens (cont.)

(Images from Rafael C. Gonzalez and Richard Wood, Digital Image Processing, 2nd Edition.

Butterworth Lowpass Filter Transfer function


H ( u, v ) = 1 2N 1 + [D (u, v ) / D0 ]

Where D0 = Cut off frequency, N = filter order.

(Images from Rafael C. Gonzalez and Richard E. d Edition. Wood, Digital Image P W d Di it l I Processing, 2nd Editi i

Results of Butterworth Lowpass Filters

There is less ringing effect compared to those of ideal lowpass filters! filt !
(Images from Rafael C. Gonzalez and Richard Wood, Digital Image Processing, 2nd Edition.

GaussianLowPassFilter

34

GaussianLowPassFilter

35

Highpass Filters

Hhp = 1 - Hlp

(Images from Rafael C. Gonzalez and Richard Wood, Digital Image Processing, 2nd Edition.

HighPassFilters

37

IdealHighPassFilter

38

ButterworthHighPassFilter

39

GaussianHighPassFilter

40

Laplacian Filter in the Frequency Domain


From Fourier Tr. Property: d n f (x ) y (x n ( ju ) F (u ) dx n Then for Laplacian operator 2 f 2 f 2 f = 2 + 2 (u 2 + v 2 )F (u, v ) x y We get 2 (u 2 + v 2 )

Image of (u2+v2)

Surface plot

(Images from Rafael C. Gonzalez and Richard Wood, Digital Image Processing, 2nd Edition.

Laplacian Filter in the Frequency Domain (cont.)


Spatial response of (u2+v2)
Cross section

Laplacian mask in Chapter 3