int main( int argc, char * argv[] )
{
if( argc < 3 )
{
std::cerr << "Usage: " << std::endl;
std::cerr << argv[0] << " fixedImage movingImage" << std::endl;
return EXIT_FAILURE;
}
const unsigned int Dimension = 2;
typedef float PixelType;
ReaderType::Pointer fixedReader = ReaderType::New();
ReaderType::Pointer movingReader = ReaderType::New();
fixedReader->SetFileName( argv[ 1 ] );
movingReader->SetFileName( argv[ 2 ] );
try
{
fixedReader->Update();
movingReader->Update();
}
{
std::cerr << "Exception catched !" << std::endl;
std::cerr << excep << std::endl;
}
ImageType, ImageType > MetricType;
MetricType::Pointer metric = MetricType::New();
TransformType::Pointer transform = TransformType::New();
ImageType, double > InterpolatorType;
InterpolatorType::Pointer interpolator = InterpolatorType::New();
transform->SetIdentity();
ImageType::ConstPointer fixedImage = fixedReader->GetOutput();
ImageType::ConstPointer movingImage = movingReader->GetOutput();
metric->SetTransform( transform );
metric->SetMovingInterpolator( interpolator );
metric->SetFixedImage( fixedImage );
metric->SetMovingImage( movingImage );
metric->SetVirtualDomainFromImage( fixedImage );
try
{
metric->Initialize();
}
{
std::cerr << "Exception catched !" << std::endl;
std::cerr << excep << std::endl;
return EXIT_FAILURE;
}
MetricType::MovingTransformParametersType displacement( Dimension );
const int rangex = 50;
const int rangey = 50;
for( int dx = -rangex; dx <= rangex; dx++ )
{
for( int dy = -rangey; dy <= rangey; dy++ )
{
displacement[0] = dx;
displacement[1] = dy;
metric->SetParameters( displacement );
const double value = metric->GetValue();
std::cout << dx << " " << dy << " " << value << std::endl;
}
}
return EXIT_SUCCESS;
}