[Insight-users] BSplineInterpolateImageFunction - setting input image and performace questions

Gavin Baker gavinb+xtk at cs.mu.OZ.AU
Wed Jun 22 21:24:11 EDT 2005


Hi Jakub,

On Wed, Jun 22, 2005 at 10:49:51AM +0200, Jakub Bican wrote:

> i am using BSplineInterpolateImageFunction to interpolate my 3D image 
> during its resample.
> 
> One thing i am considering is the SetInputImage() method - should i call 
> it each times, when the input to the ResampleImageFilter changes? Or is 
> it called by the filter?

That is not normally necessary - the ResampleImageFilter will call the
interpolator's SetInputImage() method before each update.

> Doxygen docs says "This must be set by the user." but i looked in the 
> code and i think that it is called by the filter but i am not sure. 

Hmmm, not the most enlightening prose... :) It is sufficient to attach the
interpolator to the filter, and it will handle the rest.

> Some other docs (tutorial) says, that the method is called when the
> pipeline is connected - but i think, that it should be called whenever the
> input changes!

It is actually called in
itkResampleImageFilter::BeforeThreadedGenerateData(), which means whenever
the resample filter stage is updated.  This is normally in response to an
Update() downstream of the filter, and thus the coefficients would be
updated accordingly if the input image did change.

> The other thing is performance. Does the spline order has considerable 
> effect on the performance?
> 
> I am using default order (3) and the resampling process takes about 
> 7-times longer than if i use LinearInterpolateImageFunction. Is this 
> expectable?

Absolutely - a B-spline is far more computationally expensive than a simple
linear function.  Order N splines are equivalent to N repeated convolutions
of the 0th order spline, so each higher order will have a corresponding
increase in computation time.  (An order-0 spline is actually equivalent to
a nearest neighbor function, while and order-1 is equivalent to a linear
interpolator, although that's not the most efficient way of obtaining the
same result!)

Of course, ITK has the NearestNeighborInterpolateImageFunction (which is the
fastest by far) and LinearInterpolateImageFunction (which would be second
fastest), optimised accordingly.

So a 7x speed difference is not entirely surprising.  It comes down to a
classic accuracy vs time tradeoff, so if you are prepared to pay for the
extra processing time, the B-Spline interpolator will usually give you far
better results.

  :: Gavin

-- 
Gavin Baker                                      Complex Systems Group
http://www.cs.mu.oz.au/~gavinb             The University of Melbourne


More information about the Insight-users mailing list