Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Topic: convn and (i)fftn
Replies: 10   Last Post: May 16, 2016 4:51 PM

 Messages: [ Previous | Next ]
 Alle Mejie Posts: 12 Registered: 2/24/11
Re: convn and (i)fftn
Posted: Jun 22, 2011 11:39 AM

> There's no reason you should be using FFT's with such a small kernel. Also,
> you're not exploiting the separability of the Gaussian. The separability allows you to convolve with a 1D Gaussian first along x, then along y, then along z, which is more efficient than consolidating into a 3D convolution kernel.

Ah, I did forget that indeed. To wrapped up in the frequency domain...

Would like to point out that the FFT version made by 'John' is seriously faster than the original convn() approach!

> Below, I've implemented this using my interpMatrix and KronProd tools.
>
> http://www.mathworks.com/matlabcentral/fileexchange/26292-regular-control-point-interpolation-matrix-with-boundary-conditions
>
> http://www.mathworks.com/matlabcentral/fileexchange/25969-efficient-object-oriented-kronecker-product-manipulation
>
> I'm getting a factor of 5 speed-up over FFTN and a factor of 7 speed-up over CONVN

I will try it out as well, thanks!

> dist = sqrt ( (-ksize:ksize).^ 2) ;
> gauss = 1 / ( sigma * sqrt ( 2 * pi ) ) * exp ( -0.5 * dist .^ 2 / ( sigma ) ^2 ) ;
> gauss=gauss/sum(gauss(:));
>
> Hxy=interpMatrix(gauss,'max',144);
> Hz=interpMatrix(gauss,'max',44);
>
> K=KronProd({Hxy,Hz},[1 1 2]);
>
> tic;
> filtered3=K*vol;
> toc;%Elapsed time is 0.039550 seconds.

Brilliant. So, what would you (in general, or more specifically for this problem), recommend in terms of speed: do as you've done, combine as many dimensions as possible (Hxy and Hz), or to separate out every dimension (have separate Hx, Hy, and Hz)?

Thanks!
Alle Meije

Date Subject Author
6/22/11 Alle Mejie
6/22/11 Alle Mejie
6/22/11 Matt J
6/22/11 Alle Mejie
6/22/11 Matt J
6/23/11 Alle Mejie
6/23/11 Alle Mejie
6/23/11 Alle Mejie
6/23/11 Matt J
6/23/11 Alle Mejie
5/16/16 mathango