DSPRelated.com
Forums

FFT based filtering question

Started by wyonghao February 23, 2009
Dear All,

I have a simple question regarding FFT based filtering. Most text tells us
to do the FFT based filtering is multiplication of "FFT of signal" and "FFT
of FIR filter kernel."

I understand that. My question is, in some simple situation, can we
directly manipulate the frequency result of signal. For example, if do a
low pass filtering, I obtained FFT of a signal, then just simply set all
value above Fc as zeros, and do a iFFt to obtain the time domain signal?

You can regard this operation as multiply spectrum of signal with the
spectrum of ideal Low pass filter i.e brick wall filter (amplitude 1 below
cutoff frequency, and zero above cutoff frequency). In this way, we don't
need to do fft of filter kernel?

Am I missing something here, or we can do this with confidence?

Your inputs will be appreciated.

Many thanks

Y.Wang 


On 23 Feb, 14:44, "wyonghao" <wyong...@gmail.com> wrote:
> Dear All, > > I have a simple question regarding FFT based filtering. Most text tells us > to do the FFT based filtering is multiplication of "FFT of signal" and "FFT > of FIR filter kernel." > > I understand that. My question is, in some simple situation, can we > directly manipulate the frequency result of signal. For example, if do a > low pass filtering, I obtained FFT of a signal, then just simply set all > value above Fc as zeros, and do a iFFt to obtain the time domain signal? > > You can regard this operation as multiply spectrum of signal with the > spectrum of ideal Low pass filter i.e brick wall filter (amplitude 1 below > cutoff frequency, and zero above cutoff frequency). In this way, we don't > need to do fft of filter kernel? > > Am I missing something here, or we can do this with confidence?
Technically speaking, you can do this 'with confidence'. The end result will, however, be severely messed up. The problem is that this approach leaves the filter response undefined between the frequencies in the DFT, which means you have no control over the filter response. The filter design methods take care of the responses ove continyous bands, which gives non-iedal results but in return avoid lots of problems. Rune
On Mon, 23 Feb 2009 06:17:10 -0800, Rune Allnor wrote:

> On 23 Feb, 14:44, "wyonghao" <wyong...@gmail.com> wrote: >> Dear All, >> >> I have a simple question regarding FFT based filtering. Most text tells >> us to do the FFT based filtering is multiplication of "FFT of signal" >> and "FFT of FIR filter kernel." >> >> I understand that. My question is, in some simple situation, can we >> directly manipulate the frequency result of signal. For example, if do >> a low pass filtering, I obtained FFT of a signal, then just simply set >> all value above Fc as zeros, and do a iFFt to obtain the time domain >> signal? >> >> You can regard this operation as multiply spectrum of signal with the >> spectrum of ideal Low pass filter i.e brick wall filter (amplitude 1 >> below cutoff frequency, and zero above cutoff frequency). In this way, >> we don't need to do fft of filter kernel? >> >> Am I missing something here, or we can do this with confidence? > > Technically speaking, you can do this 'with confidence'. The end result > will, however, be severely messed up. The problem is that this approach > leaves the filter response undefined between the frequencies in the DFT, > which means you have no control over the filter response. > > The filter design methods take care of the responses ove continyous > bands, which gives non-iedal results but in return avoid lots of > problems. > > Rune
Actually, this technique _does_ work if you have a signal with lots of low-frequency content, and not too much noise at the higher frequencies. A far better way, if you don't want to FFT the filter kernel, is to start with a frequency-domain filter specification that you know isn't going to result in a lot of ringing, like a flat-top filter with raised cosine ends to smoothly bring the frequency response to zero. The first technique (just hack off the spectrum) should _always_ be considered a quick & dirty expedient to take a better look at data; the second one may actually make sense in a production product, after you do a whole lot of verification. -- http://www.wescottdesign.com
On 23 Feb., 16:40, Tim Wescott <t...@seemywebsite.com> wrote:
> On Mon, 23 Feb 2009 06:17:10 -0800, Rune Allnor wrote: > > On 23 Feb, 14:44, "wyonghao" <wyong...@gmail.com> wrote: > >> Dear All, > > >> I have a simple question regarding FFT based filtering. Most text tells > >> us to do the FFT based filtering is multiplication of "FFT of signal" > >> and "FFT of FIR filter kernel." > > >> I understand that. My question is, in some simple situation, can we > >> directly manipulate the frequency result of signal. For example, if do > >> a low pass filtering, I obtained FFT of a signal, then just simply set > >> all value above Fc as zeros, and do a iFFt to obtain the time domain > >> signal? > > >> You can regard this operation as multiply spectrum of signal with the > >> spectrum of ideal Low pass filter i.e brick wall filter (amplitude 1 > >> below cutoff frequency, and zero above cutoff frequency). In this way, > >> we don't need to do fft of filter kernel? > > >> Am I missing something here, or we can do this with confidence? > > > Technically speaking, you can do this 'with confidence'. The end result > > will, however, be severely messed up. The problem is that this approach > > leaves the filter response undefined between the frequencies in the DFT, > > which means you have no control over the filter response. > > > The filter design methods take care of the responses ove continyous > > bands, which gives non-iedal results but in return avoid lots of > > problems. > > > Rune > > Actually, this technique _does_ work if you have a signal with lots of > low-frequency content, and not too much noise at the higher frequencies. > > A far better way, if you don't want to FFT the filter kernel, is to start > with a frequency-domain filter specification that you know isn't going to > result in a lot of ringing, like a flat-top filter with raised cosine > ends to smoothly bring the frequency response to zero. > > The first technique (just hack off the spectrum) should _always_ be > considered a quick & dirty expedient to take a better look at data; the > second one may actually make sense in a production product, after you do > a whole lot of verification.
To make this approach a little less dirty but still quick one can introduce a "transition sample" (O&S75, p. 253), trading steepness for stopband attenuation. Appearently, the value 0f 0.3904 seems to be the best one with highes stopband attenuation with one single transition sample (for the N=65 case). The computation can be made for any N, I suppose. Regards, Andor
On Feb 24, 2:44&#4294967295;am, "wyonghao" <wyong...@gmail.com> wrote:
> Dear All, > > I have a simple question regarding FFT based filtering. Most text tells us > to do the FFT based filtering is multiplication of "FFT of signal" and "FFT > of FIR filter kernel." > > I understand that. My question is, in some simple situation, can we > directly manipulate the frequency result of signal. For example, if do a > low pass filtering, I obtained FFT of a signal, then just simply set all > value above Fc as zeros, and do a iFFt to obtain the time domain signal? > > You can regard this operation as multiply spectrum of signal with the > spectrum of ideal Low pass filter i.e brick wall filter (amplitude 1 below > cutoff frequency, and zero above cutoff frequency). In this way, we don't > need to do fft of filter kernel? > > Am I missing something here, or we can do this with confidence? > > Your inputs will be appreciated. > > Many thanks > > Y.Wang
Yes it works but there is a problem. The resolution you get is fs/N so to be ideal you would need an infinite number of FFT points since for a brick wall you need to come down vertically and this is not really possible to do. H
Rune Allnor wrote:
> On 23 Feb, 14:44, "wyonghao" <wyong...@gmail.com> wrote: >> Dear All, >> >> I have a simple question regarding FFT based filtering. Most text tells us >> to do the FFT based filtering is multiplication of "FFT of signal" and "FFT >> of FIR filter kernel." >> >> I understand that. My question is, in some simple situation, can we >> directly manipulate the frequency result of signal. For example, if do a >> low pass filtering, I obtained FFT of a signal, then just simply set all >> value above Fc as zeros, and do a iFFt to obtain the time domain signal? >> >> You can regard this operation as multiply spectrum of signal with the >> spectrum of ideal Low pass filter i.e brick wall filter (amplitude 1 below >> cutoff frequency, and zero above cutoff frequency). In this way, we don't >> need to do fft of filter kernel? >> >> Am I missing something here, or we can do this with confidence? > > Technically speaking, you can do this 'with confidence'. > The end result will, however, be severely messed up. > The problem is that this approach leaves the filter response > undefined between the frequencies in the DFT, which means > you have no control over the filter response. > > The filter design methods take care of the responses ove > continyous bands, which gives non-iedal results but in > return avoid lots of problems.
I'll put that another way. First note that "the FFT of the filter kernel" means the FFT of the *entire* filter kernel. The kernel of a brick-wall filter is very long before its magnitude falls below i LSB, probably longer than the IFFT you contemplate. That means you will get temporal aliasing, which really messes up the response. Second, note that even a brick-wall filter that works introduces rather severe ringing. The result of these combined blemishes is precisely as Rune described. Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
wyonghao wrote:
> Dear All, > > I have a simple question regarding FFT based filtering. Most text > tells us to do the FFT based filtering is multiplication of "FFT of > signal" and "FFT of FIR filter kernel." > > I understand that. My question is, in some simple situation, can we > directly manipulate the frequency result of signal. For example, if > do a low pass filtering, I obtained FFT of a signal, then just simply > set all value above Fc as zeros, and do a iFFt to obtain the time > domain signal? > > You can regard this operation as multiply spectrum of signal with the > spectrum of ideal Low pass filter i.e brick wall filter (amplitude 1 > below cutoff frequency, and zero above cutoff frequency). In this > way, we don't need to do fft of filter kernel? > > Am I missing something here, or we can do this with confidence? > > Your inputs will be appreciated. > > Many thanks > > Y.Wang
There *are* situations where you can do this. Mostly they would be where there is little or no energy at the transition point of the brick wall. An example is in interpolation filtering. You lowpass the data one time with the kernel of an actual lowpass filter... just to make sure there is little energy in some of the region around fs/2. Then, you replicate the spectral data one time so the sample rate is 2fs and there is a complete spectrum around fs. Then, delete the data (with a brick wall filter cutoff at fs/2 where the first filter removed most of the energy there) around fs keeping the data at zero and at 2fs, thereby increasing the sample rate from fs to 2fs and thereby increasing the number of points in time within the same temporal epoch. This operation is effectively a brick wall as if you'd applied a half-band filter and it works pretty well because there are no sharp transitions created. The transition is in the stopband of the first lowpass. Then the operation can be repeated or done for a higher multiple than 2. Admittedly this is a particular case where it works. Otherwise heed the advice of others here. Fred
On 23 Feb., 14:44, "wyonghao" <wyong...@gmail.com> wrote:
> Dear All, > > I have a simple question regarding FFT based filtering. Most text tells us > to do the FFT based filtering is multiplication of "FFT of signal" and "FFT > of FIR filter kernel."
That's hopefully not the whole text book story. What about overlap +add? http://en.wikipedia.org/wiki/Overlap-add_method
> I understand that. My question is, in some simple situation, can we > directly manipulate the frequency result of signal. For example, if do a > low pass filtering, I obtained FFT of a signal, then just simply set all > value above Fc as zeros, and do a iFFt to obtain the time domain signal?
Sure, you can do that. Depending on what you do exactly in terms of overlap+add you'll get artefacts of varying severity. Artefacts? What artefacts? Well, multiplication of two DFT spectra is equivalent to circular convolution. The error introduced by careless multiplication is also known as "wrap around error".
> You can regard this operation as multiply spectrum of signal with the > spectrum of ideal Low pass filter i.e brick wall filter (amplitude 1 below > cutoff frequency, and zero above cutoff frequency). In this way, we don't > need to do fft of filter kernel?
You only have to calculate the FFT of the kernel once. After that it's practically the same. The problem with your approach is that you ignore the wrap around error. If you start with known kernel you know its length and hence have a good idea of how to avoid the wrap around error.
> Am I missing something here, or we can do this with confidence?
No. Be sure to understand circular convolution and check out overlap +add Cheers! SG