POV-Ray : Newsgroups : povray.off-topic : DFT and FFT : Re: DFT and FFT Server Time
6 Sep 2024 19:22:11 EDT (-0400)
  Re: DFT and FFT  
From: Invisible
Date: 20 Jan 2009 08:16:45
Message: <4975cebd$1@news.povray.org>
Mike Raiford wrote:

> According to the book, my thinking was sound. You take an iFFT of the 
> arbitrary filter, apply a Hamming or Blackmann window to the shifted and 
> zero-padded filter kernel. Then you execute the filter by convolution, 
> or FFT convolution. Depending on the size of the filter kernel you've 
> generated. Bigger means FFT is more advantageous.
> 
> That's for FIR filters.

Not quite...

Let's say you want to build a band-pass filter. It passes 100 Hz 
unchanged, but it filters out everything else. A "perfect" version of 
this filter is very simple - and very impossible. Its impulse response 
would simply by a 100 Hz sinewave extending an infinite distance into 
the past and into the future.

It should be completely obvious that no filter real-world filter can 
possibly react to inputs that haven't happened yet - but that is what 
this design calls for. (It is a "non-causal filter".)

Anyway, if you build an FIR by simply taking that infinite sinewave and 
chopping the ends off to make it finite, you've just truncated the 
impulse response. And that distorts the frequency response. The longer 
the IR is, the less the distortion - and the more arithmetic your 
digital filter is going to have to do when you run it.

If, instead of just chopping the ends off, you use a Blackmann window... 
Well, you're multiplying the IR by the window. Multiplication in the 
time domain is convolution in the frequency domain. The frequency 
spectrum of a Blackmann window is such that this convolution is 
essentially a blurring operation. It blurs out the small ripples, 
without destroying the peak at 100 Hz which we'd like to keep. (It does 
widen it slightly though.)

Anyway, coming back to general filter design...

- You figure out what frequency response you want, and how many points 
you've going to use. (Note that before and after the inverse-FFT, the 
number of "points" remains the same.)

- Obviously more points give you more control over the frequency 
response; you've got more control points to move. It also means less 
rippling between the centers of those control points.

- Take your desired frequency response. Take the inverse-FFT. Now 
multiply that by your chosen windowing function.

- You now have your filter kernel.

Notice there's no zero-padding here. (I think you're possibly confused 
by the guide's suggestion that you can zero-pad the IR before taking an 
FFT in order to get better frequency resolution so you can see what your 
filter's "real" frequency response is - this does not exactly match what 
you originally requested because the IR is finite.)

Anyway, you can now "run" the filter in two ways: Take the convolution 
of the kernel and your signal, or do an FFT-convolution.

To do an FFT-convolution, you want the filter's frequency response (not 
its impulse response). Chop your input signal into blocks, zero-pad each 
block, FFT, multiply, inverse-FFT, overlap consecutive blocks to build 
an output signal. You're done.

(It strikes me that if you were trying to do this "real time", the 
blocking would necessarily add some latency to the system that a 
convolution implementation wouldn't have...)


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.