-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathDirectionToTransformMatrix.cpp
More file actions
28 lines (26 loc) · 1.01 KB
/
DirectionToTransformMatrix.cpp
File metadata and controls
28 lines (26 loc) · 1.01 KB
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
#include "DirectionToTransformMatrix.h"
int DirectionToTransformMatrix( int argc , char* argv[] )
{
if( argc != 4 )
{
std::cout<< argv[ 0 ] << " " << argv[ 1 ] << " inputImage outputTransform" << std::endl ;
return 1 ;
}
typedef itk::Image< unsigned char , 3 > ImageType ;
typedef itk::ImageFileReader< ImageType > ImageReaderType ;
ImageReaderType::Pointer imageFile = ImageReaderType::New() ;
imageFile->SetFileName( argv[ 2 ] ) ;
imageFile->Update() ;
typedef ImageType::DirectionType MatrixType ;
MatrixType matrix = imageFile->GetOutput()->GetDirection() ;
//Set parameters
typedef itkv3::Rigid3DTransform< double > RigidTransformType ;
RigidTransformType::Pointer rigid = RigidTransformType::New() ;
rigid->SetMatrix( matrix ) ;
//Creation of the itkTransformFileWriter
itk::TransformFileWriter::Pointer transformWriter = itk::TransformFileWriter::New() ;
transformWriter->SetFileName( argv[ 3 ] ) ;
transformWriter->AddTransform( rigid ) ;
transformWriter->Update() ;
return 0 ;
}