[Insight-users] [insight-users] Can not reproduce metric value

Quy Pham Sy phamsyquybk at gmail.com
Fri Oct 2 16:09:01 EDT 2009


hi,
I run ImageRegistration7 example in ITK.
and the output like following
-------------------------------------
 Scale         = 1.08438
 Angle (radians) 0.154531
 Angle (degrees) 8.85397
 Center X      = 170.327
 Center Y      = 148.556
 Translation X = -26.6822
 Translation Y = -93.4428
 Iterations    = 500
 Metric value  = 4551.86
---------------------------------------

I made a program in which i use a same metric, transformation, interpolate
object type as above example, with same two input image file. I set above
value to calculate metric value directly from metric object, but the result
is not same as what the example made..

here is the code, did i miss something?
I'm running out of time! really appreciate any help!

-------------------------------------------------------------------------
int main( int argc, char * argv[] )
{
const     unsigned int   Dimension = 2;
 typedef   unsigned char  PixelType;
typedef itk::Image< PixelType, Dimension >   ImageType;
 typedef itk::ImageFileReader< ImageType >  ReaderType;

ReaderType::Pointer fixedReader  = ReaderType::New();
 ReaderType::Pointer movingReader = ReaderType::New();

fixedReader->SetFileName(  "fixed.bmp" );
 movingReader->SetFileName( "moving.bmp" );

 try
{
fixedReader->Update();
 movingReader->Update();
}
catch( itk::ExceptionObject & excep )
 {
std::cerr << "Exception catched !" << std::endl;
 std::cerr << excep << std::endl;
}

typedef itk::MeanSquaresImageToImageMetric< ImageType, ImageType >
 MetricType;
 MetricType::Pointer metric = MetricType::New();

typedef itk::CenteredSimilarity2DTransform < double >  TransformType;
TransformType::Pointer transform = TransformType::New();

typedef itk::LinearInterpolateImageFunction< ImageType, double >
 InterpolatorType;
 InterpolatorType::Pointer interpolator = InterpolatorType::New();

ImageType::Pointer fixedImage  = fixedReader->GetOutput();
ImageType::Pointer movingImage = movingReader->GetOutput();

typedef itk::CenteredTransformInitializer< TransformType, ImageType,
ImageType >  TransformInitializerType;
 TransformInitializerType::Pointer initializer =
TransformInitializerType::New();

initializer->SetTransform(   transform );
 initializer->SetFixedImage(  fixedImage );
initializer->SetMovingImage( movingImage );
 initializer->MomentsOn();
initializer->InitializeTransform();

metric->SetTransform( transform );
metric->SetInterpolator( interpolator );
 metric->SetFixedImage(  fixedImage  );
metric->SetMovingImage( movingImage );
 metric->SetFixedImageRegion(  fixedImage->GetBufferedRegion()  );

try
 {
metric->Initialize();
}
 catch( itk::ExceptionObject & excep )
{
std::cerr << "Exception catched !" << std::endl;
 std::cerr << excep << std::endl;
return EXIT_FAILURE;
}
  transform->SetScale(1.08438);
 transform->SetAngle(8.85397);
TransformType::TranslationType translation;
 translation[0] = -26.6822;
translation[1] = -93.6822;

MetricType::TransformParametersType transformParams =
transform->GetParameters();

double metricval = metric->GetValue(transformParams);
 return EXIT_SUCCESS;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20091003/ea76af47/attachment-0001.htm>


More information about the Insight-users mailing list