h.r. pourreza digital image processing بسمهتعالي h.r. pourreza image enhancement in the...

65
H.R. Pourreza Digital Image Processing يH.R. Pourreza Image Enhancement in the Frequency Domain (Chapter 4)

Upload: corey-hunt

Post on 19-Dec-2015

283 views

Category:

Documents


5 download

TRANSCRIPT

Page 1: H.R. Pourreza Digital Image Processing بسمهتعالي H.R. Pourreza Image Enhancement in the Frequency Domain (Chapter 4)

H.R. Pourreza

Digital Image Processing

بسمه تعالي

H.R. Pourreza

Image Enhancement in the Frequency Domain

(Chapter 4)

Page 2: H.R. Pourreza Digital Image Processing بسمهتعالي H.R. Pourreza Image Enhancement in the Frequency Domain (Chapter 4)

H.R. Pourreza

• Basic understanding of the frequency domain, Fourier series, and Fourier transform. • Image enhancement in the frequency domain.

Objective

Page 3: H.R. Pourreza Digital Image Processing بسمهتعالي H.R. Pourreza Image Enhancement in the Frequency Domain (Chapter 4)

H.R. Pourreza

Any function that periodically repeats itself can be expressedas the sum of sines and/or cosines of different frequencies, each multiplied by a different coefficients.This sum is called a Fourierseries.

Fourier Series

Page 4: H.R. Pourreza Digital Image Processing بسمهتعالي H.R. Pourreza Image Enhancement in the Frequency Domain (Chapter 4)

H.R. Pourreza

00

0

00

0

00

0

00

00

00

1000

sin)(2

cos)(2

)(1

sincos)(

Tt

t

n

Tt

t

n

Tt

t

nnn

dttnwtgT

b

dttnwtgT

a

dttgT

a

tnwbtnwaatg

Fourier Series

Page 5: H.R. Pourreza Digital Image Processing بسمهتعالي H.R. Pourreza Image Enhancement in the Frequency Domain (Chapter 4)

H.R. Pourreza

A function that is not periodic but the area under its curve is finite can be expressed as the integral of sines and/or cosines multiplied by a weighing function. The formulation in this case is Fourier transform.

Fourier Transform

Page 6: H.R. Pourreza Digital Image Processing بسمهتعالي H.R. Pourreza Image Enhancement in the Frequency Domain (Chapter 4)

H.R. Pourreza

dueuFxf

dxexfuF

uxj

uxj

2

2

)()(

)()(

Continuous One-Dimensional Fourier Transform and Its Inverse

Where 1j

• (u) is the frequency variable.• F(u) is composed of an infinite sum of

sine and cosine terms and…• Each value of u determines the

frequency of its corresponding sine-cosine pair.

Page 7: H.R. Pourreza Digital Image Processing بسمهتعالي H.R. Pourreza Image Enhancement in the Frequency Domain (Chapter 4)

H.R. Pourreza

2

10

2

11

)(x

xx

2 sinc )(

uuF

0.5- 0.5x

2

4

u

Continuous One-Dimensional Fourier Transform and Its Inverse

ExampleFind the Fourier transform of a gate function (t) defined by

Page 8: H.R. Pourreza Digital Image Processing بسمهتعالي H.R. Pourreza Image Enhancement in the Frequency Domain (Chapter 4)

H.R. Pourreza

Continuous One-Dimensional Fourier Transform and Its Inverse

Page 9: H.R. Pourreza Digital Image Processing بسمهتعالي H.R. Pourreza Image Enhancement in the Frequency Domain (Chapter 4)

H.R. Pourreza

Discrete One-Dimensional Fourier Transform and Its Inverse

• A continuous function f(x) is discretized into a sequence:

)}]1[(),...,2(),(),({ 0000 xNxfxxfxxfxf

by taking N or M samples x units apart.

Page 10: H.R. Pourreza Digital Image Processing بسمهتعالي H.R. Pourreza Image Enhancement in the Frequency Domain (Chapter 4)

H.R. Pourreza

Discrete One-Dimensional Fourier Transform and Its Inverse

• Where x assumes the discrete values (0,1,2,3,…,M-1) then

)()( 0 xxxfxf

• The sequence {f(0),f(1),f(2),…f(M-1)} denotes any M uniformly spaced samples from a corresponding continuous function.

Page 11: H.R. Pourreza Digital Image Processing بسمهتعالي H.R. Pourreza Image Enhancement in the Frequency Domain (Chapter 4)

H.R. Pourreza

1

0

1

0

2

2sin2cos)(1

)(

)(1

)(

M

x

M

x

M

xuj

M

xuj

M

xuxf

MuF

exfM

uF

1

0

2)()(

M

u

xM

uj

euFxf

u =[0,1,2, …, M-1]

x =[0,1,2, …, M-1]

Discrete One-Dimensional Fourier Transform and Its Inverse

Page 12: H.R. Pourreza Digital Image Processing بسمهتعالي H.R. Pourreza Image Enhancement in the Frequency Domain (Chapter 4)

H.R. Pourreza

Discrete One-Dimensional Fourier Transform and Its Inverse

• The values u = 0, 1, 2, …, M-1 correspond to samples of the continuous transform at values 0, u, 2u, …, (M-1)u.

i.e. F(u) represents F(uu), where:

u 1

Mx

• Each term of the FT (F(u) for every u) is composed of the sum of all values of f(x)

Page 13: H.R. Pourreza Digital Image Processing بسمهتعالي H.R. Pourreza Image Enhancement in the Frequency Domain (Chapter 4)

H.R. Pourreza

Discrete One-Dimensional Fourier Transform and Its Inverse

• The Fourier transform of a real function is generally complex and we use polar coordinates:

)(

)(tan)(

)]()([)(

)()(

)()()(

1

2/122

)(

uR

uIu

uIuRuF

euFuF

ujIuRuFuj

Page 14: H.R. Pourreza Digital Image Processing بسمهتعالي H.R. Pourreza Image Enhancement in the Frequency Domain (Chapter 4)

H.R. Pourreza

|F(u)| (magnitude function) is the Fourier spectrum of f(x) and (u) its phase angle.

• The square of the spectrum

)()()()( 222uIuRuFuP

is referred to as the Power Spectrum of f(x) (spectral density).

Discrete One-Dimensional Fourier Transform and Its Inverse

Page 15: H.R. Pourreza Digital Image Processing بسمهتعالي H.R. Pourreza Image Enhancement in the Frequency Domain (Chapter 4)

H.R. Pourreza

• Fourier spectrum: 2/122 ),(),(),( vuIvuRvuF

• Phase:

),(

),(tan),( 1

vuR

vuIvu

• Power spectrum:

),(),(),(),( 222vuIvuRvuFvuP

Discrete 2-Dimensional Fourier Transform

Page 16: H.R. Pourreza Digital Image Processing بسمهتعالي H.R. Pourreza Image Enhancement in the Frequency Domain (Chapter 4)

H.R. Pourreza

Discrete One-Dimensional Fourier Transform and Its Inverse

Page 17: H.R. Pourreza Digital Image Processing بسمهتعالي H.R. Pourreza Image Enhancement in the Frequency Domain (Chapter 4)

H.R. Pourreza 1 second

Fmax = 100 HzWhat is the sampling rate (Nyquist)?What is the time resolution?What is the frequency resolution?What if the sampling rate is higher than the Nyquist sampling rate?What if we take samples for twoseconds with the Nyquist samplingrate?

Time and Frequency Resolution and Sampling

Page 18: H.R. Pourreza Digital Image Processing بسمهتعالي H.R. Pourreza Image Enhancement in the Frequency Domain (Chapter 4)

H.R. Pourreza

2/122

1

0

1

0

)(2

1

0

1

0

)(2

),(),(),(

),(),(

),(1

),(

vuIvuRvuF

evuFyxf

eyxfMN

vuF

M

u

N

v

yN

vx

M

uj

M

x

N

y

N

yv

M

xuj

Fourier Spectrum

Discrete Two-Dimensional Fourier Transform and Its Inverse

Page 19: H.R. Pourreza Digital Image Processing بسمهتعالي H.R. Pourreza Image Enhancement in the Frequency Domain (Chapter 4)

H.R. Pourreza

1

0

1

0

),(1

)0,0(M

x

N

y

yxfMN

F

F(0,0) is the average intensity of an image

Discrete Two-Dimensional Fourier Transform and Its Inverse

Page 20: H.R. Pourreza Digital Image Processing بسمهتعالي H.R. Pourreza Image Enhancement in the Frequency Domain (Chapter 4)

H.R. Pourreza

Use Matlab to generate the above figures

Discrete Two-Dimensional Fourier Transform and Its Inverse

Page 21: H.R. Pourreza Digital Image Processing بسمهتعالي H.R. Pourreza Image Enhancement in the Frequency Domain (Chapter 4)

H.R. Pourreza

),(),(

)()(

then

)()(

If

00

)(2

0

00

0

vvuuFeyxf

Getg

Gtg

N

yv

M

xuj

tj

Frequency Shifting Property of the Fourier Transform

Page 22: H.R. Pourreza Digital Image Processing بسمهتعالي H.R. Pourreza Image Enhancement in the Frequency Domain (Chapter 4)

H.R. Pourreza

Frequency Shifting Property of the Fourier Transform

Page 23: H.R. Pourreza Digital Image Processing بسمهتعالي H.R. Pourreza Image Enhancement in the Frequency Domain (Chapter 4)

H.R. Pourreza

function Normalized_DFT = Img_DFT(img)img=double(img); % So mathematical operations can be conducted on % the image pixels.[R,C]=size(img);for r = 1:R % To phase shift the image so the DFT will be for c=1:C % centered on the display monitor phased_img(r,c)=(img(r,c))*(-1)^((r-1)+(c-1)); endendfourier_img = fft2(phased_img); %Discrete Fourier Transformmag_fourier_img = abs(fourier_img ); % Magnitude of DFTLog_mag_fourier_img = log10(mag_fourier_img +1);Max = max(max(Log_mag_fourier_img ));Normalized_DFT = (Log_ mag_fourier_img )*(255/Max);imshow(uint8(Normalized_DFT))

Basic Filtering in the Frequency Domain using Matlab

Page 24: H.R. Pourreza Digital Image Processing بسمهتعالي H.R. Pourreza Image Enhancement in the Frequency Domain (Chapter 4)

H.R. Pourreza

1. Multiply the input image by (-1)x+y to center the transform2. Compute F(u,v), the DFT of the image from (1)3. Multiply F(u,v) by a filter function H(u,v)4. Compute the inverse DFT of the result in (3)5. Obtain the real part of the result in (4)6. Multiply the result in (5) by (-1)x+y

Basic Filtering in the Frequency Domain

Page 25: H.R. Pourreza Digital Image Processing بسمهتعالي H.R. Pourreza Image Enhancement in the Frequency Domain (Chapter 4)

H.R. Pourreza

Filtering out the DC Frequency Component

Page 26: H.R. Pourreza Digital Image Processing بسمهتعالي H.R. Pourreza Image Enhancement in the Frequency Domain (Chapter 4)

H.R. Pourreza

1

)2/,2/(),( if 0),(

NMvuvuH

otherwise

Notch Filter

Filtering out the DC Frequency Component

Page 27: H.R. Pourreza Digital Image Processing بسمهتعالي H.R. Pourreza Image Enhancement in the Frequency Domain (Chapter 4)

H.R. Pourreza

Low Pass Filter attenuate high frequencies while “passing” low frequencies.

High Pass Filter attenuate low frequencies while “passing” high frequencies.

Low-pass and High-pass Filters

Page 28: H.R. Pourreza Digital Image Processing بسمهتعالي H.R. Pourreza Image Enhancement in the Frequency Domain (Chapter 4)

H.R. Pourreza

Low-pass and High-pass Filters

Page 29: H.R. Pourreza Digital Image Processing بسمهتعالي H.R. Pourreza Image Enhancement in the Frequency Domain (Chapter 4)

H.R. Pourreza

Low-pass and High-pass Filters

Page 30: H.R. Pourreza Digital Image Processing بسمهتعالي H.R. Pourreza Image Enhancement in the Frequency Domain (Chapter 4)

H.R. Pourreza

Low-pass and High-pass Filters

Page 31: H.R. Pourreza Digital Image Processing بسمهتعالي H.R. Pourreza Image Enhancement in the Frequency Domain (Chapter 4)

H.R. Pourreza

2/122

0

0

)2/()2/(),(

),( if 0

),( if 1),(

NvMuvuD

DvuD

DvuDvuH

Smoothing Frequency Domain, Ideal Low-pass Filters

Page 32: H.R. Pourreza Digital Image Processing بسمهتعالي H.R. Pourreza Image Enhancement in the Frequency Domain (Chapter 4)

H.R. Pourreza

u vT

M

u

N

vT

PvuF

vuFP

/),(100

),(1

0

1

0

2

Total Power

The remained percentage power after filtration

Smoothing Frequency Domain, Ideal Low-pass Filters

Page 33: H.R. Pourreza Digital Image Processing بسمهتعالي H.R. Pourreza Image Enhancement in the Frequency Domain (Chapter 4)

H.R. Pourreza

fc =5 = 92%

fc =15 = 94.6%

fc =30 = 96.4%

fc =80 = 98%

fc =230 = 99.5%

Smoothing Frequency Domain, Ideal Low-pass Filters

Page 34: H.R. Pourreza Digital Image Processing بسمهتعالي H.R. Pourreza Image Enhancement in the Frequency Domain (Chapter 4)

H.R. Pourreza

Cause of Ringing

Page 35: H.R. Pourreza Digital Image Processing بسمهتعالي H.R. Pourreza Image Enhancement in the Frequency Domain (Chapter 4)

H.R. Pourreza

Implement in Matlab the Ideal low-pass filter in the following equation.

1. You must give the user the ability to specify the cutoff frequency D0

2. Calculate the The remained percentage power after filtration.

3. Display the image after filtration4. Use Elaine image to test your program

2/122

0

0

)2/()2/(),(

),( if 0

),( if 1),(

NvMuvuD

DvuD

DvuDvuH

Project #5, Ideal Low-pass Filter

Page 36: H.R. Pourreza Digital Image Processing بسمهتعالي H.R. Pourreza Image Enhancement in the Frequency Domain (Chapter 4)

H.R. Pourreza

nDvuDvuH

20/),(1

1),(

Smoothing Frequency Domain, Butterworth Low-pass Filters

Page 37: H.R. Pourreza Digital Image Processing بسمهتعالي H.R. Pourreza Image Enhancement in the Frequency Domain (Chapter 4)

H.R. Pourreza

Smoothing Frequency Domain, Butterworth Low-pass Filters

Radii= 5

Radii= 15 Radii=

30

Radii= 80

Radii= 230

Butterworth Low-pass Filter: n=2

Page 38: H.R. Pourreza Digital Image Processing بسمهتعالي H.R. Pourreza Image Enhancement in the Frequency Domain (Chapter 4)

H.R. Pourreza

Smoothing Frequency Domain, Butterworth Low-pass Filters

Page 39: H.R. Pourreza Digital Image Processing بسمهتعالي H.R. Pourreza Image Enhancement in the Frequency Domain (Chapter 4)

H.R. Pourreza

20

2 2/),(),( DvuDevuH

Smoothing Frequency Domain, Gaussian Low-pass Filters

Page 40: H.R. Pourreza Digital Image Processing بسمهتعالي H.R. Pourreza Image Enhancement in the Frequency Domain (Chapter 4)

H.R. Pourreza

Radii= 5

Radii= 15 Radii=

30

Radii= 80

Radii= 230

Gaussian Low-pass

Smoothing Frequency Domain, Gaussian Low-pass Filters

Page 41: H.R. Pourreza Digital Image Processing بسمهتعالي H.R. Pourreza Image Enhancement in the Frequency Domain (Chapter 4)

H.R. Pourreza

Smoothing Frequency Domain, Gaussian Low-pass Filters

Page 42: H.R. Pourreza Digital Image Processing بسمهتعالي H.R. Pourreza Image Enhancement in the Frequency Domain (Chapter 4)

H.R. Pourreza

Smoothing Frequency Domain, Gaussian Low-pass Filters

Page 43: H.R. Pourreza Digital Image Processing بسمهتعالي H.R. Pourreza Image Enhancement in the Frequency Domain (Chapter 4)

H.R. Pourreza

Smoothing Frequency Domain, Gaussian Low-pass Filters

Page 44: H.R. Pourreza Digital Image Processing بسمهتعالي H.R. Pourreza Image Enhancement in the Frequency Domain (Chapter 4)

H.R. Pourreza

Hhp(u,v) = 1 - Hlp(u,v)

Sharpening Frequency Domain Filters

Page 45: H.R. Pourreza Digital Image Processing بسمهتعالي H.R. Pourreza Image Enhancement in the Frequency Domain (Chapter 4)

H.R. Pourreza

Sharpening Frequency Domain Filters

Page 46: H.R. Pourreza Digital Image Processing بسمهتعالي H.R. Pourreza Image Enhancement in the Frequency Domain (Chapter 4)

H.R. Pourreza

),( if 1

),( if 0),(

0

0

DvuD

DvuDvuH

Sharpening Frequency Domain, Ideal High-pass Filters

Page 47: H.R. Pourreza Digital Image Processing بسمهتعالي H.R. Pourreza Image Enhancement in the Frequency Domain (Chapter 4)

H.R. Pourreza

nvuDDvuH

20 ),(/1

1),(

Sharpening Frequency Domain, Butterworth High-pass Filters

Page 48: H.R. Pourreza Digital Image Processing بسمهتعالي H.R. Pourreza Image Enhancement in the Frequency Domain (Chapter 4)

H.R. Pourreza

20

2 2/),(1),( DvuDevuH

Sharpening Frequency Domain, Gaussian High-pass Filters

Page 49: H.R. Pourreza Digital Image Processing بسمهتعالي H.R. Pourreza Image Enhancement in the Frequency Domain (Chapter 4)

H.R. Pourreza

Homomorphic Filtering

Page 50: H.R. Pourreza Digital Image Processing بسمهتعالي H.R. Pourreza Image Enhancement in the Frequency Domain (Chapter 4)

H.R. Pourreza

Homomorphic Filtering

Page 51: H.R. Pourreza Digital Image Processing بسمهتعالي H.R. Pourreza Image Enhancement in the Frequency Domain (Chapter 4)

H.R. Pourreza

g t k t h tM

k t m h mm

M

( ) ( ) * ( ) ( ) ( )

1

0

1

h(t) g(t)k(t) g(t) = k(t)*h(t)G(f) = K(f)H(f)

-1

1

t

h(t)

12

3

t

k(t)

1 2 3

* is a convolution operator and not multiplication

Convolution

Page 52: H.R. Pourreza Digital Image Processing بسمهتعالي H.R. Pourreza Image Enhancement in the Frequency Domain (Chapter 4)

H.R. Pourreza

gM

k m h mm

M

( ) ( ) ( )01

00

1

m

k(-m)

-1

1

m

h(m)

g(t)

Convolution

Page 53: H.R. Pourreza Digital Image Processing بسمهتعالي H.R. Pourreza Image Enhancement in the Frequency Domain (Chapter 4)

H.R. Pourreza

-1

1

m

h(m)

Convolution

m

k(1-m)

g(t)

Page 54: H.R. Pourreza Digital Image Processing بسمهتعالي H.R. Pourreza Image Enhancement in the Frequency Domain (Chapter 4)

H.R. Pourreza

-1

1

m

h(m)

Convolution

m

k(2-m)

g(t)

Page 55: H.R. Pourreza Digital Image Processing بسمهتعالي H.R. Pourreza Image Enhancement in the Frequency Domain (Chapter 4)

H.R. Pourreza

-1

1

m

h(m)

Convolution

m

k(3-m)

g(t)

Page 56: H.R. Pourreza Digital Image Processing بسمهتعالي H.R. Pourreza Image Enhancement in the Frequency Domain (Chapter 4)

H.R. Pourreza

-1

1

m

h(m)

Convolution

m

k(4-m)

g(t)

Page 57: H.R. Pourreza Digital Image Processing بسمهتعالي H.R. Pourreza Image Enhancement in the Frequency Domain (Chapter 4)

H.R. Pourreza

-1

1

m

h(m)

Convolution

m

k(5-m)

g(t)

Page 58: H.R. Pourreza Digital Image Processing بسمهتعالي H.R. Pourreza Image Enhancement in the Frequency Domain (Chapter 4)

H.R. Pourreza

-1

1

m

h(m)

Convolution

m

k(6-m)

g(t)

Page 59: H.R. Pourreza Digital Image Processing بسمهتعالي H.R. Pourreza Image Enhancement in the Frequency Domain (Chapter 4)

H.R. Pourreza

f x y h x yMN

f m n h x m y nn

N

m

M

( , ) ( , ) ( , ) ( , )

1

0

1

0

1

2-Dimensions Convolution

Page 60: H.R. Pourreza Digital Image Processing بسمهتعالي H.R. Pourreza Image Enhancement in the Frequency Domain (Chapter 4)

H.R. Pourreza

g t k t h tM

k t m h mm

M

( ) ( ) ( ) ( ) ( )

1

0

1

h(t) g(t)k(t)g(t) = k(t)h(t)G(f) = K(f)* . H(f)

-1

1 1

2

t t

k(t)h(t)

g(t)

2

Correlation

Page 61: H.R. Pourreza Digital Image Processing بسمهتعالي H.R. Pourreza Image Enhancement in the Frequency Domain (Chapter 4)

H.R. Pourreza

Correlation

Page 62: H.R. Pourreza Digital Image Processing بسمهتعالي H.R. Pourreza Image Enhancement in the Frequency Domain (Chapter 4)

H.R. Pourreza

Convolution

Page 63: H.R. Pourreza Digital Image Processing بسمهتعالي H.R. Pourreza Image Enhancement in the Frequency Domain (Chapter 4)

H.R. Pourreza

Convolution

Page 64: H.R. Pourreza Digital Image Processing بسمهتعالي H.R. Pourreza Image Enhancement in the Frequency Domain (Chapter 4)

H.R. Pourreza

Convolution

Page 65: H.R. Pourreza Digital Image Processing بسمهتعالي H.R. Pourreza Image Enhancement in the Frequency Domain (Chapter 4)

H.R. Pourreza

Convolution