Hacker News new | ask | show | jobs
by jschveibinz 1863 days ago
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.
2 comments

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.

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.
>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.