digital image processing - sjtumin.sjtu.edu.cn/files/courses/dip16/lecture04.pdf · 2018-04-09 ·...

Post on 12-May-2020

5 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Digital Image Processing

Hongkai Xiong

熊红凯http://ivm.sjtu.edu.cn

电子工程系上海交通大学

2016

http://ivm.sjtu.edu.cn

Topic

• Simple review of Fourier transform

• Filtering in frequency domain

http://ivm.sjtu.edu.cn

Simple review of Fourier transform

http://ivm.sjtu.edu.cn

The Fourier Transform

• The Fourier transform converts a signal from spatial domain to the frequency domain.

• The Continuous Fourier Transform of a one-dimensional continuous function f(t) is defined as

f(t) F(s)Fourier

Transform

dtetfsFtf stj 2)()()}({F

http://ivm.sjtu.edu.cn

• The inverse Fourier transform

dsesFsF stj 21 )()}({F

F(s) f(t)Inverse Fourier

Transform

http://ivm.sjtu.edu.cn

• If is a sequence of length N, then its discrete Fourier transform (DFT) is given by

• And the inverse DFT is given by

Where are indices.

1 2

0

1, 0,1, 1

nN j iN

n i

i

F f e n NN

1 2

0

, 0,1, , 1iN j nN

i n

n

f F e i N

}{ if

1,0 Nni

The Discrete Fourier Transform

http://ivm.sjtu.edu.cn

Properties of the Fourier Transform

• The Addition Theorem

▫ If and , then

▫ And take it as an axiom that for any real number c

▫ This implies that Fourier transform is a linear transform.

)()}({ sFtf F )()}({ sGtg F

)()()}()({ sGsFtgtf F

)()}({ scFtcf F

http://ivm.sjtu.edu.cn

The Addition Theorem

• Addition-5 0 5

0

2

4

f(t)

-2 -1 0 1 2

-200

0

200

F(s

)

-5 0 50

2

4

g(t

)

-2 -1 0 1 2

-200

0

200

G(s

)

-5 0 50

2

4

6

f(t)

+g

(t)

-2 -1 0 1 2

-200

0

200F

(s)+

G(s

)

http://ivm.sjtu.edu.cn

The Shift Theorem

• Time shift:

• Frequency shift:

When ,

)()}({ 2 sFeatf asj F

02 /

0{ ( ) } ( )j s t N

f t e F s s

F

0 / 2s N

{ ( )( 1) } ( / 2)tf t F s N Fback

http://ivm.sjtu.edu.cn

The Convolution Theorem

• The Fourier transform of the convolution of two functions is the product of the Fourier transforms of these two functions

)()()}()({ sGsFtgtf F

http://ivm.sjtu.edu.cn

The Two-Dimensional DFT

• The discrete Fourier transform of an image of size M*N is given by

• Inverse Fourier transform

1 1

2

0 0

1, ,

M Nj ux M vy N

x y

F u v f x y eMN

1 1

2

0 0

, ,M N

j ux M vy N

u v

f x y F u v e

http://ivm.sjtu.edu.cn

http://ivm.sjtu.edu.cn

• Fourier spectrum

• Phase angle

• Power spectrum

where R(u, v) and I(u, v) are the real and imaginary parts of F(u, v), respectively

2 2, , ,F u v R u v I u v

-1

,, tan

,

I u vu v

R u v

2

2 2

, ,

, ,

P u v F u v

R u v I u v

http://ivm.sjtu.edu.cn

• For display, it is common practice to shift the original point to the center (M/2, N/2). According to the shift theorem, we need to multiply the input image function by (-1)x+y

prior to computing the Fourier transform.:

, 1 ( / 2, / 2)x y

f x y F u M v N

http://ivm.sjtu.edu.cn

• What’s the value of the transform at (u, v)=(0, 0)?

• The average of f(x, y).

1 1

0 0

10,0 ,

M N

x y

F f x yMN

http://ivm.sjtu.edu.cn

A simple example

http://ivm.sjtu.edu.cn

Translation and Rotation

http://ivm.sjtu.edu.cn

The 2-D Convolution Theorem

• 2-D circular convolution

• The 2-D convolution theorem is given by

and, conversely,

1 1

0 0

, , ,,M N

m n

h x y f m n h x m y nf x y

, ,, ,h x y F uf y vx v H u

, ,, ,h x y F u vf y vx H u

http://ivm.sjtu.edu.cn

2D convolution theorem example

*

f(x,y)

h(x,y)

g(x,y)

|F(sx,sy)|

|H(sx,sy)|

|G(sx,sy)|

http://ivm.sjtu.edu.cn

Curious Things about FT on Images

Example:cheetah pic

http://ivm.sjtu.edu.cn

Curious Things about FT on Images

This is the magnitude transform of the cheetah pic

http://ivm.sjtu.edu.cn

Curious Things about FT on Images

This is the phase transform of the cheetah pic

http://ivm.sjtu.edu.cn

Curious Things about FT on Images

Example:zebra pic

http://ivm.sjtu.edu.cn

Curious Things about FT on Images

This is the magnitude transform of the zebra pic

http://ivm.sjtu.edu.cn

Curious Things about FT on Images

This is the phase transform of the zebra pic

http://ivm.sjtu.edu.cn

Curious Things about FT on Images

Reconstruction with zebra phase, cheetah magnitude

http://ivm.sjtu.edu.cn

Curious Things about FT on Images

Reconstruction with cheetah phase, zebra magnitude

http://ivm.sjtu.edu.cn

Filtering in frequency domain

http://ivm.sjtu.edu.cn

http://ivm.sjtu.edu.cn

Steps for filtering in frequency domain

1) Multiply the input image by (-1)x+y to center the transform

2) Zero padding in case of aliasing

3) Compute F(u, v), the DFT of the image from (2)

4) Multiply F(u, v) by a filter function H(u, v)

5) Compute the inverse DFT of the result in (4)

6) Obtain the real part of the result in (5)

7) Multiply the result in (6) by (-1)x+y

8) Crop the image

http://ivm.sjtu.edu.cn

Correspondence Between Filtering in the

Spatial and Frequency Domains

• h(x, y) is a spatial filter, and can be obtained from the response of a frequency domain filter to an impulse.

• h(x, y) sometimes is referred to as the impulse response of H(u, v)

http://ivm.sjtu.edu.cn

Gaussian low-pass filter and high-pass filter in

the frequency and spatial domain

http://ivm.sjtu.edu.cn

A Gaussian kernel gives less weight to pixels further from the center of the window

This kernel is an approximation of a Gaussian function:

0 0 0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0 0

0 0 0 90 90 90 90 90 0 0

0 0 0 90 90 90 90 90 0 0

0 0 0 90 90 90 90 90 0 0

0 0 0 90 0 90 90 90 0 0

0 0 0 90 90 90 90 90 0 0

0 0 0 0 0 0 0 0 0 0

0 0 90 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0 0

1 2 1

2 4 2

1 2 1

Correspondence Between Filtering in the

Spatial and Frequency Domains

http://ivm.sjtu.edu.cn

Correspondence Between Filtering in the

Spatial and Frequency Domains

http://ivm.sjtu.edu.cn

Correspondence Between Filtering in the

Spatial and Frequency Domains

http://ivm.sjtu.edu.cn

Image Smoothing

• Ideal low-pass filters

0

0

1 if ,,

0 if ,

D u v DH u v

D u v D

http://ivm.sjtu.edu.cn

• Ideal low-pass filters

0

0

1 if ,,

0 if ,

D u v DH u v

D u v D

Image Smoothing

http://ivm.sjtu.edu.cn

• Ideal low-pass filters

Image Smoothing

http://ivm.sjtu.edu.cn

• Butterworth low-pass filters

2

0

1,

1 ,n

H u vD u v D

Image Smoothing

http://ivm.sjtu.edu.cn

• Butterworth low-pass filters

2

0

1,

1 ,n

H u vD u v D

Image Smoothing

http://ivm.sjtu.edu.cn

http://ivm.sjtu.edu.cn

• Gaussian low-pass filters

2 2, 2,

D u vH u v e

Image Smoothing

http://ivm.sjtu.edu.cn

http://ivm.sjtu.edu.cn

• Gaussian low-pass filters

Image Smoothing

http://ivm.sjtu.edu.cn

Image Sharpening

• A high-pass filter is obtained from a given low-pass filter

, 1 ,HP LPH u v H u v

http://ivm.sjtu.edu.cn

Image Sharpening

http://ivm.sjtu.edu.cn

Image Sharpening

http://ivm.sjtu.edu.cn

• Ideal high-pass filters

0

0

0 if ,,

1 if ,

D u v DH u v

D u v D

Image Sharpening

http://ivm.sjtu.edu.cn

• Butterworth high-pass filters

2

0

1,

1 ,n

H u vD D u v

Image Sharpening

http://ivm.sjtu.edu.cn

• Gaussian high-pass filters

,,

2 2D u v 2H u v 1 e

Image Sharpening

http://ivm.sjtu.edu.cn

• The Laplacian in the frequency domain

, 2 2 2H u v 4 u v

, , ,12 H uf v F vx y u

Image Sharpening

http://ivm.sjtu.edu.cn

Sharpening Spatial Filters

• The Laplacian

▫ Laplacian operator

▫ X-direction

▫ Y-direction

2 22

2 2

f ff

x y

2

2

ff x 1, y f x 1, y 2 f x, y

x

2

2

ff x, y 1 f x, y 1 2 f x, y

y

http://ivm.sjtu.edu.cn

Sharpening Spatial Filters

• The discrete Laplacian of two variables

2 f x, y f x 1, y f x 1, y f x, y 1 f x, y 1 4 f x, y

http://ivm.sjtu.edu.cn

• Enhancement is achieved using the equation

• In frequency domain

, , ,

, ,

,

,

,

1

1

1 2 2

F u v H u v F u v

1 H u v F u v

1 4 D u v F

g

u

x y

v

2g x, y f x, y c f x, y

Image Sharpening

http://ivm.sjtu.edu.cn

• High-boost filtering

▫ Spatial domain:

▫ Frequency domain

, , ,1

LPLP H u v F uf x y v

mask LPg x, y f x, y f x, y

Image Sharpening

maskg x, y f x, y k g x, y

* ,, ,1

LP1 k 1 H u v ug vx Fy

http://ivm.sjtu.edu.cn

• High-frequency-emphasis filtering:

* ,, ,1

HPg 1 k H u vx u vy F

Image Sharpening

http://ivm.sjtu.edu.cn

• A slightly more general formulation of high-frequency-emphasis filtering

* ,, ,1

1 2 HPk k H ug x y v F u v

Image Sharpening

http://ivm.sjtu.edu.cn

Take another look

Important things are to be repeated

for 3 times !

http://ivm.sjtu.edu.cn

Homework One

Page327: problem 4.8(b), 4.22, 4.28, 4.33, 4.35

http://ivm.sjtu.edu.cn

Thank You!

top related