Filtering in the Frequency Domaincseweb.ucsd.edu/classes/sp20/cse166-a/lec7.pdfFiltering in spatial...

Post on 06-Aug-2020

49 views 0 download

Transcript of Filtering in the Frequency Domaincseweb.ucsd.edu/classes/sp20/cse166-a/lec7.pdfFiltering in spatial...

Filtering in the Frequency Domain

Image Processing

CSE 166

Lecture 7

Announcements

• Assignment 3 will be released today

– Due Apr 27, 11:59 PM

• Reading

– Chapter 4: Filtering in the Frequency Domain

CSE 166, Spring 2020 2

Overview: Image processing in the frequency domain

CSE 166, Spring 2020 3

Image in spatial domain

f(x,y)

Image in spatial domain

g(x,y)

Fouriertransform

Image in frequency domain

F(u,v)

Inverse Fourier

transform

Image in frequency domain

G(u,v)

Frequency domain processing

Jean-Baptiste Joseph Fourier1768-1830

2D continuous Fourier transform

• (Forward) Fourier transform

• Inverse Fourier transform

CSE 166, Spring 2020 4

2D continuous Fourier transform

CSE 166, Spring 2020

1D

2D

5

Example: box function

Unit discrete impulse

CSE 166, Spring 2020

1D

2D

6

Impulse train

CSE 166, Spring 2020

1D

2D

7

Fourier transform of sampled functionand extracting one period

CSE 166, Spring 2020 8

1D

2D

Over-sampled Under-sampled

Recovered Imperfect recoverydue to

interference

Aliasing

CSE 166, Spring 2020

1D

2D

Aliasing

Original

9

Aliasing in real images

CSE 166, Spring 2020

AliasingOriginal No aliasing

10

2D Discrete Fourier Transform

2D discrete Fourier transform (DFT)

• (Forward) Fourier transform

• Inverse Fourier transform

CSE 166, Spring 2020 12

Centering the DFT

CSE 166, Spring 2020

1D

2D

In MATLAB, use fftshift and ifftshift

13

Centering the DFT

CSE 166, Spring 2020

Original

DFT(look at corners)

Shifted DFTLog of

shifted DFT

14

DFT magnitude of geometrically transformed images

CSE 166, Spring 2020

Translated

Rotatedabout center

Same magnitude as original

(invariant to translation)

15

DFT phase of geometrically transformed images

CSE 166, Spring 2020

TranslatedRotated

about centerOriginal

16

Contributions of magnitude and phaseto image formation

CSE 166, Spring 2020

Phase

IDFT: Phase only

(zero magnitude)

IDFT: Magnitude

only (zero phase)

IDFT: Boy magnitude

and rectangle phase

IDFT: Rectangle magnitude

and boy phase 17

2D convolution theorem

• 2D discrete (circular) convolution

• 2D convolution theorem

CSE 166, Spring 2020 18

Filtering using convolution theorem

CSE 166, Spring 2020

Filtering in spatial domain

using convolution

expectedresult

Filtering in frequencydomain

using productwithout

zero-padding

wraparounderror

19

Filtering using convolution theorem

CSE 166, Spring 2020

Filtering in frequencydomain

using productwith

zero-padding

no wraparounderror

Gaussian lowpass filter in

frequency domain

20

Fourier transform

Product

Inverse Fourier transform

Zero padding

Filtering using convolution theorem

CSE 166, Spring 2020

Filtering in spatial

domain using

convolution

Filtering in frequencydomain

usingproduct

Identical results

DFT

21

Filtering in the frequency domain

• Ideal lowpass filter (LPF)

– Frequency domain

CSE 166, Spring 2020 22

Filtering in the frequency domain

• Ideal lowpass filter (LPF)

– Spatial domain

CSE 166, Spring 2020 23

H(u,v) h(x,y)

Filtering in the frequency domain

• Gaussian lowpass filter (LPF)

CSE 166, Spring 2020 24

Filtering in the frequency domain

• Butterworth lowpass filter (LPF)

CSE 166, Spring 2020 25

Gaussian LPF

Filtering in the frequency domain

CSE 166, Spring 2020

Ideal LPF Butterworth LPF

26

Example: character recognition

CSE 166, Spring 2020 27

Gaussian LPFjoins broken characters

Highpass filter (HPF)Frequency domain

CSE 166, Spring 2020

Ideal HPF

Gaussian HPF

Butterworth HPF

28

Butterworth HPF

Highpass filter (HPF)Spatial domain

CSE 166, Spring 2020

Ideal HPF Gaussian HPF

29

Filtering in the frequency domain

CSE 166, Spring 2020

Ideal HPF Gaussian HPF Butterworth HPF

30

H (u)

u u

x x

H (u)

h (x)

1

16–– 3

h (x)

2 12 12 1

2 1 8 2 1

2 12 12 1

0 2 1 0

2 1 4 2 1

0 2 1 0

1 2 1

2

1

9–– 3

4 2

1 2 1

1 1 1

1 1 1

1 1 1

Filtering in the frequency domain

CSE 166, Spring 2020

1D

Lowpass filter Sharpening filter31

Frequencydomain

Spatialdomain

Filtering in the frequency domain

CSE 166, Spring 2020

2D

32

Lowpass filter Highpass filter Offset highpass filter

Bandreject filters

CSE 166, Spring 2020 33

ButterworthIdeal Gaussian

Filtering in the frequency domain

• Sharpening filter

CSE 166, Spring 2020 34

Overview: Image processing in the frequency domain

CSE 166, Spring 2020 35

Image in spatial domain

f(x,y)

Image in spatial domain

g(x,y)

Fouriertransform

Image in frequency domain

F(u,v)

Inverse Fourier

transform

Image in frequency domain

G(u,v)

Frequency domain processing

Jean-Baptiste Joseph Fourier1768-1830

Next Lecture

• Image restoration

• Reading

– Chapter 5: Image Restoration and Reconstruction

CSE 166, Spring 2020 36