[ITK] ExhaustiveOptimizerv4 not working as expected

Bergmeier, Jan Jan.Bergmeier at imes.uni-hannover.de
Thu Apr 30 04:19:57 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::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();
    RegistrationType::Pointer registration = RegistrationType::New();

    fixedReader->SetFileName( "/home/jan/mitk/DicomTestSceneBuild/drillImg_000000.png" );
    movingReader->SetFileName( "/home/jan/mitk/DicomTestSceneBuild/drillImg_source_visEar0.05_dhRad1mm.png" );

    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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/community/attachments/20150430/cfc1c6c9/attachment.html>


More information about the Community mailing list