[Insight-users] bug in itkImageSpatialObject
Stefan Klein
s.klein at erasmusmc.nl
Fri Aug 28 09:35:23 EDT 2009
Hi,
I believe I found a bug in the
ImageSpatialObject::ComputeLocalBoundingbox() method.
The bounding box is wrongly computed in case of rotated images. Attached
is a test program that produces the bug and tests a fix. A 100x100 image
is created, with a rotation matrix of 45 degrees (pi/4 rad) as direction
cosines. Below are the resulting bounding box min/max coordinates:
ITK:
min: [0, 0]
max: [70.7107, 70.7107]
FIX:
min: [-70.7107, 0]
max: [70.7107, 141.421]
ITK = the itk implementation
FIX = my proposed fix (itkImageSpatialObject2).
The bounding box of a rotated square of 100x100 can never become smaller
than 100x100, so the ITK result must be wrong.
By changing the variable 'factor' in the test program you will see that
with even values both versions give a correct result, but with odd
values the ITK version is faulty.
The cause of the failure lies in itkImageSpatialObject.txx lines
256-260. By setting the minimum and maximum first, these point will
never be considered to be maximum or minimum, respectively.
Kind regards,
Stefan.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: testspatobbb.zip
Type: application/x-zip-compressed
Size: 6106 bytes
Desc: not available
URL: <http://www.itk.org/pipermail/insight-users/attachments/20090828/6cc306dc/attachment.bin>
More information about the Insight-users
mailing list