[ITK] Write and read itkEuler3DTransform with m_ComputeZYX = 1
Yaniv, Ziv Rafael (NIH/NLM/LHC) [C]
zivrafael.yaniv at nih.gov
Wed May 4 14:26:42 EDT 2016
Hello Silvain,
I reproduced this bug, and yes you are correct in that it is because the m_ComputeZYX variable is not serialized. Will likely add it as an additional fixed parameter which should solve this issue. Will keep you posted when the patch is on gerrit.
Also, the current behavior of the class when turning this flag on/off is inconsistent: SetParameters(); SetComputeZYX(); vs. SetComputeZYX(); SetParameters(); yield different matrices.
Ziv
From: Silvain Bériault <silvain.beriault at zimmercas.com<mailto:silvain.beriault at zimmercas.com>>
Date: Wednesday, May 4, 2016 at 11:17 AM
To: "community at itk.org<mailto:community at itk.org>" <community at itk.org<mailto:community at itk.org>>
Subject: [ITK] Write and read itkEuler3DTransform with m_ComputeZYX = 1
Hello,
I and trying to write an itk::Euler3DTransform (with m_ComputeZYX = 1) to file (*.tfm file format). However, I noticed the flag m_ComputeZYX is not saved to the tfm file. Consequently, when I read-back the transform from file, I get a different transform (i.e. a transform with same angles but different matrix since m_ComputeZYX = 0 ). I am using ITK version 4.9.1 (latest release). Any help on this issue would be greatly appreciated. An example follows.
Regards,
Silvain Beriault, Ph.D.
code sample:
include<itkEuler3DTransform.h>
#include<itkTransformFileWriter.h>
#include<itkTransformFileReader.h>
#include<itkMath.h>
intmain()
{
typedefitk::Euler3DTransform<double> TransformType;
TransformType::PointertransformIn = TransformType::New();
transformIn->SetComputeZYX(true);
doubleangleX = 90;
doubleangleY = 180;
doubleangleZ = 0;
doubledeg2rad = itk::Math::pi / 180.0;
transformIn->SetRotation(angleX * deg2rad,
angleY * deg2rad,
angleZ * deg2rad);
typedefitk::TransformFileWriterTemplate<double> WriterType;
WriterType::Pointerwriter = WriterType::New();
writer->SetInput(transformIn);
writer->SetFileName("D:/tmp/transform.tfm");
writer->Update();
typedefitk::TransformFileReaderTemplate<double> ReaderType;
ReaderType::Pointerreader = ReaderType::New();
reader->SetFileName("D:/tmp/transform.tfm");
reader->Update();
autotransformOut = (reader->GetTransformList()->begin())->GetPointer();
std::cout << "****TransformIn****" << std::endl;
std::cout << transformIn << std::endl << std::endl << std::endl;
std::cout << "****TransformOut****" << std::endl;
std::cout << *transformOut << std::endl << std::endl << std::endl;
}
The screen output is:
****TransformIn****
Euler3DTransform (0000000000461BF0)
RTTI typeinfo: class itk::Euler3DTransform<double>
Reference Count: 4
Modified Time: 12
Debug: Off
Object Name:
Observers:
none
Matrix:
-1 1.22465e-016 7.4988e-033
0 6.12323e-017 -1
-1.22465e-016 -1 -6.12323e-017
Offset: [0, 0, 0]
Center: [0, 0, 0]
Translation: [0, 0, 0]
Inverse:
-1 0 -1.22465e-016
1.22465e-016 0 -1
0 -1 0
Singular: 0
Euler's angles: AngleX=1.5708 AngleY=3.14159 AngleZ=0
m_ComputeZYX = 1
****TransformOut****
Euler3DTransform (0000000000473180)
RTTI typeinfo: class itk::Euler3DTransform<double>
Reference Count: 2
Modified Time: 673
Debug: Off
Object Name:
Observers:
none
Matrix:
-1 0 1.22465e-016
1.22465e-016 6.12323e-017 1
-7.4988e-033 1 -6.12323e-017
Offset: [0, 0, 0]
Center: [0, 0, 0]
Translation: [0, 0, 0]
Inverse:
-1 1.22465e-016 -7.4988e-033
-7.4988e-033 4.59169e-049 1
1.22465e-016 1 4.59169e-049
Singular: 0
Euler's angles: AngleX=1.5708 AngleY=3.14159 AngleZ=0
m_ComputeZYX = 0
The saved transform is :
#Insight Transform File V1.0
#Transform 0
Transform: Euler3DTransform_double_3_3
Parameters: 1.5707963267948966 3.141592653589793 0 0 0 0
FixedParameters: 0 0 0
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/community/attachments/20160504/556a0b51/attachment-0001.html>
More information about the Community
mailing list