Read Transform From File

Synopsis

Read a transform from a file.

Results

Note

Help Wanted Implementation of Results for sphinx examples containing this message. Reconfiguration of CMakeList.txt may be necessary. Write An Example <https://itk.org/ITKExamples/Documentation/Contribute/WriteANewExample.html>

Code

C++

#include "itkTransformFileReader.h"
#include "itkTransformFactoryBase.h"

int
main(int argc, char * argv[])
{
  std::string fileName;
  if (argc == 1) // No arguments were provided
  {
    fileName = "test.tfm";
  }
  else
  {
    fileName = argv[1];
  }

  // Register default transforms
  itk::TransformFactoryBase::RegisterDefaultTransforms();

#if (ITK_VERSION_MAJOR == 4 && ITK_VERSION_MINOR >= 5) || ITK_VERSION_MAJOR > 4
  itk::TransformFileReaderTemplate<float>::Pointer reader = itk::TransformFileReaderTemplate<float>::New();
#else
  itk::TransformFileReader::Pointer writer = itk::TransformFileReader::New();
#endif
  reader->SetFileName(fileName);
  reader->Update();

  // Display the transform
  std::cout << *(reader->GetTransformList()->begin()) << std::endl;

  return EXIT_SUCCESS;
}

Classes demonstrated

Warning

doxygenclass: Cannot find class “itk::TransformFileReader” in doxygen xml output for project “ITK” from directory: /home/kitware/Dashboards/Tests/ITKExamples-doc-build/ITKEx-build/ITKDoxygenXML

See itk::TransformFileReader for additional documentation.