[Insight-users] bug in BSplineInterpolationWeightFunction, BSplineFloor()

Matthias Kirschner Matthias.Kirschner at gris.informatik.tu-darmstadt.de
Tue Sep 9 01:58:12 EDT 2008


Hi,

I can reproduce the error, and I think the problem is due to numerical 
imprecision. If you want robust code, it may be wiser to use the 
standard library function. It may be slower, but I doubt that it will be 
the bottleneck in your final program.

Regards,
Matthias



Stefan Klein schrieb:
> Hi,
>
> It seems there is a bug in the BSplineFloor() function defined in 
> itkBSplineInterpolationWeightFunction.txx.
>
> It floors 97.999999 to 98...
>
> The code in the attachment reproduces the problem and illustrates how 
> it may lead to severe crashes when using the 
> BSplineDeformableTransform (that's how I found it).
>
> Can anybody reproduce the problem? I'm using Visual C++ 2008, Windows 
> XP 32bit, ITK 3.8.
>
> It can be easily fixed by changing in 
> itkBSplineInterpolationWeightFunction.txx the following lines:
>
>   union { unsigned int hilo[2]; double d; } u;
>   u.d = x + 103079215104.0;
>   return (int)((u.hilo[1]<<16)|(u.hilo[0]>>16));
>
> into:
>
>   return static_cast<int>(vcl_floor(x));
>
> But that might give a performance loss, as the comment explains:
>
> // The 'floor' function on x86 and mips is many times slower than these
> // and is used a lot in this code, optimize for different CPU 
> architectures
>
> Does anybody have a better solution?
>
> Kind regards,
> Stefan
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users


-- 

Matthias Kirschner
TU Darmstadt - GRIS
Medical Computing
Fraunhoferstraße 5
64283 Darmstadt, Germany
www.gris.informatik.tu-darmstadt.de

Phone: +49 6151 155-624
Fax  : +49 6151 155-669
eMail: matthias.kirschner at gris.informatik.tu-darmstadt.de



More information about the Insight-users mailing list