Search All of the Math Forum:

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

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

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 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

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