Load mha rotation/translation in the proper order
This was a bug submitted to the old bugzilla by Guillaume Custillon on 2016-03-17
When loading an mhd/mha image that contains some transformation, the translation (offset) is not handled correctly. Indeed, the rotation matrix should be applied and then the translation in the world frame. However, on CamiTK the rotation is applied, and then the translation in the rotated frame.
Steps to Reproduce
- Open imp and load the attached mha test image:
It is a 2D image with a rotation of 45° around z axis and a translation of 10 mm on the x axis.
- Display the world frame.
Actual VS Expected Result
- Observe the location of the image: the translation is not made on the x axis of the world frame, but on the x axis of > the rotated image frame.
Relevant logs and/or screenshots:
Interpretation & Possible fixes:
This is the answer given by @jaffarda on 2016-03-22
Following is based on the test image provided by Guillaume.
***** The Bug, reworded ****** According to the data in file: TransformMatrix (which contains rotation matrix of frame) is 0.707 -0.707 0 0.707 0.707 0 0 0 1 and Offset (which contains translation of frame) is 10 0 0
Opening this image with camiTK: rotation is OK translation become 7.07 7.07 0
in other words, the translation is applied in rotated frame, but we expect it to be applied in world frame
***** suggested fix *****
based on tests on this image,
in ImageComponent.cpp (line 290), the line
vtkMatrix4x4::Multiply4x4(rotationMatrix, initialTranslation->GetMatrix(), initialFrameMatrix);
should become : ```cpp vtkMatrix4x4::Multiply4x4(initialTranslation->GetMatrix(), rotationMatrix, initialFrameMatrix);
***** WARNING ***** This change in a core file should only be commit after deep tests on every thing it may impact.
This was submitted for CamiTK 3.5.0.svn but is still present in CamiTK 4.1.develop