DSPRelated.com
Forums

Low pass filter

Started by rob83 September 12, 2007
Hello everybody,

I am new to new to DSP. So if my question(s) are fundamentally wrong or
just too naive I apologize in advance.
This is the problem I have:

I have an input array of time domain samples (4096) which I feed into an
FFT algorithm. I can compute the inverse FFT and get back my original
data.
I want to apply a low pass filter to get rid of undesired high frequency
components. When I do this (apply FFT,then an Equi-Ripple low pass filter
followed by the inverse FFT)I get a very different output. 

Should't my data go back to the time-domain after an inverse FFT (minus
the noise created by the high frequency componets? 

Regards,
Rob



Hello,

I think there is some misunderstanding about how to apply filtering in
frequency domain.

Here is a simple example how it could be done:
http://www.elisanet.fi/mnentwig/webroot/FFT_filter_example/index.html

-mn

How is the output of you FFT organized?
Unless you have a real-to-complex FFT (which will give you 2048 complex 
frequency domain values), you will get a symmetrical output, so you have 
to mirror your desired frequency response accordingly.

Best regards,

Andre

rob83 wrote:
> Hello everybody, > > I am new to new to DSP. So if my question(s) are fundamentally wrong or > just too naive I apologize in advance. > This is the problem I have: > > I have an input array of time domain samples (4096) which I feed into an > FFT algorithm. I can compute the inverse FFT and get back my original > data. > I want to apply a low pass filter to get rid of undesired high frequency > components. When I do this (apply FFT,then an Equi-Ripple low pass filter > followed by the inverse FFT)I get a very different output. > > Should't my data go back to the time-domain after an inverse FFT (minus > the noise created by the high frequency componets? > > Regards, > Rob > > >
-- -- I am still confused, but on a higher level. - Enrico Fermi
Just to be clear regarding first principles,

To create a low pass filter in the frequency domain, just zero out all the
high frequency values and then IFFT.
(this is equivalent to convolution with a rectangular window, or a simple
sliding average)

If you get that to work, you can do the same with the frequency response of
the filter.

What I think you are doing is applying a time domain convolutional filter to
a frequency domain data set.

To verify this, apply your filter directly to the raw data (no fft) and see
if you get what you expected.

Convolution in the time domain = multiplication in the frequency domain
(assuming you FFT both entities)





"rob83" <roberto_glez83@hotmail.com> wrote in message
news:6budnehatuggUHrbnZ2dnUVZ_gmdnZ2d@giganews.com...
> Hello everybody, > > I am new to new to DSP. So if my question(s) are fundamentally wrong or > just too naive I apologize in advance. > This is the problem I have: > > I have an input array of time domain samples (4096) which I feed into an > FFT algorithm. I can compute the inverse FFT and get back my original > data. > I want to apply a low pass filter to get rid of undesired high frequency > components. When I do this (apply FFT,then an Equi-Ripple low pass filter > followed by the inverse FFT)I get a very different output. > > Should't my data go back to the time-domain after an inverse FFT (minus > the noise created by the high frequency componets? > > Regards, > Rob > > >
On 12 Sep., 13:48, "mnentwig" <mnent...@elisanet.fi> wrote:
> Hello, > > I think there is some misunderstanding about how to apply filtering in > frequency domain. > > Here is a simple example how it could be done: > http://www.elisanet.fi/mnentwig/webroot/FFT_filter_example/index.html
Markus, your example performs circular convolution. Why don't you put up a proper OLS/OLA frequency domain filtering Matlab example? Regars, Andor
>Markus, > >your example performs circular convolution. Why don't you put up a >proper OLS/OLA frequency domain filtering Matlab example? > >Regars, >Andor >
Hello, that's right, most of the code examples on my web site are with regard to cyclic signals (see http://www.elisanet.fi/mnentwig/webroot/cyclic_signals/index.html). For the audio example, the error from the cyclic assumption may be negligible, or manageable with some zero padding (in an engineering sense). Keep in mind, I advertised it as a "simple" example. Of course, if one wants to use FFT filtering in non-cyclic cases, things get much more complicated. An example is FFT in real-time voice processing. But then, the problem is not anymore the FFT filtering as such, but how to use a method that is cyclic on a signal that is not. It is an approximation, and the quality depends solely on the tradeoff from the cyclic-noncyclic problem (or in other words, how well I manage the impossible to localize a signal in both time and frequency). That's why I like this FFT example as it is: Once one has read and understood the small print - "for cyclic signals only" - it is an ideal filter, not an approximation. Cheers Markus PS: I'm not fully on the map regarding OLS: I've got another example for finding the _inverse_ of a filter, both through cyclic FFT - which is sort of a 'hack' - and a least squares solution. But here the discussion was only to -apply- a filter?
>PS: I'm not fully on the map regarding OLS: I've got another example for >finding the _inverse_ of a filter, both through cyclic FFT - which is
sort
>of a 'hack' - and a least squares solution. But here the discussion was >only to -apply- a filter?
Uh-oh... temporary loss of orientation in the acronym jungle It's short for overlap-and-add and overlap-and-save, which are ways to apply FFT to non-cyclic signals. I'm back on the map :) Cheers Markus
Markus wrote:

> Keep in mind, I advertised it as a "simple" example. > Of course, if one wants to use FFT filtering in non-cyclic cases, things > get much more complicated. An example is FFT in real-time voice > processing. > > But then, the problem is not anymore the FFT filtering as such, but how to > use a method that is cyclic on a signal that is not. It is an > approximation, and the quality depends solely on the tradeoff from the > cyclic-noncyclic problem (or in other words, how well I manage the > impossible to localize a signal in both time and frequency).
Not at all. On your website, you write something similar:
> DFT (FFT) is by nature cyclic. Processing a cyclic > signal with DFT methods is lossless and straightforward. > Typically, FFT methods are used on non-periodic signals, > which introduces at least some signal degradation and is > more complicated.
FIR filtering is possible in two ways: either through time-domain convolution, or through frequency-domain multiplication. Neither one is an approximation to the other, both methods are equivalent (up to numerical error, and minds are split on this newsgroup as to which method introduces more error).
> > That's why I like this FFT example as it is: Once one has read and > understood the small print - "for cyclic signals only" - it is an ideal > filter, not an approximation.
OLS/OLA are methods to implement FIR filters, not approximations. If you don't agree, you can start with this: http://www.dspguide.com/ch9/3.htm Regards, Andor
>OLS/OLA are methods to implement FIR filters, not approximations. If >you don't agree, you can start with this: > >http://www.dspguide.com/ch9/3.htm
Right. It implements the convolution on different segments, the superposition principle holds, and we sum them up afterwards. Agree. But the maximum impulse response lenght is tied to the FFT size, right? So let's forget my bloated argument about localization in time/frequency, and I simply say instead "I have to design a finite length FIR filter". My point is: If I run a single FFT on my whole signal, I -don't- have to "design" the filter. I simply evaluate the desired frequency response at the resulting frequencies, and that's it. Effectively, the impulse response is infinitely long, and wraps from one cycle into the next. Needless to say, in many cases I don't have the luxury of using for example a 16 million point FFT. But sometimes it -is- possible, and why should I then make my own life more difficult? The audio example is IMO one such case, and using overlap-and-add etc would only give worse results, because of the finite-length impulse response. As you suggested, I might cook up an example program for FFT-convolution one day. But probably somebody has done the work already. Best Regards Markus
PS:

>>Not at all. On your website, you write something similar:
.. and thanks for the comment. Yes, this clashes with what was discussed above. I had mostly windowing in mind. I removed that sentence. The site should get an overhaul anyway. -Markus