[ITK] [ITK-users] ExhaustiveOptimizerv4 not working as expected

Jan Bergmeier jan.bergmeier at imes.uni-hannover.de
Thu Apr 30 04:26:50 EDT 2015


Hello everyone,

I am trying to get the ExhaustiveOptimizerv4 to work. Therefore I built a
minimal example:

    typedef itk::Image< double, 2 > ImageType;
    typedef itk::ImageFileReader< ImageType > ReaderType;
    typedef itk::MeanSquaresImageToImageMetricv4< ImageType, ImageType >
MetricType;
    typedef itk::ExhaustiveOptimizerv4< double > OptimizerType;
    typedef itk::TranslationTransform< double, 2 >TransformType;
    typedef itk::LinearInterpolateImageFunction< ImageType, double >
LinearInterpolatorType;
    typedef itk::ImageRegistrationMethodv4< ImageType, ImageType,
TransformType > RegistrationType;

    ReaderType::Pointer fixedReader = ReaderType::New();
    ReaderType::Pointer movingReader = ReaderType::New();
    MetricType::Pointer metric = MetricType::New();
    OptimizerType::Pointer optimizer = OptimizerType::New();
    TransformType::Pointer identityTransform = TransformType::New();
    LinearInterpolatorType::Pointer fixedInterpolator =
LinearInterpolatorType::New();
    LinearInterpolatorType::Pointer movingInterpolator =
LinearInterpolatorType::New();
    RegistrationType::Pointer registration = RegistrationType::New();

    fixedReader->SetFileName( "fixedImage.png" );
    movingReader->SetFileName( "movingImage.png" );

    metric->SetFixedInterpolator( fixedInterpolator );
    metric->SetMovingInterpolator( movingInterpolator );

    identityTransform->SetIdentity();

    OptimizerType::StepsType steps(
identityTransform->GetNumberOfParameters() );
    steps[1] = 10;
    steps[2] = 50;
    optimizer->SetNumberOfSteps( steps );
    optimizer->SetStepLength( 1 );

    registration->SetMetric( metric );
    registration->SetOptimizer( optimizer );
    registration->SetFixedImage( fixedReader->GetOutput() );
    registration->SetMovingImage( movingReader->GetOutput() );
    registration->SetFixedInitialTransform( identityTransform );
    registration->SetMovingInitialTransform( identityTransform );

    registration->Update();

    std::cout << "Best value: " << registration->GetOptimizer()->GetValue()
<< std::endl;
    std::cout << "Number of iterations: " <<
optimizer->GetCurrentIteration() << std::endl;


When I run this code, the number of iterations are 21. I would expect them
to be 10*50 = 500, but the second steps entry seems to have no effect.

Furthermore, the output from the registration metric is always 0, while it
isn't if I use different optimizers.


I hope anyone can help me.
Thanks in advance!

Jan



--
View this message in context: http://itk-users.7.n7.nabble.com/ExhaustiveOptimizerv4-not-working-as-expected-tp35618.html
Sent from the ITK - Users mailing list archive at Nabble.com.
_____________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html

Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.php

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://public.kitware.com/mailman/listinfo/insight-users


More information about the Community mailing list