Lecture 10: Ideal Filters Mark Hasegawa-Johnson ECE 401: Signal and - - PowerPoint PPT Presentation

lecture 10 ideal filters
SMART_READER_LITE
LIVE PREVIEW

Lecture 10: Ideal Filters Mark Hasegawa-Johnson ECE 401: Signal and - - PowerPoint PPT Presentation

DTFT Ideal LPF Ideal HPF Ideal BPF Finite-Length Even Length Summary Lecture 10: Ideal Filters Mark Hasegawa-Johnson ECE 401: Signal and Image Analysis, Fall 2020 DTFT Ideal LPF Ideal HPF Ideal BPF Finite-Length Even Length Summary


slide-1
SLIDE 1

DTFT Ideal LPF Ideal HPF Ideal BPF Finite-Length Even Length Summary

Lecture 10: Ideal Filters

Mark Hasegawa-Johnson ECE 401: Signal and Image Analysis, Fall 2020

slide-2
SLIDE 2

DTFT Ideal LPF Ideal HPF Ideal BPF Finite-Length Even Length Summary

1

Review: DTFT

2

Ideal Lowpass Filter

3

Ideal Highpass Filter

4

Ideal Bandpass Filter

5

Realistic Filters: Finite Length

6

Realistic Filters: Even Length

7

Summary

slide-3
SLIDE 3

DTFT Ideal LPF Ideal HPF Ideal BPF Finite-Length Even Length Summary

Outline

1

Review: DTFT

2

Ideal Lowpass Filter

3

Ideal Highpass Filter

4

Ideal Bandpass Filter

5

Realistic Filters: Finite Length

6

Realistic Filters: Even Length

7

Summary

slide-4
SLIDE 4

DTFT Ideal LPF Ideal HPF Ideal BPF Finite-Length Even Length Summary

Review: DTFT

The DTFT (discrete time Fourier transform) of any signal is X(ω), given by X(ω) =

  • n=−∞

x[n]e−jωn x[n] = 1 2π π

−π

X(ω)ejωndω Particular useful examples include: f [n] = δ[n] ↔ F(ω) = 1 g[n] = δ[n − n0] ↔ G(ω) = e−jωn0

slide-5
SLIDE 5

DTFT Ideal LPF Ideal HPF Ideal BPF Finite-Length Even Length Summary

Properties of the DTFT

Properties worth knowing include:

0 Periodicity: X(ω + 2π) = X(ω) 1 Linearity:

z[n] = ax[n] + by[n] ↔ Z(ω) = aX(ω) + bY (ω)

2 Time Shift: x[n − n0] ↔ e−jωn0X(ω) 3 Frequency Shift: ejω0nx[n] ↔ X(ω − ω0) 4 Filtering is Convolution:

y[n] = h[n] ∗ x[n] ↔ Y (ω) = H(ω)X(ω)

slide-6
SLIDE 6

DTFT Ideal LPF Ideal HPF Ideal BPF Finite-Length Even Length Summary

Outline

1

Review: DTFT

2

Ideal Lowpass Filter

3

Ideal Highpass Filter

4

Ideal Bandpass Filter

5

Realistic Filters: Finite Length

6

Realistic Filters: Even Length

7

Summary

slide-7
SLIDE 7

DTFT Ideal LPF Ideal HPF Ideal BPF Finite-Length Even Length Summary

What is “Ideal”?

The definition of “ideal” depends on your application. Let’s start with the task of lowpass filtering. Let’s define an ideal lowpass filter, Y (ω) = LI(ω)X(ω), as follows: Y (ω) =

  • X(ω)

|ω| ≤ ωL,

  • therwise,

where ωL is some cutoff frequency that we choose. For example, to de-noise a speech signal we might choose ωL = 2π2400/Fs, because most speech energy is below 2400Hz. This definition gives: LI(ω) =

  • 1

|ω| ≤ ωL

  • therwise
slide-8
SLIDE 8

DTFT Ideal LPF Ideal HPF Ideal BPF Finite-Length Even Length Summary

Ideal Lowpass Filter

slide-9
SLIDE 9

DTFT Ideal LPF Ideal HPF Ideal BPF Finite-Length Even Length Summary

How can we implement an ideal LPF?

1 Use np.fft.fft to find X[k], set Y [k] = X[k] only for

2πk N < ωL, then use np.fft.ifft to convert back into the

time domain?

It sounds easy, but. . . np.fft.fft is finite length, whereas the DTFT is infinite

  • length. Truncation to finite length causes artifacts.

2 Use pencil and paper to inverse DTFT LI(ω) to lI[n], then use

np.convolve to convolve lI[n] with x[n].

It sounds more difficult. But actually, we only need to find lI[n] once, and then we’ll be able to use the same formula for ever afterward. This method turns out to be both easier and more effective in practice.

slide-10
SLIDE 10

DTFT Ideal LPF Ideal HPF Ideal BPF Finite-Length Even Length Summary

Inverse DTFT of LI(ω)

The ideal LPF is LI(ω) =

  • 1

|ω| ≤ ωL

  • therwise

The inverse DTFT is lI[n] = 1 2π π

−π

LI(ω)ejωndω Combining those two equations gives lI[n] = 1 2π ωL

−ωL

ejωndω

slide-11
SLIDE 11

DTFT Ideal LPF Ideal HPF Ideal BPF Finite-Length Even Length Summary

Solving the integral

The ideal LPF is lI[n] = 1 2π ωL

−ωL

ejωndω = 1 2π 1 jn ejωnωL

−ωL = 1

2π 1 jn

  • (2j sin(ωLn))

So lI[n] = sin(ωLn) πn

slide-12
SLIDE 12

DTFT Ideal LPF Ideal HPF Ideal BPF Finite-Length Even Length Summary

lI[n] = sin(ωLn)

πn

sin(ωLn) πn

is undefined when n = 0 limn→0

sin(ωLn) πn

= ωL

π

So let’s define lI[0] = ωL

π .

slide-13
SLIDE 13

DTFT Ideal LPF Ideal HPF Ideal BPF Finite-Length Even Length Summary

lI[n] = sin(ωLn)

πn

slide-14
SLIDE 14

DTFT Ideal LPF Ideal HPF Ideal BPF Finite-Length Even Length Summary

Outline

1

Review: DTFT

2

Ideal Lowpass Filter

3

Ideal Highpass Filter

4

Ideal Bandpass Filter

5

Realistic Filters: Finite Length

6

Realistic Filters: Even Length

7

Summary

slide-15
SLIDE 15

DTFT Ideal LPF Ideal HPF Ideal BPF Finite-Length Even Length Summary

Ideal Highpass Filter An ideal high-pass filter passes all frequencies above ωH: HI(ω) =

  • 1

|ω| > ωH

  • therwise

Ideal Highpass Filter

slide-16
SLIDE 16

DTFT Ideal LPF Ideal HPF Ideal BPF Finite-Length Even Length Summary

Ideal Highpass Filter

. . . except for one problem: H(ω) is periodic with a period of 2π.

slide-17
SLIDE 17

DTFT Ideal LPF Ideal HPF Ideal BPF Finite-Length Even Length Summary

The highest frequency is ω = π

The highest frequency, in discrete time, is ω = π. Frequencies that seem higher, like ω = 1.1π, are actually lower. This phenomenon is called “aliasing.”

slide-18
SLIDE 18

DTFT Ideal LPF Ideal HPF Ideal BPF Finite-Length Even Length Summary

Redefining “Lowpass” and “Highpass”

Let’s redefine “lowpass” and “highpass.” The ideal LPF is LI(ω) =

  • 1

|ω| ≤ ωL, ωL < |ω| ≤ π. The ideal HPF is HI(ω) =

  • |ω| < ωH,

1 ωH ≤ |ω| ≤ π. Both of them are periodic with period 2π.

slide-19
SLIDE 19

DTFT Ideal LPF Ideal HPF Ideal BPF Finite-Length Even Length Summary

Inverse DTFT of HI(ω)

The easiest way to find hI[n] is to use linearity: HI(ω) = 1 − LI(ω) Therefore: hI[n] = δ[n] − lI[n] = δ[n] − sin(ωHn) πn

slide-20
SLIDE 20

DTFT Ideal LPF Ideal HPF Ideal BPF Finite-Length Even Length Summary

hI[n] = δ[n] − sin(ωHn)

πn

slide-21
SLIDE 21

DTFT Ideal LPF Ideal HPF Ideal BPF Finite-Length Even Length Summary

hI[n] = δ[n] − sin(ωLn)

πn

slide-22
SLIDE 22

DTFT Ideal LPF Ideal HPF Ideal BPF Finite-Length Even Length Summary

Outline

1

Review: DTFT

2

Ideal Lowpass Filter

3

Ideal Highpass Filter

4

Ideal Bandpass Filter

5

Realistic Filters: Finite Length

6

Realistic Filters: Even Length

7

Summary

slide-23
SLIDE 23

DTFT Ideal LPF Ideal HPF Ideal BPF Finite-Length Even Length Summary

Ideal Bandpass Filter An ideal band-pass filter passes all frequencies between ωH and ωL: BI(ω) =

  • 1

ωH ≤ |ω| ≤ ωL

  • therwise

(and, of course, it’s also periodic with period 2π). Ideal Bandpass Filter

slide-24
SLIDE 24

DTFT Ideal LPF Ideal HPF Ideal BPF Finite-Length Even Length Summary

Inverse DTFT of BI(ω)

The easiest way to find bI[n] is to use linearity: BI(ω) = LI(ω|ωL) − LI(ω|ωH) Therefore: bI[n] = sin(ωLn) πn − sin(ωHn) πn

slide-25
SLIDE 25

DTFT Ideal LPF Ideal HPF Ideal BPF Finite-Length Even Length Summary

bI[n] = sin(ωLn)

πn

− sin(ωHn)

πn

slide-26
SLIDE 26

DTFT Ideal LPF Ideal HPF Ideal BPF Finite-Length Even Length Summary

bI[n] = sin(ωLn)

πn

− sin(ωHn)

πn

slide-27
SLIDE 27

DTFT Ideal LPF Ideal HPF Ideal BPF Finite-Length Even Length Summary

Outline

1

Review: DTFT

2

Ideal Lowpass Filter

3

Ideal Highpass Filter

4

Ideal Bandpass Filter

5

Realistic Filters: Finite Length

6

Realistic Filters: Even Length

7

Summary

slide-28
SLIDE 28

DTFT Ideal LPF Ideal HPF Ideal BPF Finite-Length Even Length Summary

Ideal Filters are Infinitely Long

All of the ideal filters, lI[n] and so on, are infinitely long. In videos so far, I’ve faked infinite length by just making lI[n] more than twice as long as x[n]. If x[n] is very long (say, a 24-hour audio recording), you probably don’t want to do that (computation=expensive)

slide-29
SLIDE 29

DTFT Ideal LPF Ideal HPF Ideal BPF Finite-Length Even Length Summary

Finite Length by Truncation

We can force lI[n] to be finite length by just truncating it, say, to 2M + 1 samples: l[n] =

  • lI[n]

−M ≤ n ≤ M

  • therwise
slide-30
SLIDE 30

DTFT Ideal LPF Ideal HPF Ideal BPF Finite-Length Even Length Summary

Truncation Causes Frequency Artifacts

The problem with truncation is that it causes artifacts.

slide-31
SLIDE 31

DTFT Ideal LPF Ideal HPF Ideal BPF Finite-Length Even Length Summary

Windowing Reduces the Artifacts

We can reduce the artifacts (a lot) by windowing lI[n], instead of just truncating it: l[n] =

  • w[n]lI[n]

−M ≤ n ≤ M

  • therwise

where w[n] is a window that tapers smoothly down to near zero at n = ±M, e.g., a Hamming window: w[n] = 0.54 + 0.46 cos 2πn 2M

slide-32
SLIDE 32

DTFT Ideal LPF Ideal HPF Ideal BPF Finite-Length Even Length Summary

Windowing a Lowpass Filter

slide-33
SLIDE 33

DTFT Ideal LPF Ideal HPF Ideal BPF Finite-Length Even Length Summary

Windowing Reduces the Artifacts

slide-34
SLIDE 34

DTFT Ideal LPF Ideal HPF Ideal BPF Finite-Length Even Length Summary

Outline

1

Review: DTFT

2

Ideal Lowpass Filter

3

Ideal Highpass Filter

4

Ideal Bandpass Filter

5

Realistic Filters: Finite Length

6

Realistic Filters: Even Length

7

Summary

slide-35
SLIDE 35

DTFT Ideal LPF Ideal HPF Ideal BPF Finite-Length Even Length Summary

Even Length Filters

Often, we’d like our filter l[n] to be even length, e.g., 200 samples long, or 256 samples. We can’t do that with this definition: l[n] =

  • w[n]lI[n]

−M ≤ n ≤ M

  • therwise

. . . because 2M + 1 is always an odd number.

slide-36
SLIDE 36

DTFT Ideal LPF Ideal HPF Ideal BPF Finite-Length Even Length Summary

Even Length Filters using Delay

We can solve this problem using the time-shift property of the DTFT: z[n] = x[n − n0] ↔ Z(ω) = e−jωn0X(ω)

slide-37
SLIDE 37

DTFT Ideal LPF Ideal HPF Ideal BPF Finite-Length Even Length Summary

Even Length Filters using Delay

Let’s delay the ideal filter by exactly M − 0.5 samples, for any integer M: z[n] = lI [n − (M − 0.5)] = sin

  • ω
  • n − M + 1

2

  • π
  • n − M + 1

2

  • I know that sounds weird. But notice the symmetry it gives us.

The whole signal is symmetric w.r.t. sample n = M − 0.5. So z[M − 1] = z[M], and z[M − 2] = z[M + 1], and so one, all the way out to z[0] = z[2M − 1] = sin

  • ω
  • M − 1

2

  • π
  • M − 1

2

slide-38
SLIDE 38

DTFT Ideal LPF Ideal HPF Ideal BPF Finite-Length Even Length Summary

Even Length Filters using Delay

slide-39
SLIDE 39

DTFT Ideal LPF Ideal HPF Ideal BPF Finite-Length Even Length Summary

Even Length Filters using Delay

Apply the time delay property: z[n] = lI [n − (M − 0.5)] ↔ Z(ω) = e−jω(M−0.5)LI(ω), and then notice that |e−jω(M−0.5)| = 1 So |Z(ω)| = |LI(ω)|

slide-40
SLIDE 40

DTFT Ideal LPF Ideal HPF Ideal BPF Finite-Length Even Length Summary

Even Length Filters using Delay

slide-41
SLIDE 41

DTFT Ideal LPF Ideal HPF Ideal BPF Finite-Length Even Length Summary

Even Length Filters using Delay and Windowing

Now we can create an even-length filter by windowing the delayed filter: l[n] =

  • w[n]lI [n − (M − 0.5)]

0 ≤ n ≤ (2M − 1)

  • therwise

where w[n] is a Hamming window defined for the samples 0 ≤ m ≤ 2M − 1: w[n] = 0.54 − 0.46 cos

  • 2πn

2M − 1

slide-42
SLIDE 42

DTFT Ideal LPF Ideal HPF Ideal BPF Finite-Length Even Length Summary

Even Length Filters using Delay and Windowing

slide-43
SLIDE 43

DTFT Ideal LPF Ideal HPF Ideal BPF Finite-Length Even Length Summary

Even Length Filters using Delay and Windowing

slide-44
SLIDE 44

DTFT Ideal LPF Ideal HPF Ideal BPF Finite-Length Even Length Summary

lI[n] = sin(ωLn)

πn

slide-45
SLIDE 45

DTFT Ideal LPF Ideal HPF Ideal BPF Finite-Length Even Length Summary

Outline

1

Review: DTFT

2

Ideal Lowpass Filter

3

Ideal Highpass Filter

4

Ideal Bandpass Filter

5

Realistic Filters: Finite Length

6

Realistic Filters: Even Length

7

Summary

slide-46
SLIDE 46

DTFT Ideal LPF Ideal HPF Ideal BPF Finite-Length Even Length Summary

Summary: Ideal Filters

Ideal Lowpass Filter: LI(ω) =

  • 1

|ω| ≤ ωL, ωL < |ω| ≤ π. ↔ lI[m] = sin(ωLn) πn Ideal Highpass Filter: HI(ω) = 1 − LI(ω) ↔ hI[n] = δ[n] − sin(ωHn) πn Ideal Bandpass Filter: BI(ω) = LI(ω|ωL)−LI(ω|ωH) ↔ bI[n] = sin(ωLn) πn −sin(ωHn) πn

slide-47
SLIDE 47

DTFT Ideal LPF Ideal HPF Ideal BPF Finite-Length Even Length Summary

Summary: Practical Filters

Odd Length: h[n] =

  • hI[n]w[n]

−M ≤ n ≤ M

  • therwise

Even Length: h[n] =

  • hI [n − (M − 0.5)] w[n]

0 ≤ n ≤ 2M − 1

  • therwise

where w[n] is a window with tapered ends, e.g., w[n] =

  • 0.54 − 0.46 cos
  • 2πn

L−1

  • 0 ≤ n ≤ L − 1
  • therwise