Live data from Hacker News

Why is it a bad idea to filter by zeroing out FFT bins? (2020)

dsp.stackexchange.com

1–10 of 43 posts

Re: Why is it a bad idea to filter by zeroing out FFT bins? (2020)

#3

While it’s not necessarily a “bad idea” depending upon your application, you may be able to do “better” in the side lobes using masking functions (windows) other than rectangles, which is what zeroing is. See hanning, hamming, etc.

Said another way, you're making a filter. Zeroing out FFT bins is a brickwall filter. Brickwall filters have poor frequency and amplitude accuracy if you are trying to preserve the signal in the passband. A Flattop filter will give maximum amplitude accuracy, a gaussian filter will give good amplitude and excellent frequency accuracy. Other filter types can be implemented to require less computation for resource constrained systems under certain circumstances. Zeroing is the simplest filter to implement in code, but it's performance is essentially the worst from a signals point of view.

Re: Why is it a bad idea to filter by zeroing out FFT bins? (2020)

#5

While it’s not necessarily a “bad idea” depending upon your application, you may be able to do “better” in the side lobes using masking functions (windows) other than rectangles, which is what zeroing is. See hanning, hamming, etc.

I heard a maxim that declares: "a sharp discontinuity in the frequency domain equals ringing in the time domain, and a sharp discontintuity in the time domain equals ringing in the frequency domain".

In other words it will cause ringing (oscillations, Gibbs phenomenon) in the time domain (for signals, or spatial domain for images). If instead you want a smoother result, you will need to use oscillation in the FFT domain when zeroing out bins. As that is hard to do perfectly, it's easier to specify a window function (or a classically derived FIR or IIR filter kernel) and convolve it with your input signal / image. It is also more efficient to do online when the data is streaming.

Re: Why is it a bad idea to filter by zeroing out FFT bins? (2020)

#7
I disagree that it's always a bad idea. If you didn't have real data in those bins to begin with, then the absence of ringing was never real either. You're just choosing between interpolation strategies to fill in the data you deleted. You have to realize that whatever you do, you're making up data. One could say that you're taking out your dry erase marker and writing in your priors. For image processing, you probably don't have ringing in the scene you took a picture of, so you don't want to zero bins. In other signal processing contexts where you might actually have no signal to measure in certain bins, and sometimes you want to zero them.

Re: Why is it a bad idea to filter by zeroing out FFT bins? (2020)

#8

While it’s not necessarily a “bad idea” depending upon your application, you may be able to do “better” in the side lobes using masking functions (windows) other than rectangles, which is what zeroing is. See hanning, hamming, etc.

Said another way, you're making a filter. Zeroing out FFT bins is a brickwall filter. Brickwall filters have poor frequency and amplitude accuracy if you are trying to preserve the signal in the passband. A Flattop filter will give maximum amplitude accuracy, a gaussian filter will give good amplitude and excellent frequency accuracy. Other filter types can be implemented to require less computation for resource cons…

>Brickwall filters have poor frequency and amplitude accuracy if you are trying to preserve the signal in the passband.

Brickwall filters have the greatest possible frequency accuracy. I think you might be getting filters mixed up with windows - a boxcar window does not have the best frequency accuracy.

Re: Why is it a bad idea to filter by zeroing out FFT bins? (2020)

#9

Earlier quoted context omitted.

Said another way, you're making a filter. Zeroing out FFT bins is a brickwall filter. Brickwall filters have poor frequency and amplitude accuracy if you are trying to preserve the signal in the passband. A Flattop filter will give maximum amplitude accuracy, a gaussian filter will give good amplitude and excellent frequency accuracy. Other filter types can be implemented to require less computation for resource cons…

> Brickwall filters have poor frequency and amplitude accuracy if you are trying to preserve the signal in the passband. Brickwall filters have the greatest possible frequency accuracy. I think you might be getting filters mixed up with windows - a boxcar window does not have the best frequency accuracy.

It can work fine if you implement an FIR with sufficient bins.

Re: Why is it a bad idea to filter by zeroing out FFT bins? (2020)

#10
post #6

This would be a really good interview question!

I think it's a terrible interview question, unless maybe you're hiring an electrical engineer.

It's not something you can expect someone to reason through from the basics, and it's not something I'd expect someone to know unless they've worked on problems involving the technique.

Post reply on HN