Page MenuHomePhabricator

If setting a cloned geometry for an image via SetClonedGeometry(Geometry) the cloned Geometry can be slightly different from the original one
Closed, ResolvedPublic

Description

If you call the method mitk::Image::SetClonedGeometry(), it can happen, that the cloned geometry is slightly different from the original one.
The transfomation matrices of the two geometries are then different from each other.

This may result in a wrong transformation of (e.g. from index coordinates to world coordinates)

The reason for this lies in the method mitk::SlicedGeometry3D::InitializeEvenlySpaced() which is called in SetClonedGeometry.

Event Timeline

Resetting all bugs without active assignee flag to "CONFIRMED". Change status to IN_PROGRESS if you are working on it.

New remote branch pushed: bug-6505-SetClonedGeometryIsNotAccurate

Cannot reproduce the bug.

Added test case to mitkImageTest to cover this case.

[437c22]: Merge branch 'bug-6505-SetClonedGeometryIsNotAccurate'

Merged commits:

2013-06-05 14:42:31 Michael Goetz [94f0ca]
Added test case for SeClonedGeometry to mitkImageTest

[f2c2f6]: Merge branch 'bug-6505-COMPFixForNewTest'

Merged commits:

2013-06-05 18:18:31 Michael Goetz [d43a9e]
COMP: Increased eps to avoid test failure

[9c51a1]: Merge branch 'bug-6505-COMPFixForNewTest'

Merged commits:

2013-06-05 18:30:20 Michael Goetz [26283d]
COMP: Deactivated test for T6505, bug still present

The bug seems to be present, the new test, which works on my computer, fails on the dashboard.

The error that occurs seems to be bigger than mitk::eps

New remote branch pushed: bug-6505-COMPFixForNewTest

Can't reproduce this bug on my machine, but it is still present, since the test fails on the dashboard. So i'll set the bug status back to confirmed.

To reproduce the bug see mitkImageTest, the methode SetClonedGeometry_None_ClonedEqualInput will test for this bug.

Valgrind shows the reason, there is some illegal memory read. This also explains the undeterministic behaviour on different machines:

30963== Conditional jump or move depends on uninitialised value(s)

30963== at 0x844DBE: mitkImageTestClass::SetClonedGeometry_None_ClonedEqualInput() (mitkImageTest.cpp:101)

30963== by 0x83EB52: mitkImageTest(int, char**) (mitkImageTest.cpp:118)

30963== by 0x5ABD50: main (MitkTestDriver.cpp:709)

30963

30963== Invalid read of size 8

30963== at 0x844D41: mitkImageTestClass::SetClonedGeometry_None_ClonedEqualInput() (mitkImageTest.cpp:97)

30963== by 0x83EB52: mitkImageTest(int, char**) (mitkImageTest.cpp:118)

30963== by 0x5ABD50: main (MitkTestDriver.cpp:709)

30963== Address 0x1ac15400 is 0 bytes after a block of size 528 alloc'd

30963== at 0x4A068F3: operator new(unsigned long) (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)

30963== by 0x54E6E1E: itk::ScalableAffineTransform<double, 3u>::New() (in /home/nolden/prj/mitk/gcc-core/MITK-build/bin/libMitk.so)

30963== by 0x5597034: mitk::Geometry3D::InitializeGeometry(mitk::Geometry3D*) const (mitkGeometry3D.cpp:936)

30963== by 0x55905D4: mitk::Geometry3D::Geometry3D(mitk::Geometry3D const&) (mitkGeometry3D.cpp:65)

30963== by 0x5BC2E68: mitk::SlicedGeometry3D::SlicedGeometry3D(mitk::SlicedGeometry3D const&) (mitkSlicedGeometry3D.cpp:42)

30963== by 0x5BC6031: mitk::SlicedGeometry3D::InternalClone() const (mitkSlicedGeometry3D.cpp:675)

30963== by 0x52444BF: mitk::Geometry3D::Clone() const (in /home/nolden/prj/mitk/gcc-core/MITK-build/bin/libMitk.so)

30963== by 0x552E82F: mitk::ProportionalTimeGeometry::Initialize(mitk::Geometry3D*, unsigned long) (mitkProportionalTimeGeometry.cpp:200)

30963== by 0x5BC2780: mitk::SlicedData::SetGeometry(mitk::Geometry3D*) (mitkSlicedData.cpp:290)

30963== by 0x55A3CF7: mitk::Image::SetGeometry(mitk::Geometry3D*) (mitkImage.cpp:1166)

30963== by 0x553DCA1: mitk::BaseData::SetClonedGeometry(mitk::Geometry3D const*) (mitkBaseData.cpp:139)

30963== by 0x844C92: mitkImageTestClass::SetClonedGeometry_None_ClonedEqualInput() (mitkImageTest.cpp:89)

30963

30963== Invalid read of size 8

30963== at 0x844D6E: mitkImageTestClass::SetClonedGeometry_None_ClonedEqualInput() (mitkImageTest.cpp:98)

30963== by 0x83EB52: mitkImageTest(int, char**) (mitkImageTest.cpp:118)

30963== by 0x5ABD50: main (MitkTestDriver.cpp:709)

30963== Address 0x1ac04290 is 0 bytes after a block of size 528 alloc'd

30963== at 0x4A068F3: operator new(unsigned long) (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)

30963== by 0x54E6E1E: itk::ScalableAffineTransform<double, 3u>::New() (in /home/nolden/prj/mitk/gcc-core/MITK-build/bin/libMitk.so)

30963== by 0x5B91747: mitk::PlaneGeometry::InitializeStandardPlane(double, double, vnl_vector<double> const&, vnl_vector<double> const&, itk::Vector<double, 3u> const*) (mitkPlaneGeometry.cpp:439)

30963== by 0x5B91502: mitk::PlaneGeometry::InitializeStandardPlane(double, double, itk::Vector<double, 3u> const&, itk::Vector<double, 3u> const&, itk::Vector<double, 3u> const*) (mitkPlaneGeometry.cpp:414)

30963== by 0x844C11: mitkImageTestClass::SetClonedGeometry_None_ClonedEqualInput() (mitkImageTest.cpp:85)

30963== by 0x83EB52: mitkImageTest(int, char**) (mitkImageTest.cpp:118)

30963== by 0x5ABD50: main (MitkTestDriver.cpp:709)

I just did some investigation: could be an ITK problem as well. To verify this a small test case for mitk::Geometry3D::InitializeGeometry in the Geometry3D test would be helpful.

We should investigate this further. Maybe this bug is fixed with the latest ITK update?
At least we should enhance the GeometryTest like Marco suggested.

User wildes has pushed new remote branch:

bug-6505-ClonedImage_Geometry

[852f9a]: Merge branch 'bug-6505-ClonedImage_Geometry'

Merged commits:

2014-06-25 16:35:21 Sebastian Wirkert [8632b7]
Image test was falty:
checked if 4x4 transformation matrix is same for two image geometries.
The matrix really is a 3x3 rotation matrix, thus the additionally compared
elements were undefined.
Switched to the new Equal methods to check if the two Geometries are equal.


2014-06-25 16:33:20 Sebastian Wirkert [d04d87]
Superclass constructors were sometimes not called.
Fixed that to ensure Geometry classes are always correctly initialized.


2014-06-04 17:31:07 Esther Wild [d36bec]
Removed redundant setting of Bounds, Matrix and IndexToWorldTransform.

[da6238]: Merge branch 'bug-6505-ClonedImage_Geometry'

Merged commits:

2014-06-25 17:22:46 Sebastian Wirkert [eafff7]
COMP: Removed two unused variables which caused warnings (equals errors).