DSPRelated.com
Forums

Why don't we just zero out FFT bins?

Started by bmh161 April 9, 2009
On Apr 9, 6:22&#4294967295;am, "bmh161" <bmh...@yahoo.com> wrote:
> This is probably a stupid question but, well, I'm not all that smart... > > Instead of going through all the trouble of designing complicated digital > filters, why don't we just pick the frequencies that we want to supress and > replace those bins in the FFT with zeros?
Because any real frequency in which you are likely to be interested in suppressing is very probably not represented by any bin in your FFT. imho. ymmv. http://www.nicholson.com/fftmisconceptions.html
bmh161 wrote:
>> This is probably a stupid question but, well, I'm not all that smart... >> >> Instead of going through all the trouble of designing complicated > digital >> filters, why don't we just pick the frequencies that we want to supress > and >> replace those bins in the FFT with zeros? >> >> >> > > Then, with the undesirable frequencies zeroed out, take the inverse FFT to > get back to the time domain.
Something like this is done in 'overlap-save' and 'overlap-add' FFT / IFFT filters, but a little more care need so be taken in specifying the frequency response. A requirement of these techniques is that the impulse response of the filter must be shorter than the number of bins in the FFT. (N/2 samples long for example.) If you simply zero-out particular frequency bins in the FFT you are effectively specifying a filter that has a very steep response in the frequency domain. This filter will have an impulse response that is certain to be too long. In this situation, severe noise and distortion will be introduced into the filter output. You need to ensure that the frequency response that you are specifying implies a filter with an acceptably short impulse response. Unfortunately, to do this you must do a FIR filter design even though you end up using the number of coefficients in the filter, but not the coefficients themselves. Regards, John
"bmh161" <bmh161@yahoo.com> a &#4294967295;crit dans le message de 
news: -9CdnboVQ4Mya0DUnZ2dnUVZ_vednZ2d@giganews.com...
> This is probably a stupid question but, well, I'm not all that smart... > > Instead of going through all the trouble of designing complicated digital > filters, why don't we just pick the frequencies that we want to supress > and > replace those bins in the FFT with zeros? >
Doing what you propose (FFT of the signal, multiplying with a frequency mask, IFFT) gives EXACTLY the same result mathematically speaking than a FIR filter, its just another way to calculate it. In a nutshell : output = IFFT (FFT(input) x MASK) = convol (IFFT(FFT(input) x IFFT(MASK)) = convol (input x IMPULSEREPONSE) = FIR(input, IMPULSERESPONSE)... However, as explained by the other posts, if the frequency mask is just rectangular then your actual frequency response may not be adequate between the frequency FFT bins, that's why windowing techniques are welcome. You can read an article I've published in 2007 in Circuit Cellar for more explanations on links between FFT and FIR (#207, october 2007, p. 70, "The Darker Side : No Fear with FIR"). Friendly, Robert Lacoste www.alciom.com
On 10 Apr, 02:17, Rick Lyons <R.Lyons@_BOGUS_ieee.org> wrote:
> On Thu, 09 Apr 2009 08:22:55 -0500, "bmh161" <bmh...@yahoo.com> wrote:
> >Instead of going through all the trouble of designing complicated digital > >filters, why don't we just pick the frequencies that we want to supress and > >replace those bins in the FFT with zeros?
...
> &#4294967295;I just wanted to say that > your question is sensible and that we, the DSP guys here, > should investigate the process of freq-domain filtering > in detail
Rick, did we read the same post? The question is not why frequency domain filtering is a bad idea, but why one doesn't use the naive, 'obvious' specs for the filters. I commented on a similar question not too long ago: http://groups.google.no/group/comp.dsp/msg/2d4bd5dfb25b5a23 Such questions are covered in most DSP texts - I wouldn't be surprised if you touched on the subject already. If not, the issue might be worth half a page's comments in your 3rd edition, as your book is the first entry point into DSP for lots of users. Teachning students how to think 'right' is an admirable (and difficult!) task; warning against how to think 'wrong' can only help the effort. Rune
On Apr 9, 9:22&#4294967295;am, "bmh161" <bmh...@yahoo.com> wrote:
> This is probably a stupid question but, well, I'm not all that smart... > > Instead of going through all the trouble of designing complicated digital > filters, why don't we just pick the frequencies that we want to supress and > replace those bins in the FFT with zeros?
A subtle point here (which is implicit in alot of the criticism mentioned above), is that the frequency resolution and center frequencies of your method is changes with your FFT size. Consider for example, the case of designing a notch filter. Lets say you want to cancel a 60 Hz sinuisoid component. Then for different FFT sizes you will be cancelling the following frequency bands as well (assuming Fs =44100): N= 128 -> 0<= f < 344 Hz frequencies set to 0 N= 256 -> 0<= f < 172 Hz set to 0 N=1024 -> 43<= f < 86 Hz set to 0 The alternative is do desing a notch filter whos resolution is "independent" of the sample size ie, cW = cos(2*pi*60/44100); b=[1 -2*cW 1]; This can be important in case you want to make the sample size variable on some applications (ie, say you are processing speech signals and the speech segments are of different lengths) but you want the filter to be fixed.
On 9 Apr., 15:22, "bmh161" <bmh...@yahoo.com> wrote:
> Instead of going through all the trouble of designing complicated digital > filters, why don't we just pick the frequencies that we want to supress and > replace those bins in the FFT with zeros?
It's equivalent to circular convolution with a brickwall lowpass filter (infinite impulse response). The issue is you need to fight the "wrap-around error". This becomes easy if the filter's impulse response is finite and known ... Cheers! SG
On Apr 11, 3:12&#4294967295;pm, Neu <ikarosi...@hotmail.com> wrote:
> On Apr 9, 9:22&#4294967295;am, "bmh161" <bmh...@yahoo.com> wrote: > > > This is probably a stupid question but, well, I'm not all that smart... > > > Instead of going through all the trouble of designing complicated digital > > filters, why don't we just pick the frequencies that we want to supress and > > replace those bins in the FFT with zeros? > > A subtle point here (which is implicit in alot of the criticism > mentioned above), is that the frequency resolution and center > frequencies of your method is changes with your FFT size. Consider for > example, the case of designing a notch filter. Lets say you want to > cancel a 60 Hz sinuisoid component. Then for different FFT sizes you > will be cancelling the following frequency bands as well (assuming Fs > =44100): > > N= 128 &#4294967295;-> &#4294967295;0<= f < &#4294967295;344 Hz &#4294967295; &#4294967295;frequencies set to 0 > > N= 256 &#4294967295; -> &#4294967295;0<= f < 172 Hz &#4294967295; set to 0 > > N=1024 &#4294967295; -> &#4294967295;43<= f < 86 Hz &#4294967295; set to 0
These bands will not actually be set to 0; one frequency within these bands will and rest will be attenuated to some extent.
> > The alternative is do desing a notch filter whos resolution is > "independent" of the sample size ie, > > cW = cos(2*pi*60/44100); > b=[1 -2*cW 1];
Really horrible filter response; much worse than zeroing one point in the FFT. Plot the response. You will see.
> > This can be important in case you want to make the sample size > variable on some applications (ie, say you are processing speech > signals and the speech segments are of different lengths) but you want > the filter to be fixed.
spamfree
Neu <ikarosilva@hotmail.com> wrote:
> On Apr 9, 9:22?am, "bmh161" <bmh...@yahoo.com> wrote:
>> Instead of going through all the trouble of designing complicated digital >> filters, why don't we just pick the frequencies that we want to supress and >> replace those bins in the FFT with zeros?
> A subtle point here (which is implicit in alot of the criticism > mentioned above), is that the frequency resolution and center > frequencies of your method is changes with your FFT size. Consider for > example, the case of designing a notch filter. Lets say you want to > cancel a 60 Hz sinuisoid component. Then for different FFT sizes you > will be cancelling the following frequency bands as well (assuming Fs > =44100):
> N=1024 -> 43<= f < 86 Hz set to 0
At 44100 Hz, 1024 points is about 1/40th of a second, which doesn't sound very realistic. Consider a five minute CD track, 5*60*44100, 13230000 points, maybe zero pad up to the next power of two or more. Then the bins are much smaller. -- glen

c...@claysturner.com wrote:
> On Apr 9, 9:29 am, "bmh161" <bmh...@yahoo.com> wrote: > > >This is probably a stupid question but, well, I'm not all that smart... > > > > >Instead of going through all the trouble of designing complicated > > digital > > >filters, why don't we just pick the frequencies that we want to supress > > and > > >replace those bins in the FFT with zeros? > > > > Then, with the undesirable frequencies zeroed out, take the inverse FFT to > > get back to the time domain. > > Because the resulting frequency response is often quite awful. If you > design a digital filter, then you have control over its response. > > Clay
you have control over an FFT frequency response via windowing, an FFT is a digital filter

bmh161 wrote:
> >This is probably a stupid question but, well, I'm not all that smart... > > > >Instead of going through all the trouble of designing complicated > digital > >filters, why don't we just pick the frequencies that we want to supress > and > >replace those bins in the FFT with zeros? > > > > > > > > Then, with the undesirable frequencies zeroed out, take the inverse FFT to > get back to the time domain.
you certainly can, an N point FFT is just bank of N notch filters, with frequency response controlled by the window. It's just that, in most cases, a simple 20 tap FIR or 6 pole IIR filter will do the job instead of performing a 4096 point FFT/IFFT.