ECG782: Multidimensional Digital Signal Processing Filtering in - - PowerPoint PPT Presentation

β–Ά
ecg782 multidimensional
SMART_READER_LITE
LIVE PREVIEW

ECG782: Multidimensional Digital Signal Processing Filtering in - - PowerPoint PPT Presentation

Professor Brendan Morris, SEB 3216, brendan.morris@unlv.edu ECG782: Multidimensional Digital Signal Processing Filtering in the Frequency Domain http://www.ee.unlv.edu/~b1morris/ecg782/ 2 Outline Background Concepts Sampling and


slide-1
SLIDE 1

http://www.ee.unlv.edu/~b1morris/ecg782/ Professor Brendan Morris, SEB 3216, brendan.morris@unlv.edu

ECG782: Multidimensional Digital Signal Processing

Filtering in the Frequency Domain

slide-2
SLIDE 2

Outline

  • Background Concepts
  • Sampling and Fourier Transform
  • Discrete Fourier Transform
  • Extension to Two Variables
  • Properties of 2D DFT
  • Frequency Domain Filtering Basics
  • Smoothing
  • Sharpening
  • Selective Filtering
  • Implementation

2

slide-3
SLIDE 3

Motivation

  • Complicated signals

(functions) can be constructed as a linear combination of sinusoids

β–« Mathematically compact representation with complex exponentials π‘“π‘˜πœ•π‘’

  • Introduced as Fourier series

by Jean Baptiste Joseph Fourier

β–« Initially considered periodic signals β–« Later extended to aperiodic signals

  • Powerful mathematical tool

β–« Can go between β€œtime” and β€œfrequency” domain processing

3

slide-4
SLIDE 4

Preliminary Concepts

  • Complex numbers

β–« 𝐷 = 𝑆 + π‘˜π½ β–« π·βˆ— = 𝑆 βˆ’ π‘˜π½ β–« 𝐷 = 𝐷 π‘“π‘˜πœ„

ο‚– Using Euler’s formula ο‚– π‘“π‘˜πœ„ = cos πœ„ + π‘˜ sin πœ„

  • Fourier Series

β–« Express a periodic signal as a sum of sines and cosines β–« 𝑔 𝑒 = π‘‘π‘œπ‘“π‘˜πœ•0π‘œπ‘’

π‘œ

β–« π‘‘π‘œ =

1 π‘ˆ 𝑔 𝑒 π‘“βˆ’π‘˜πœ•0π‘œπ‘’ π‘ˆ

ο‚– πœ•0 = 2𝜌/π‘ˆ

  • Fourier Transform

β–« 𝐺 𝜈 = β„± 𝑔 𝑒 = 𝑔 𝑒 π‘“βˆ’π‘˜2πœŒπœˆπ‘’π‘’π‘’

ο‚– 𝜈 : continuous frequency variable

β–« 𝑔 𝑒 = β„±βˆ’1 𝐺 𝜈 = 𝐺 𝜈 π‘“π‘˜2πœŒπœˆπ‘’π‘’πœˆ β–« Notice for real 𝑔 𝑒 this generally results in a complex transform

4

slide-5
SLIDE 5

Rectangle Wave Example

  • 𝐺 𝜈 = 𝐡𝑋

sin πœŒπœˆπ‘‹ πœŒπœˆπ‘‹

β–« Rectangle in time gives sinc in frequency β–« See book for derivation

  • Frequency spectrum

β–« 𝐺 𝜈 = 𝐡𝑋 sin πœŒπœˆπ‘‹

πœŒπœˆπ‘‹

ο‚– Consider only a real portion

  • Note zeros are inversely proportional to width of box

β–« Wider in time, narrow in frequency 5

slide-6
SLIDE 6

Convolution Properties

  • Very important input-output relationship

between a input signal 𝑔 𝑒 and an LTI system β„Ž(𝑒)

  • 𝑔 𝑒 βˆ— β„Ž 𝑒 = 𝑔 𝜐 β„Ž 𝑒 βˆ’ 𝜐 π‘’πœ
  • Dual time-frequency relationship

β–« 𝑔 𝑒 βˆ— β„Ž 𝑒 ↔ 𝐺 𝜈 𝐼 𝜈 β–« 𝑔 𝑒 β„Ž 𝑒 ↔ 𝐺 𝜈 βˆ— 𝐼 𝜈 β–« Convolution-multiplication relationship

6

slide-7
SLIDE 7

Sampling

  • Convert continuous signal to a

discrete sequence

β–« Use impulse train sampling

  • 𝑔

𝑒 = 𝑔 𝑒 π‘‘Ξ”π‘ˆ 𝑒 = 𝑔 𝑒 πœ€(𝑒 βˆ’ π‘œΞ”π‘ˆ)

π‘œ

β–« πœ€ 𝑒 βˆ’ π‘œΞ”π‘ˆ - impulse response at time 𝑒 = π‘œΞ”π‘ˆ

  • Sample value

β–« 𝑔

𝑙 = 𝑔(π‘™Ξ”π‘ˆ)

7

slide-8
SLIDE 8

Fourier Transform of Sampled Signal

8

  • 𝐺

𝜈 = β„± 𝑔 𝑒 = 𝐺 𝜈 βˆ— 𝑇(𝜈)

β–« 𝑇 𝜈 =

1 Ξ”π‘ˆ πœ€ 𝜈 βˆ’ π‘œ Ξ”π‘ˆ π‘œ

β–« FT of impulse train is an impulse train

ο‚– See section 4.2.3 in the book for details ο‚– Note spacing between impulses are inversely related

  • 𝐺

𝜈 =

1 Ξ”T 𝐺 𝜈 βˆ’ π‘œ Ξ”π‘ˆ π‘œ

β–« Sampling creates copies of the original spectrum β–« Must be careful with sampling period to avoid aliasing (overlap of spectrum)

slide-9
SLIDE 9

Sampling Theorem

  • Conditions to be able to recover

𝑔 𝑒 completely after sampling

  • Requires bandlimited 𝑔(𝑒)

β–« 𝐺 𝜈 = 0 for |𝜈| > 𝜈max β–« Can isolate center spectrum copy from its neighbors

  • Sampling theorem

β–«

1 Ξ”π‘ˆ > 2𝜈max

ο‚– Nyquist rate 2𝜈max

  • Recovery with lowpass filter

β–« 𝐼 𝜈 = Ξ”π‘ˆ for 𝜈 ≀ 𝜈max 9

slide-10
SLIDE 10

Aliasing

  • Corruption of recovered signal

if not sampled at rate less than Nyquist rate

β–« Spectrum copies overlap β–« High frequency components corrupt lower frequencies

  • In reality this is always present

β–« Most signals are not bandlimited β–« Bandlimited signals require infinite time duration

ο‚– Windowing to limit size naturally causes distortion

β–« Use anti-aliasing filter before sampling

ο‚– Filter reduces high frequency components 10

slide-11
SLIDE 11

Discrete Fourier Transform

  • Discussion has considered continuous signals (functions)

β–« Need to operate on discrete signals

  • DFT is a sampled version of the sampled signal FT in one

period

β–« 𝐺 𝜈 = 𝑔

π‘œπ‘“βˆ’π‘˜2πœŒπœˆπ‘œΞ”π‘ˆ π‘œ

β–« Sample in frequency evenly (𝑁) over a period

ο‚– 𝜈 =

𝑛 π‘Ξ”π‘ˆ

β–« 𝐺

𝑛 = 𝑔 π‘œπ‘“βˆ’π‘˜2πœŒπ‘›π‘œ/𝑁 π‘œ

ο‚– 𝑛 = 0,1,2, … , 𝑁 βˆ’ 1

β–« 𝑁 samples of 𝑔 𝑒 , 𝑔

π‘œ , results in 𝑁 DFT values

β–« Note: implicitly assumes samples come from one period of periodic signal

  • Inverse DFT

β–« 𝐺

π‘œ = 1 𝑁

𝐺

π‘›π‘“π‘˜2πœŒπ‘›π‘œ/𝑁 𝑛

11

slide-12
SLIDE 12

Sampling/Frequency Relationship

  • 𝑁 samples of signal with sample period Ξ”π‘ˆ

β–« Total time οƒ  π‘ˆ = π‘Ξ”π‘ˆ

  • Spacing in discrete frequency

β–« Δ𝑣 =

1 π‘Ξ”π‘ˆ = 1 π‘ˆ

ο‚– Note the switch to 𝑣 for discrete frequency

β–« Total frequency range οƒ  Ξ© = 𝑁Δ𝑣 =

1 Ξ”π‘ˆ

  • Resolution of DFT is dependent on the duration

π‘ˆ of the sampled function

β–« Generally the number of samples

  • See fft.m in Matlab to test this

12

slide-13
SLIDE 13

Extensions to 2D

  • All discussions can be extended to two variables

easily

β–« Add second integral or summation for extra variable

  • 2D rectangle

β–« 𝐺 𝜈, πœ‰ = ATZ

sin πœŒπœˆπ‘ˆ πœŒπœˆπ‘ˆ sin πœŒπœ‰π‘Ž πœŒπœ‰π‘Ž

13

slide-14
SLIDE 14

Image Aliasing

  • Temporal aliasing appears in video

β–« Wheel effect – looks like it is spinning opposite direction

  • Spatial aliasing is the same as the previous

discussion now in two dimensions

14

slide-15
SLIDE 15

Image Interpolation and Resampling

  • Used for image resizing

β–« Zooming – oversample and image β–« Shrinking – undersample an image

ο‚– Must be careful of aliasing ο‚– Generally smooth before downsample

15

slide-16
SLIDE 16

Fourier Spectrum and Phase Angle

  • 𝐺 𝑣, 𝑀 = 𝐺 𝑣, 𝑀 π‘“π‘˜πœš 𝑣,𝑀

β–« Magnitude, spectrum

ο‚– 𝐺 𝑣, 𝑀 = 𝑆2 𝑣, 𝑀 + 𝐽2 𝑣, 𝑀

1/2

β–« Phase angle

ο‚– π‘“π‘˜πœš 𝑣,𝑀 = arctan

𝐽 𝑣,𝑀 𝑆 𝑣,𝑀

  • Spectrum is component we

naturally specify while phase is a bit harder to visualize

  • Spectrum

16

slide-17
SLIDE 17

Spectrum

  • Translation does not affect

spectrum

β–« Wide in space οƒ  narrow in frequency

  • Orientation clearly visible

in spectrum

17

slide-18
SLIDE 18

Phase

  • Difficult to describe phase given image content

β–« a) centered rectangle β–« b) translated rectangle β–« c) rotated rectangle

18

slide-19
SLIDE 19

Spectrum Phase Manipulation

  • Both spectrum and phase are important for image

content

19

slide-20
SLIDE 20

Frequency Domain Filtering Basics

  • Generally complicated relationship between image and

transform

β–« Frequency is associated with patterns of intensity variations in image

  • Filtering modifies the image spectrum based on a

specific objective

β–« Magnitude (spectrum) – most useful for visualization (e.g. match visual characteristics) β–« Phase – generally not useful for visualization

20 45 degree lines Off center line

slide-21
SLIDE 21

Fundamentals

  • Modify FT of image and inverse for result

β–« 𝑕 𝑦, 𝑧 = β„±βˆ’1[𝐼 𝑣, 𝑀 𝐺 𝑣, 𝑀 ]

ο‚– 𝑕(𝑦, 𝑧) : output image [𝑁 Γ— 𝑂] ο‚– 𝐺(𝑣, 𝑀) : FT of input image 𝑔 𝑦, 𝑧 [𝑁 Γ— 𝑂] ο‚– 𝐼(𝑣, 𝑀) : filter transfer function [𝑁 Γ— 𝑂] ο‚– β„±βˆ’1 : inverse FT (iFT)

β–« Product from element-wise array multiplication

21 Remove DC (0,0) term from 𝐺(𝑣, 𝑀)

slide-22
SLIDE 22

Example Filters

22 Addition of small offset to retain DC component after HP

slide-23
SLIDE 23

DFT Subtleties

  • Multiplication in frequency is convolution in time

β–« Must pad image since output is larger

ο‚– Will pad 𝑔(𝑦, 𝑧) image but not β„Ž(𝑦, 𝑧) ο‚– 𝐼(𝑣, 𝑀) designed and sized for padded 𝐺(𝑣, 𝑀)

β–« DFT implicitly assumes a periodic function

23

slide-24
SLIDE 24

Phase Angle

  • Generally, a filter can affect the phase of a signal
  • Zero-phase-shift filters have no effect on phase

β–« Focus of this chapter

  • Phase is very important to image

β–« Small changes can lead to unexpected results

24

slide-25
SLIDE 25

Frequency Domain Filtering Steps

1. Given image 𝑔(𝑦, 𝑧) of size 𝑁 Γ— 𝑂, get padding (𝑄, 𝑅)

β–« Typically use 𝑄 = 2𝑁 and 𝑅 = 2𝑂

  • 2. Form zero-padded image 𝑔

π‘ž(𝑦, 𝑧) of size 𝑄 Γ— 𝑅

  • 3. Multiply 𝑔

π‘ž(𝑦, 𝑧) by βˆ’1 𝑦+𝑧 to center the

transform

  • 4. Compute DFT 𝐺(𝑣, 𝑀)
  • 5. Compute 𝐻 𝑣, 𝑀 = 𝐼 𝑣, 𝑀 𝐺(𝑣, 𝑀)

β–« Get real, symmetric filter function 𝐼(𝑣, 𝑀) of size 𝑄 Γ— 𝑅 with center at coordinates

𝑄 2 , 𝑅 2

  • 6. Obtain (padded) output image from iFT

β–« π‘•π‘ž 𝑦, 𝑧 = {real β„±βˆ’1 𝐻 𝑣, 𝑀 βˆ’1 𝑦+𝑧

  • 7. Obtain 𝑕(𝑦, 𝑧) by extracting 𝑁 Γ— 𝑂 region from top

left quadrant of π‘•π‘ž(𝑦, 𝑧)

25

slide-26
SLIDE 26

Steps Example

26

slide-27
SLIDE 27

Relationship to Spatial Filtering

  • Frequency multiplication οƒ  convolution in

spatial domain

β–« β„Ž(𝑦, 𝑧) ↔ 𝐼(𝑣, 𝑀) β–« Use of a finite impulse response

  • Generally use small filter kernels which are more

efficient to implement in spatial domain

  • Frequency domain can be better for the design
  • f filters

β–« More natural space for definition β–« Use iFT to determine the β€œshape” of the spatial filter

27

slide-28
SLIDE 28

Smoothing

  • High frequency image content comes from edges

and noise

  • Smoothing/blurring is a lowpass operation that

attenuates (removes) high frequency content

  • Consider three smoothing filters

β–« Ideal lowpass – sharp filter β–« Butterworth – filter order controls shape β–« Gaussian – very smooth filter

28

slide-29
SLIDE 29

Ideal Lowpass Filter

  • 𝐼 𝑣, 𝑀 = 1

𝐸 𝑣, 𝑀 ≀ 𝐸0 𝐸 𝑣, 𝑀 > 𝐸0

β–« 𝐸 𝑣, 𝑀 = 𝑣 βˆ’

𝑄 2 2

+ 𝑀 βˆ’

𝑅 2 2

β–« Pass all frequencies 𝐸0 distance from DC

ο‚– 𝐸0 is the cuttoff frequency

29

slide-30
SLIDE 30

Ideal Lowpass Example

30 blurring ringing

slide-31
SLIDE 31

LP Spectrum View

31

slide-32
SLIDE 32

Butterworth LP Filter

  • 𝐼 𝑣, 𝑀 =

1 1+ 𝐸 𝑣,𝑀 /𝐸0 2π‘œ

β–« π‘œ – order of the filter (controls sharpness of transition) β–« Cutoff generally specified as the 50% of max (D0 = 0.5)

32

slide-33
SLIDE 33

Butterworth LP Example

  • No ringing is visible because of

the gradual transition from high to low frequency in filter

β–« May be visible in higher-

  • rder filters (π‘œ > 2)

β–« Trade-off frequency narrow main lobe with sidelobe height

33

slide-34
SLIDE 34

Gaussian Lowpass Filter

  • 𝐼 𝑣, 𝑀 = π‘“βˆ’πΈ2 𝑣,𝑀 /2𝜏2

β–« 𝜏 – measure of spread

ο‚– 𝜏 = 𝐸0 is the cutoff frequency

β–« iFT is also a Gaussian

ο‚– No ringing because of smooth function

β–« A favorite filter for smoothing

34

slide-35
SLIDE 35

Gaussian LP Example

  • No ringing
  • Not as much smoothing as

Butterworth 2

  • Best for use when ringing is

unacceptable

  • Butterworth better when tight

control of transition between high and low frequency is required

35

slide-36
SLIDE 36

Sharpening

  • Use a highpass filter

β–« 𝐼𝐼𝑄 𝑣, 𝑀 = 1 βˆ’ 𝐼𝑀𝑄(𝑣, 𝑀)

  • Ideal

β–« 𝐼 𝑣, 𝑀 = 0 𝐸 𝑣, 𝑀 ≀ 𝐸0 1 𝐸 𝑣, 𝑀 > 𝐸0

  • Butterworth

β–« 𝐼 𝑣, 𝑀 =

1 1+ 𝐸0/𝐸 𝑣,𝑀

2π‘œ

  • Gaussian

β–« 𝐼 𝑣, 𝑀 = π‘“βˆ’πΈ2 𝑣,𝑀 /2𝜏2

36

slide-37
SLIDE 37

Highpass Examples

37 Same ringing artifacts as ideal lowpass

slide-38
SLIDE 38

HP Spectrum View

38

slide-39
SLIDE 39

Selective Filtering

  • Bandpass/reject – operate on a ring in the

frequency spectrum

β–« See Table 4.6 for definitions

  • Notch filters – operate on specific regions in the

frequency spectrum

β–« Move center of HP filter appropriately

39

slide-40
SLIDE 40

Notch Examples

40

slide-41
SLIDE 41

Notch Examples II

41

slide-42
SLIDE 42

BP Spectrum View

42

slide-43
SLIDE 43

Implementation Issues

  • DFT is separable

β–« Can compute first a 1D DFT over rows followed by the 1D DFT over columns β–« Simplifies computations in 1D

  • Practically use Fast Fourier Transform (FFT) to

computer all DFT

β–« Computationally efficient algorithm that simplifies problem by halving sequence repeatedly β–« Efficiency requires 𝑁 and 𝑂 (size of image) to be multiples of 2

43