I use rigid registration to get a transformation estimation represented by six numbers (three for rotation, three for translation). And I use the following code to generate the corresponding warp image. I wonder if there is any way to generate an inverse warp image? i.e. transformation from the fixed image to the moving image (Thanks!)
/** Create an setup displacement field generator. */
DisplacementFieldGeneratorType::Pointer dispfieldGenerator =
DisplacementFieldGeneratorType::New();
dispfieldGenerator->UseReferenceImageOn();
dispfieldGenerator->SetReferenceImage( fixedImage );
dispfieldGenerator->SetTransform( outputTransform );
try
{
dispfieldGenerator->Update();
}
catch ( itk::ExceptionObject & err )
{
std::cerr << "Exception detected while generating deformation field";
std::cerr << " : " << err << std::endl;
return EXIT_FAILURE;
}
typedef itk::ImageFileWriter< DisplacementFieldImageType > FieldWriterType;
FieldWriterType::Pointer fieldWriter = FieldWriterType::New();
fieldWriter->SetInput( dispfieldGenerator->GetOutput() );
fieldWriter->SetFileName( warpFieldName );
try
{
fieldWriter->Update();
}
catch( itk::ExceptionObject & excp )
{
std::cerr << "Exception thrown " << std::endl;
std::cerr << excp << std::endl;
return EXIT_FAILURE;
}