Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
NCTM or The Math Forum.



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/26292regularcontrolpointinterpolationmatrixwithboundaryconditions > > http://www.mathworks.com/matlabcentral/fileexchange/25969efficientobjectorientedkroneckerproductmanipulation > > I'm getting a factor of 5 speedup over FFTN and a factor of 7 speedup 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



