[ITK] Write and read itkEuler3DTransform with m_ComputeZYX = 1

Silvain Bériault silvain.beriault at zimmercas.com
Wed May 4 11:17:25 EDT 2016


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>

int main()
{
   typedef itk::Euler3DTransform<double> TransformType;
   TransformType::Pointer transformIn = TransformType::New();

   transformIn->SetComputeZYX(true);

   double angleX = 90;
   double angleY = 180;
   double angleZ = 0;

   double deg2rad = itk::Math::pi / 180.0;

   transformIn->SetRotation(angleX * deg2rad,
                          angleY * deg2rad,
                          angleZ * deg2rad);


   typedef itk::TransformFileWriterTemplate<double> WriterType;
   WriterType::Pointer writer = WriterType::New();
   writer->SetInput(transformIn);
   writer->SetFileName("D:/tmp/transform.tfm");
   writer->Update();

   typedef itk::TransformFileReaderTemplate<double> ReaderType;
   ReaderType::Pointer reader = ReaderType::New();
   reader->SetFileName("D:/tmp/transform.tfm");
   reader->Update();
   auto transformOut = (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/9691bf40/attachment-0001.html>


More information about the Community mailing list