|
|
Re: convn and (i)fftn
Posted:
Jun 23, 2011 4:32 AM
|
|
> I'm getting a factor of 5 speed-up over FFTN and a factor of 7 speed-up over CONVN > > % 3-dimensional filtering with convn > tic > filtered = convn ( volume, gauss, 'same' ) ; > toc;%Elapsed time is 0.308417 seconds. > > % 3-dimensional filtering with fftn > tic; > gf = fftn ( gauss2, size ( volume ) ) ; > gv = fftn ( volume, size ( volume ) ) ; > filtered2 = real ( ifftn ( conj ( gf ) .* gv ) ) ; > toc;%Elapsed time is 0.192878 seconds. > > % 3-dimensional filtering using KronProd to exploit separability > > 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.
I'm getting an error on this line in interpMatrix.m:
if ischar(origin) switch origin case 'max' [~,origin]=max(kernel); ^^^^^^^^^^^^^^^^^^^^^ >>Expression or statement is incorrect--possibly unbalanced (, {, or [. << case 'ctr' origin = ceil( (length(kernel)+1)/2 ); otherwise error 'Unrecognized option for "origin"' end end
The line makes no sense to me either. Should the '~,' just go?
thanks Alle Meije
|
|