|
|
Line 1: |
Line 1: |
| A sample ITK Transform file that can be used to test this example is:
| | {{warning|1=The media wiki content on this page is no longer maintained. The examples presented on the https://itk.org/Wiki/* pages likely require ITK version 4.13 or earlier releases. In many cases, the examples on this page no longer conform to the best practices for modern ITK versions. |
| | | }} |
| <source lang="text">
| |
| #Insight Transform File V1.0
| |
| #Transform 0
| |
| Transform: Rigid2DTransform_float_2_2
| |
| Parameters: 0 0 0
| |
| FixedParameters: 0 0
| |
| </source>
| |
| | |
| This file was produced by the [[ITK/Examples/IO/TransformFileWriter]] example.
| |
| | |
| ==TransformFileReader.cxx==
| |
| <source lang="cpp">
| |
| #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;
| |
| }
| |
| </source>
| |
| | |
| {{ITKCMakeLists|{{SUBPAGENAME}}}}
| |