MantisBT - ITK
View Issue Details
0005692ITKpublic2007-09-13 00:412009-06-16 04:05
dbrussak 
Andinet 
normalminoralways
closedfixed 
 
 
0005692: small problem with BSplineFloor

I am compiling ITK v3.2.0 with VS 2005 V8.0.50727.42

I am working on a Dell Precision 390 with:
-Intel Core2 Duo 6700 (2.66 GHz)
-2 GB of RAM
-Windows XP Professional Version 2002, SP2

BSplineFloor(x) (in particular the version for _M_IX86) returns an incorrect result with numbers within a certain precision of ceil(x). This can cause any number of issues. The one in particular I have had is inside of BSplineInterpolationWeightFunction::Evaluate()

I have a BSplineDeformableTransform<double, 3, 3> grid of size 15x15x15.

The function: BSplineDeformableTransform<double,3,3>::TransformPoint() is called and transforms a point into the following index:
[11.452082865989810, 12.999999197680104, 10.005523428572200]

Then it checks to see if this point is in a valid region. Since this is a 3rd order BSpline, the support grid is 4x4x4. The function only proceeds if this index has full support, i.e. 1<index[j]<13.

Since this index is inside the valid region (albeit barely), the call to m_WeightsFunction->Evaluate() should return
[10 11 9] for the supportIndex. Instead, because of the issue with BSplineFloor, [10 12 9] is returned and, since the assumption that we are inside the region of full support is broken, the iterators are misaligned and continue on well past their boundaries until the program crashes.

Attached is a very simple program illustrating the problem and reproducing this crash:
BSplineFloorIssue.tar.gz
    -CMakeLists.txt
    -BSplineFloorIssue.cxx



I believe this is related to the issue reported here:
http://www.nabble.com/a-strange-error-using-itkBSplineDeformableTransform-t3516947.html [^]

I am aware that there is an already outstanding bug report covering BSplineFloor and its calculation of the correct support region. I think that this is a separate issue as that bug report claimed that everything worked fine with odd-order BSplines.
No tags attached.
has duplicate 0002078closed user390 BSplineFloor in itkBSplineInterpolationWeightFunction.txx is incorrect 
gz BSplineIssue.tar.gz (1,306) 2007-09-13 00:41
https://public.kitware.com/Bug/file/1145/BSplineIssue.tar.gz
Issue History
2007-09-13 00:41dbrussakNew Issue
2007-09-13 00:41dbrussakFile Added: BSplineIssue.tar.gz
2007-09-13 01:05dbrussakNote Added: 0008966
2007-09-13 20:53dbrussakNote Edited: 0008966
2007-10-08 08:21Luis IbanezRelationship addedrelated to 0002078
2008-01-23 15:06Luis IbanezStatusnew => assigned
2008-01-23 15:06Luis IbanezAssigned To => Andinet
2009-06-16 04:04Tom VercauterenRelationship replacedhas duplicate 0002078
2009-06-16 04:05Tom VercauterenNote Added: 0016728
2009-06-16 04:05Tom VercauterenStatusassigned => closed
2009-06-16 04:05Tom VercauterenResolutionopen => fixed

Notes
(0008966)
dbrussak   
2007-09-13 01:05   
(edited on: 2007-09-13 20:53)
A possible fix could be the code reported in:
http://ldesoras.free.fr/doc/articles/rounding_en.pdf [^]

A very simple test of speed (running N times) gives the following results:
N x floor() = 24 sec.
N x BSplineFloor = 3 sec. (though faulty output as shown above)
N x floor_int() = 5 sec. (correct output in previous case)

(0016728)
Tom Vercauteren   
2009-06-16 04:05   
Fixed in HEAD:
http://www.itk.org/cgi-bin/viewcvs.cgi/Code/Common/itkBSplineInterpolationWeightFunction.txx?root=Insight&r1=1.15&r2=1.16&sortby=date [^]
http://www.itk.org/cgi-bin/viewcvs.cgi/Code/BasicFilters/itkBilateralImageFilter.txx?root=Insight&r1=1.29&r2=1.30&sortby=date [^]