-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathPrintITKTransform.cpp
37 lines (35 loc) · 1.26 KB
/
PrintITKTransform.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "PrintITKTransform.h"
#include <itkTransformFactory.h>
int PrintITKTransform( int argc , char* argv[] )
{
if( argc != 3 )
{
std::cout<< argv[ 0 ] << " " << argv[ 1 ] << " TransformFile" << std::endl ;
return 1 ;
}
std::string input ;
input.assign( argv[ 2 ] ) ;
//Read transform files
itk::TransformFactory< itk::MatrixOffsetTransformBase<double, 3, 3> >::RegisterTransform();
itk::TransformFileReader::Pointer transformFile ;
transformFile = itk::TransformFileReader::New() ;
transformFile->SetFileName( input ) ;
transformFile->Update() ;
//Check that transform files contain only one transform
if( transformFile->GetTransformList()->size() != 1
)
{
std::cout<< "Transform files must contain only 1 transform" << std::endl ;
return 1 ;
}
typedef itk::AffineTransform< double , 3 > AffineTransformType ;
AffineTransformType::Pointer affineTransform ;
std::cout << transformFile->GetTransformList()->front().GetPointer()->GetTransformTypeAsString() << std::endl ;
if( ReadTransform( transformFile , affineTransform ) )
{
return 1 ;
}
std::cout << "Matrix = " << std::endl << affineTransform->GetMatrix() << std::endl ;
std::cout << "Offset = " << affineTransform->GetOffset() << std::endl ;
return 0 ;
}