[Insight-developers] Bug in BSplineInterpolateImageFunction ?

M.Staring at lumc.nl M.Staring at lumc.nl
Wed Jan 25 12:08:37 EST 2012


Hi developers,

We recently switched elastix to ITK 4.0.0 and noticed some changed results. One of them we tracked down to the BSplineInterpolateImageFunction.

This class was changed in ITK4 to the OptBSplineInterpolateImageFunction that was in ITK3/Review. One of the changes is to the function DetermineRegionOfSupport.

In ITK3 it reads:

for (unsigned int n = 0; n< ImageDimension; n++)

    {

    if (splineOrder & 1)     // Use this index calculation for odd splineOrder

      {

      indx = (long)vcl_floor((float)x[n]) - splineOrder / 2;                   <---
    ... etc ...

But in ITK4 the arrowed line (<---)  reads:

indx = (long)x[n];

if ( indx < 0 && (double)indx != (double)x[n] )

{

    indx--;

}

indx -= splineOrder / 2;



The behaviour is different for negative values of the continuous index x.



For example we have splineOrder = 1, x[n] = -0.3.

In ITK3:

indx = floor(-0.3) - 1/2 = -1 - 0 = -1

In ITK4:

indx = long(-0.3) = 0

if ( 0 < 0 && ...) indx--; // this does not happen since 0 !< 0

indx -= 0, so indx = 0 instead of -1

So, there is a difference between ITK3 and ITK4 and we believe ITK3 was the correct one. For x=-0.3 the left index should be -1, finally resulting in the support [-1 0] for the first order spline around the point -0.3. Do you agree with this?

If so, ITK4 can be fixed by adapting the line

if ( indx < 0 && (double)indx != (double)x[n] )
to

if ( x[n] < 0 && (double)indx != (double)x[n] )

Best regards,

Marius


Marius Staring, PhD
Division of Image Processing (LKEB)
Department of Radiology
Leiden University Medical Center
PO Box 9600, 2300 RC Leiden, The Netherlands
phone: +31 (0)71 526 2137, fax: +31 (0)71 524 8256
m.staring at lumc.nl

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/mailman/private/insight-developers/attachments/20120125/c12b055d/attachment.htm>


More information about the Insight-developers mailing list