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 unsigned char 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->SetInterpolator( interpolator );
metric->SetFixedImage( fixedImage );
metric->SetMovingImage( movingImage );
metric->SetFixedImageRegion( fixedImage->GetBufferedRegion() );
try
{
metric->Initialize();
}
{
std::cerr << "Exception catched !" << std::endl;
std::cerr << excep << std::endl;
return EXIT_FAILURE;
}
MetricType::TransformParametersType 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;
const double value = metric->GetValue( displacement );
std::cout << dx << " " << dy << " " << value << std::endl;
}
}
return EXIT_SUCCESS;
}