[Insight-developers] OptBSplineInterpolateImageFunction
M.Staring at lumc.nl
M.Staring at lumc.nl
Thu Aug 27 11:43:38 EDT 2009
Hi,
Just to share timing results on my platform, so that we can better
estimate impact on performance on several platforms.
On my platform (Windows XP SP3, using Visual C++ 2008 release mode, 3rd
order
> Bspline, 3d 100x100x100 image, ITK 3.14, Intel Core 2 quad @ 2.4 GHz
Q6600) I get:
The elapsed time for old way: 3297
The elapsed time for fast way: 2437
The elapsed time for opt way: 2141
So a bit more in favour of opt, but your code indeed looks much more
simple.
Marius
> -----Original Message-----
> From: insight-developers-bounces at itk.org
> [mailto:insight-developers-bounces at itk.org] On Behalf Of Stefan Klein
> Sent: Thursday, August 27, 2009 5:06 PM
> To: insight-developers at itk.org
> Subject: [Insight-developers] OptBSplineInterpolateImageFunction
>
> Hi,
>
> I wrote an alternative to the itkOptBSplineInterpolateImageFunction,
> which is nearly as fast, but requires less code and is easier
> to use (in
> my opinion).
>
> The OptBSplineInterpolateImageFunction adds methods that take the
> threadId as argument. For example ::EvaluateAtIndex( index,
> threadId).
> This allows some dynamic memory allocations to be avoided and gives a
> great speedup.
>
> An alternative way of avoiding the memory allocations is to declare a
> C-array (of fixed size, so allocated on the stack) within the
> EvaluateAtIndex method, and use the vnl_matrix_ref class to
> instantiate
> a matrix that uses the statically allocated memory (instead of
> allocating memory on the heap).
>
> 1 million calls to EvaluateAtIndex give the following result:
> The elapsed time for old way: 2953ms
> The elapsed time for fast way: 2219ms
> The elapsed time for opt way: 2110ms
>
> old = non-optimized itkBSplineInterpolateImageFunction
> fast = my proposed implementation
> opt = the itkOptBSplineInterpolateImageFunction.
> (tested on Windows XP, using Visual C++ 2008 release mode, 3rd order
> Bspline, 3d 100x100x100 image, ITK 3.14)
>
> In the attachment you can find the test program and the classes. My
> proposed implementation is the
> itkBSplineInterpolateImageFunctionFast.h.
> I renamed the Opt-classes in the testing code, to make it easier to
> compare them, but I didn't change the functional code.
>
> The opt version is a bit faster, but requires more lines of code (and
> requires changes to all code that uses it, in order to
> benefit from the
> fast implementation). For the EvaluateDerivativeAtIndex method the
> timing results are similar. All interpolated values are
> identical in the
> three implementations (old,fast,opt).
>
> What do you think about it?
>
> Kind regards,
> Stefan
>
>
>
>
> No virus found in this incoming message.
> Checked by AVG - www.avg.com
> Version: 8.5.409 / Virus Database: 270.13.69/2328 - Release
> Date: 08/26/09 12:16:00
>
More information about the Insight-developers
mailing list