Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

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


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: convn and (i)fftn
Replies: 9   Last Post: Jun 23, 2011 9:00 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Alle Mejie

Posts: 12
Registered: 2/24/11
Re: convn and (i)fftn
Posted: Jun 22, 2011 11:39 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

> 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



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.