[SciPy-User] variable smoothing kernel
Sturla Molden
sturla@molden...
Sun Mar 27 07:24:07 CDT 2011
Den 27.03.2011 03:54, skrev Wolfgang Kerzendorf:
> I have learned that multiplying functions in fourier space is the same
> as convoluting them.
Yes.
The best strategy is to do this chunk-wise, however, instead of FFT'ing
the whole signal. This leads tot he so-called "overlap-and-add" method,
used by e.g. scipy.signal.fftfilt. fftfilt tries to guess the optimum
chunk-size to use for filtering.
For short FIR-filters it will be faster to filter in the time-domain.
For moving average filters one can use a very fast recursive filter.
Bartlet filter can be implemented by appying MA twice, Gaussian can be
approximated by applying MA four times. (A better IIR-approximation for
the Gaussian is available, howver, see below.)
> I believe that is how the ndimage kernels work so
> incredibly fast.
No. They truncate the Gaussian, which is why compute time depends on
filter size. Cf. the comment on short FIR-filters above.
For the Gaussian it is possible to use a recursive IIR filter instead,
for which compute time does not depend on filter size.
> I wanted to see if there's a similar shortcut for a variable kernel.
Not in general, because the filter will be non-linear.
Sturla
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: _gaussian.c
Url: http://mail.scipy.org/pipermail/scipy-user/attachments/20110327/6a55cc97/attachment-0001.c
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: gaussian.h
Url: http://mail.scipy.org/pipermail/scipy-user/attachments/20110327/6a55cc97/attachment-0001.h
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: gaussian.pyx
Url: http://mail.scipy.org/pipermail/scipy-user/attachments/20110327/6a55cc97/attachment-0001.pl
More information about the SciPy-User
mailing list