70
ee.sharif.edu/~dip E. Fatemizadeh, Sharif University of Technology, 2012 Digital Image Processing Filtering in the Frequency Domain 1 2D Linear Systems 2D Fourier Transform and its Properties The Basics of Filtering in Frequency Domain Image Smoothing Image Sharpening Selective Filtering Implementation Tips

2D Linear Systems 2D Fourier Transform and its …ee.sharif.edu/~dip/Files/ImageEnhancementInFrequencyDomain(For... · ee.sharif.edu/~dip . E. Fatemizadeh, Sharif University of Technology,

Embed Size (px)

Citation preview

ee.sharif.edu/~dip

E. Fatemizadeh, Sharif University of Technology, 2012

1

Digital Image Processing

Filtering in the Frequency Domain

1

• 2D Linear Systems

• 2D Fourier Transform and its Properties

• The Basics of Filtering in Frequency Domain

• Image Smoothing

• Image Sharpening

• Selective Filtering

• Implementation Tips

ee.sharif.edu/~dip

E. Fatemizadeh, Sharif University of Technology, 2012

2

Digital Image Processing

Filtering in the Frequency Domain

2

• General Definition:

System

H ,f x y ,g x y

, ,g x y H f x y

ee.sharif.edu/~dip

E. Fatemizadeh, Sharif University of Technology, 2012

3

Digital Image Processing

Filtering in the Frequency Domain

3

• Linearity

• Shift Invariant or Spatially Invariant:

• Causality: Same as before

– Don’t worry about it!

• Stability: Same as before

1 2 1 2, , , ,H af x y bf x y aH f x y bH f x y

0 0 0 0, , , ,g x y H f x y g x x y y H f x x y y

ee.sharif.edu/~dip

E. Fatemizadeh, Sharif University of Technology, 2012

4

Digital Image Processing

Filtering in the Frequency Domain

4

• Unit Impulse Function (Pinhole):

, 0,0,

0 , 0,0

, 1

x yx y

x y

x y dxdy

ee.sharif.edu/~dip

E. Fatemizadeh, Sharif University of Technology, 2012

5

Digital Image Processing

Filtering in the Frequency Domain

5

• Point Spread Function (Impulse Response):

• Linear Shift Invariant Systems:

0 0 0 0, ; , ,H x y x y H x x y y

0 0 0 0 0 0, ; , , ,

, ,

H x y x y H x x y y H x x y y

H x y H x y

PSD of Hubble Telescope

ee.sharif.edu/~dip

E. Fatemizadeh, Sharif University of Technology, 2012

6

Digital Image Processing

Filtering in the Frequency Domain

6

• Convolution/Correlation Integral:

• Convolution/Correlation Summation:

, , , ,

, , , ,

f x y h x y f s t h x s y t dsdt

f x y h x y f s t h x s y t dsdt

1 1

0 0

1 1

0 0

, , , ,

, , , ,

M N

p q

M N

p q

f m n h m n f p q h m p n q

f m n h m n f p q h m p n q

ee.sharif.edu/~dip

E. Fatemizadeh, Sharif University of Technology, 2012

7

Digital Image Processing

Filtering in the Frequency Domain

7

• The 2-D Continuous Fourier Transform

2

2

, ,

, ,

j ux vy

j ux vy

F u v f x y e dxdy

f x y F u v e dudv

x y

Arect rect ATZsinc uT sinc vZZ T

ee.sharif.edu/~dip

E. Fatemizadeh, Sharif University of Technology, 2012

8

Digital Image Processing

Filtering in the Frequency Domain

8

• 2-D Sampling and Sampling Theorem

– 2-D impulse train:

– Error Free Reconstruction:

,m m

x m x y n y

max max

1 1,

2 2x y

u v

ee.sharif.edu/~dip

E. Fatemizadeh, Sharif University of Technology, 2012

9

Digital Image Processing

Filtering in the Frequency Domain

9

• Aliasing in Images:

• See Figures 4.16-4.22 for practical examples.

ee.sharif.edu/~dip

E. Fatemizadeh, Sharif University of Technology, 2012

10

Digital Image Processing

Filtering in the Frequency Domain

10

• 2-D Discrete Fourier Transform

• Spatial and Frequency Intervals

1 1

0 0

1 1

0 0

1, , exp 2

1, , ex

1

p 2

M N

m n

M N

u v

um vnF u v f m n j

M N

um vnf m n F u v j

M NMN

1 1,u v

M x N y

ee.sharif.edu/~dip

E. Fatemizadeh, Sharif University of Technology, 2012

11

Digital Image Processing

Filtering in the Frequency Domain

11

• Phase Significance

ee.sharif.edu/~dip

E. Fatemizadeh, Sharif University of Technology, 2012

12

Digital Image Processing

Filtering in the Frequency Domain

12

• Phase Significance

ee.sharif.edu/~dip

E. Fatemizadeh, Sharif University of Technology, 2012

13

Digital Image Processing

Filtering in the Frequency Domain

13

• Phase Significance

ee.sharif.edu/~dip

E. Fatemizadeh, Sharif University of Technology, 2012

14

Digital Image Processing

Filtering in the Frequency Domain

14

• Symmetry Properties

ee.sharif.edu/~dip

E. Fatemizadeh, Sharif University of Technology, 2012

15

Digital Image Processing

Filtering in the Frequency Domain

15

• Definition and Properties (1)

ee.sharif.edu/~dip

E. Fatemizadeh, Sharif University of Technology, 2012

16

Digital Image Processing

Filtering in the Frequency Domain

16

• Definition and Properties (2)

ee.sharif.edu/~dip

E. Fatemizadeh, Sharif University of Technology, 2012

17

Digital Image Processing

Filtering in the Frequency Domain

17

• DFT Pairs (1)

ee.sharif.edu/~dip

E. Fatemizadeh, Sharif University of Technology, 2012

18

Digital Image Processing

Filtering in the Frequency Domain

18

• DFT Pairs (2)

ee.sharif.edu/~dip

E. Fatemizadeh, Sharif University of Technology, 2012

19

Digital Image Processing

Filtering in the Frequency Domain

19

• FFT Shift, Centering and Symmetry

ee.sharif.edu/~dip

E. Fatemizadeh, Sharif University of Technology, 2012

20

Digital Image Processing

Filtering in the Frequency Domain

20

• Fourier Transform Centering

– fftshift in Matlab

ee.sharif.edu/~dip

E. Fatemizadeh, Sharif University of Technology, 2012

21

Digital Image Processing

Filtering in the Frequency Domain

21

• Example

Without Shift

With Shift

ee.sharif.edu/~dip

E. Fatemizadeh, Sharif University of Technology, 2012

22

Digital Image Processing

Filtering in the Frequency Domain

22

• Translation

• Rotation

ee.sharif.edu/~dip

E. Fatemizadeh, Sharif University of Technology, 2012

23

Digital Image Processing

Filtering in the Frequency Domain

23

• Phase Changes:

Original Translated Rotated

ee.sharif.edu/~dip

E. Fatemizadeh, Sharif University of Technology, 2012

24

Digital Image Processing

Filtering in the Frequency Domain

24

• Line Pattern in Spatial and Frequency Domain – Strong ±45˚ edge in Spatial Strong ±45˚ edge in Frequency

ee.sharif.edu/~dip

E. Fatemizadeh, Sharif University of Technology, 2012

25

Digital Image Processing

Filtering in the Frequency Domain

25

• Frequency Domain Filtering Fundamentals:

– Convolution Theorem:

– Zero Padding:

– Zero-Padding is necessary to avoid Wraparound error. • Circular vs. Linear Convolution

, , , ,f m n h m n F u v H u v

1 1M N P Q M P N Qf h g

ee.sharif.edu/~dip

E. Fatemizadeh, Sharif University of Technology, 2012

26

Digital Image Processing

Filtering in the Frequency Domain

26

• Frequency Domain Manipulation

– Set F(0,0) to zero

– Clip negative value

ee.sharif.edu/~dip

E. Fatemizadeh, Sharif University of Technology, 2012

27

Digital Image Processing

Filtering in the Frequency Domain

27

• Lowpass, Highpass, Highboost

– No shift

ee.sharif.edu/~dip

E. Fatemizadeh, Sharif University of Technology, 2012

28

Digital Image Processing

Filtering in the Frequency Domain

28

• Zero-Padding Effect:

– Blurring With Gaussian

Original No Zero-Padding Zero-Padding

ee.sharif.edu/~dip

E. Fatemizadeh, Sharif University of Technology, 2012

29

Digital Image Processing

Filtering in the Frequency Domain

29

• Inherent Periodicity of DFT and Zero-Padding

– With (Right) and Without (Left) Padding

ee.sharif.edu/~dip

E. Fatemizadeh, Sharif University of Technology, 2012

30

Digital Image Processing

Filtering in the Frequency Domain

30

• Zero-Padding Side effect

• Read Pg. 260-262!

– Ideal Filter (TL)

– Time Domain (BL)

– Zero Padding (TR)

– Ringing Effect (BR)

ee.sharif.edu/~dip

E. Fatemizadeh, Sharif University of Technology, 2012

31

Digital Image Processing

Filtering in the Frequency Domain

31

• Effect of small changes in phase

– Why we prefer zero-phase filters?

0.5j FIDFT F e 0.25j FIDFT F e

ee.sharif.edu/~dip

E. Fatemizadeh, Sharif University of Technology, 2012

32

Digital Image Processing

Filtering in the Frequency Domain

32

• Steps for Frequency Domain Filtering a) Original

b) Padding

c) Multiply by (-1)x+y

d) FFT

e) GLP (Centered)

f) Multiply © and (e)

g) Multiply IFFTReal by (-1)x+y

h) Cropping

ee.sharif.edu/~dip

E. Fatemizadeh, Sharif University of Technology, 2012

33

Digital Image Processing

Filtering in the Frequency Domain

33

• Spatial-Frequency Correspondences

• The most used Filter (Gaussian)

, ,h x y H u v

2 2

2 2 2 22 222

2

12

2

x yu v

e e

ee.sharif.edu/~dip

E. Fatemizadeh, Sharif University of Technology, 2012

34

Digital Image Processing

Filtering in the Frequency Domain

34

• Example (1)

ee.sharif.edu/~dip

E. Fatemizadeh, Sharif University of Technology, 2012

35

Digital Image Processing

Filtering in the Frequency Domain

35

• Example (2)

– An image and its spectrum

ee.sharif.edu/~dip

E. Fatemizadeh, Sharif University of Technology, 2012

36

Digital Image Processing

Filtering in the Frequency Domain

36

• Filtering in Spatial and Frequency Domain

ee.sharif.edu/~dip

E. Fatemizadeh, Sharif University of Technology, 2012

37

Digital Image Processing

Filtering in the Frequency Domain

37

• Image Smoothing in Frequency Domain

– Ideal Lowpass Filter

– Butterworth Lowpass Filter

– Gaussian Lowpass Filter

– More Examples

2 2,D u v u v

ee.sharif.edu/~dip

E. Fatemizadeh, Sharif University of Technology, 2012

38

Digital Image Processing

Filtering in the Frequency Domain

38

• Ideal Lowpass Filter

ee.sharif.edu/~dip

E. Fatemizadeh, Sharif University of Technology, 2012

39

Digital Image Processing

Filtering in the Frequency Domain

39

• Test Pattern and Energy Circles

460 (99.2%) 160 (97.8%) 60 (95.7%) 30 (93.1%) 10 (87.0%)

ee.sharif.edu/~dip

E. Fatemizadeh, Sharif University of Technology, 2012

40

Digital Image Processing

Filtering in the Frequency Domain

40

• Ideal Lowpass Filter

– 10, 30, 60, 160, and 460 (Radius)

– Smoothing

– Blurring

– Ringing Effect

ee.sharif.edu/~dip

E. Fatemizadeh, Sharif University of Technology, 2012

41

Digital Image Processing

Filtering in the Frequency Domain

41

• Origin of Ringing Effect

ee.sharif.edu/~dip

E. Fatemizadeh, Sharif University of Technology, 2012

42

Digital Image Processing

Filtering in the Frequency Domain

42

• Butterworth Lowpass Filter:

ee.sharif.edu/~dip

E. Fatemizadeh, Sharif University of Technology, 2012

43

Digital Image Processing

Filtering in the Frequency Domain

43

• Butterworth Lowpass Filter:

– Order (2) Same radius

– Smoothing

– Blurring

– Less Ringing Effect

ee.sharif.edu/~dip

E. Fatemizadeh, Sharif University of Technology, 2012

44

Digital Image Processing

Filtering in the Frequency Domain

44

• Less Ringing Effect of Butterworh Filter:

– Order 1,2 ,5, and 20

ee.sharif.edu/~dip

E. Fatemizadeh, Sharif University of Technology, 2012

45

Digital Image Processing

Filtering in the Frequency Domain

45

• Gaussian Lowpass Filter:

ee.sharif.edu/~dip

E. Fatemizadeh, Sharif University of Technology, 2012

46

Digital Image Processing

Filtering in the Frequency Domain

46

• Gaussian Lowpass Filter:

– Smoothing

– Blurring

– No Ringing Effect!

ee.sharif.edu/~dip

E. Fatemizadeh, Sharif University of Technology, 2012

47

Digital Image Processing

Filtering in the Frequency Domain

47

• Low Resolution Images Repairing

ee.sharif.edu/~dip

E. Fatemizadeh, Sharif University of Technology, 2012

48

Digital Image Processing

Filtering in the Frequency Domain

48

• Pre-print Processing (Smooth and soft-Looking)

– Original, D0=100, and D0=80

ee.sharif.edu/~dip

E. Fatemizadeh, Sharif University of Technology, 2012

49

Digital Image Processing

Filtering in the Frequency Domain

49

• Remove Unwanted Pattern:

– Remove Horizontal Lines (Imaging System Deficiency)

– Large Recognizable Features

– Original, D0=50, and D0=20

ee.sharif.edu/~dip

E. Fatemizadeh, Sharif University of Technology, 2012

50

Digital Image Processing

Filtering in the Frequency Domain

50

• Image Sharpening in Frequency Domain

– Ideal Highpass Filter

– Butterworth Highpass Filter

– Gaussian Highpass Filter

– More Examples

, 1 ,HP LPH u v H u v

ee.sharif.edu/~dip

E. Fatemizadeh, Sharif University of Technology, 2012

51

Digital Image Processing

Filtering in the Frequency Domain

51

• Highpass Filters

ee.sharif.edu/~dip

E. Fatemizadeh, Sharif University of Technology, 2012

52

Digital Image Processing

Filtering in the Frequency Domain

52

• Spatial Representation of Highpass Filters

– Ringing (Ideal, Butterworth, and Gaussian)

ee.sharif.edu/~dip

E. Fatemizadeh, Sharif University of Technology, 2012

53

Digital Image Processing

Filtering in the Frequency Domain

53

• Ideal Highpass Filter

D0=30 D0=60 D0=160

ee.sharif.edu/~dip

E. Fatemizadeh, Sharif University of Technology, 2012

54

Digital Image Processing

Filtering in the Frequency Domain

54

• Butterworth (n=2) Highpass Filters

D0=30 D0=60 D0=160

ee.sharif.edu/~dip

E. Fatemizadeh, Sharif University of Technology, 2012

55

Digital Image Processing

Filtering in the Frequency Domain

55

• Gaussian Highpass Filter

D0=30 D0=60 D0=160

ee.sharif.edu/~dip

E. Fatemizadeh, Sharif University of Technology, 2012

56

Digital Image Processing

Filtering in the Frequency Domain

56

• Thumb Print Processing:

– Original (Left)

– Butterworth Highpass Filter with n=4, D0=50 (Middle)

– Thresholding (Right) • Setting Negative Value to Black and Positive value to White

ee.sharif.edu/~dip

E. Fatemizadeh, Sharif University of Technology, 2012

57

Digital Image Processing

Filtering in the Frequency Domain

57

• Laplacian in Frequency Domain:

• Image Laplacian:

• Enhanced Image:

2 2 2 2 2, 4 4 ,H u v u v D u v

2 1, , ,f x y H u v F u v

2

1

1 2 2

, , ,

, , ,

1 4 , ,

g x y f x y c f x y

F u v H u v F u v

D u v F u v

ee.sharif.edu/~dip

E. Fatemizadeh, Sharif University of Technology, 2012

58

Digital Image Processing

Filtering in the Frequency Domain

58

• Example (Laplacian):

– Similar But Not identical to Spatial Domain

ee.sharif.edu/~dip

E. Fatemizadeh, Sharif University of Technology, 2012

59

Digital Image Processing

Filtering in the Frequency Domain

59

• Unsharp Masking, Highboost, High-Frequency Emphasis:

• Unsharp Masking (K=1) and Highboost Filters(K>1):

• High Frequency Emphasing:

1

, , ,

, , ,

mask LP

LP LP

g x y f x y f x y

f x y H u v F u v

1

, , ,

, 1 1 , ,

mask

LP

g x y f x y kg x y

g x y k H u v F u v

1 2

1

1

, ,1 ,

,, ,

HP

HP

g x y F u v

g x

kH u v

k k H uy F u vv

ee.sharif.edu/~dip

E. Fatemizadeh, Sharif University of Technology, 2012

60

Digital Image Processing

Filtering in the Frequency Domain

60

• Example: GHPF, D0=40

HFE, k1=0.5, k2=0.25

Histogram EQ.

ee.sharif.edu/~dip

E. Fatemizadeh, Sharif University of Technology, 2012

61

Digital Image Processing

Filtering in the Frequency Domain

61

• Homomorphic Filtering:

• Linear Process is not Possible:

• Summary of Steps

, , ,f x y i x y r x y

ln , ln , ln ,f x y i x y r x y

ee.sharif.edu/~dip

E. Fatemizadeh, Sharif University of Technology, 2012

62

Digital Image Processing

Filtering in the Frequency Domain

62

• Illumination-Reflection Control Filter

2 2

0,, 1

c D u v D

H L LH u v e

ee.sharif.edu/~dip

E. Fatemizadeh, Sharif University of Technology, 2012

63

Digital Image Processing

Filtering in the Frequency Domain

63

• Example: Whole Body PET Scan Enhancement

0

0.25

2

1

80

L

H

c

D

ee.sharif.edu/~dip

E. Fatemizadeh, Sharif University of Technology, 2012

64

Digital Image Processing

Filtering in the Frequency Domain

64

• Selective Filtering:

– Bandpass

– Band Reject

– Notch

ee.sharif.edu/~dip

E. Fatemizadeh, Sharif University of Technology, 2012

65

Digital Image Processing

Filtering in the Frequency Domain

65

• Bandreject and Bandpass Filter

– HBP(u, v)= 1- HBR(u, v)

ee.sharif.edu/~dip

E. Fatemizadeh, Sharif University of Technology, 2012

66

Digital Image Processing

Filtering in the Frequency Domain

66

• Notch Filters:

– Pass/Reject predefined, both (u0, v0) and (-u0, -v0)

– HNP(u, v)= 1- HNR(u, v)

ee.sharif.edu/~dip

E. Fatemizadeh, Sharif University of Technology, 2012

67

Digital Image Processing

Filtering in the Frequency Domain

67

• Example (1)

– Spot in Frequency Domain

Multiplied Spectrum

Spectrum

ee.sharif.edu/~dip

E. Fatemizadeh, Sharif University of Technology, 2012

68

Digital Image Processing

Filtering in the Frequency Domain

68

• Example (2)

– Vertical sin Pattern

ee.sharif.edu/~dip

E. Fatemizadeh, Sharif University of Technology, 2012

69

Digital Image Processing

Filtering in the Frequency Domain

69

• Example (2) – Cont.

– Extract Vertical sin Pattern

ee.sharif.edu/~dip

E. Fatemizadeh, Sharif University of Technology, 2012

70

Digital Image Processing

Filtering in the Frequency Domain

70

• Matlab Command

– fft2, ifft2, fftshift, ifftshift

– freqz2, fspecial