DIPlib / diplib

Quantitative Image Analysis in C++, MATLAB and Python
https://diplib.org
Apache License 2.0
211 stars 48 forks source link

Computing GaussFT for multiple sigmas at once? #117

Closed anntzer closed 1 year ago

anntzer commented 1 year ago

Component DIPlib 3.3.0. Actually I use PyDIP (thank you very much for making this Python binding!) but this is a feature request for the core library.

Describe the bug Would it be possible and/or beneficial to support computing GaussFT for multiple values of sigma at once? The idea being that one only needs to perform a single forward FT, multiply with each FT(gaussian) in Fourier space, and perform N backwards FT back to image space (rather than having to perform N identical forward FTs as well if doing a loop over each value of sigma).

Optimally I would like to use that to speed up Hessian computations to compute ridge filters, which often want to compute Hessian eigenvalues at multiple smoothings (see e.g. the note at the end of https://diplib.org/diplib-docs/detection_lines.html#dip-FrangiVesselness-dip-Image-CL-dip-Image-L-dip-FloatArray-CL-dip-FloatArray--dip-String-CL-dip-StringArray-CL).

To Reproduce N/A

System information: N/A

crisluengo commented 1 year ago

It is typically not efficient to use the FT to compute a Gaussian filter (it depends on image size, I guess). dip::Gauss (and therefore everything in DIPlib that uses Gaussian filters) only uses the FT implementation for very small sigma, and for derivatives of order higher than 3; in both these cases you get numerical precision issues with spatial-domain implementations.

Still, it would make sense to add a inRepresentation and outRepresentation parameters to dip::GaussFT like dip::ConvolveFT has. Then you could do a forward transform, and call dip::GaussFT as often as you like with "frequency" as the input representation and "spatial" as the output representation.

anntzer commented 1 year ago

Thanks for implementing this!