int main( int argc, char * argv[] )
{
if( argc < 4 )
{
std::cerr << "Usage: " << std::endl;
std::cerr << argv[0] << " inputImageFile inputDisplacementField outputImageFile" << std::endl;
return EXIT_FAILURE;
}
const unsigned int Dimension = 2;
typedef float VectorComponentType;
typedef unsigned char PixelType;
ReaderType::Pointer reader = ReaderType::New();
WriterType::Pointer writer = WriterType::New();
reader->SetFileName( argv[1] );
writer->SetFileName( argv[3] );
FieldReaderType::Pointer fieldReader = FieldReaderType::New();
fieldReader->SetFileName( argv[2] );
fieldReader->Update();
DisplacementFieldType::ConstPointer deformationField =
fieldReader->GetOutput();
ImageType,
DisplacementFieldType > FilterType;
FilterType::Pointer filter = FilterType::New();
ImageType, double > InterpolatorType;
InterpolatorType::Pointer interpolator = InterpolatorType::New();
filter->SetInterpolator( interpolator );
filter->SetOutputSpacing( deformationField->GetSpacing() );
filter->SetOutputOrigin( deformationField->GetOrigin() );
filter->SetOutputDirection( deformationField->GetDirection() );
filter->SetDisplacementField( deformationField );
filter->SetInput( reader->GetOutput() );
writer->SetInput( filter->GetOutput() );
try
{
writer->Update();
}
{
std::cerr << "Exception thrown " << std::endl;
std::cerr << excp << std::endl;
}
return EXIT_SUCCESS;
}