[Insight-users] [insight-users] Can not reproduce metric value
Bill Lorensen
bill.lorensen at gmail.com
Fri Oct 2 16:32:40 EDT 2009
/** Set/Get the angle of rotation in radians */
----------
void SetAngle(TScalarType angle);
itkGetConstReferenceMacro( Angle, TScalarType );
Try:
transform->SetAngle(0.154531);
On Fri, Oct 2, 2009 at 4:09 PM, Quy Pham Sy <phamsyquybk at gmail.com> wrote:
> 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;
> }
>
>
>
>
>
>
>
>
>
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users
>
>
More information about the Insight-users
mailing list