<div dir="ltr">Hi guys,<div><br></div><div>thank you very much for your help. I was trying to follow the examples you sent me (converting it in native C++ ITK code), but it seems that the optimizer does not work properly. In particular, no matter the number of angles and the step length I choose, it always gives me the same result. It seems to me that the optimizer is never updating the angles, therefore it is not following the grid I create. Also the metric is always 0. There is definitely something wrong! Here is part of the script I am using and the result I always get. Am I overlooking anything? </div><div><br></div><div><div> typedef itk::Euler2DTransform< double > <span class="" style="white-space:pre"> </span>TransformType;</div><div> typedef itk::ExhaustiveOptimizerv4< double > <span class="" style="white-space:pre"> </span>OptimizerType; </div><div> typedef itk::MeanSquaresImageToImageMetricv4< FixedInputImageType, MovingInputImageType > <span class="" style="white-space:pre"> </span>MetricType;<br></div><div> typedef itk::CenteredTransformInitializer< TransformType, FixedInputImageType, MovingInputImageType > <span class="" style="white-space:pre"> </span>TransformInitializerType;</div><div> typedef itk::ImageRegistrationMethodv4< FixedInputImageType, MovingInputImageType, TransformType ><span class="" style="white-space:pre"> </span>RegistrationType;</div><div><br></div><div> typename TransformType::Pointer transform = TransformType::New();</div><div> typename MetricType::Pointer metric = MetricType::New();</div><div> typename OptimizerType::Pointer optimizer = OptimizerType::New();</div><div> typename RegistrationType::Pointer registration = RegistrationType::New();</div><div> typename TransformInitializerType::Pointer initializer = TransformInitializerType::New();</div><div><br></div><div> unsigned int angles = 12;<br></div><div> OptimizerType::StepsType steps( transform->GetNumberOfParameters() );</div><div> steps[0] = int(angles/2);</div><div> steps[1] = 0;</div><div> steps[2] = 0;</div><div> optimizer->SetNumberOfSteps( steps );<br></div><div><br></div><div> OptimizerType::ScalesType scales( transform->GetNumberOfParameters() );<br></div><div> scales[0] = 2.0 * vnl_math::pi / angles;</div><div> scales[1] = 1.0;</div><div> scales[2] = 1.0; </div><div><br></div><div> optimizer->SetScales( scales );<br></div><div><br></div><div> initializer->SetTransform( transform );<br></div><div> initializer->SetFixedImage( fixImage );</div><div> initializer->SetMovingImage( movImage );</div><div> //initializer->GeometryOn();</div><div> initializer->InitializeTransform();</div><div><br></div><div> // Initialize registration</div><div> registration->SetMetric( metric );</div><div> registration->SetOptimizer( optimizer );</div><div> registration->SetFixedImage( fixedImage );</div><div> registration->SetMovingImage( movingImage ); </div><div> registration->SetInitialTransform( transform );</div><div><br></div><div> try</div><div> {</div><div> registration->Update();</div><div> }</div><div> catch( itk::ExceptionObject & err )</div><div> {</div><div> std::cerr << "ExceptionObject caught !" << std::endl;</div><div> std::cerr << err << std::endl;</div><div> return EXIT_FAILURE;</div><div> }</div><div> </div><div>Result:</div><div><br></div><div><div>Final parameters: [-1.8849555921538759, -40, 40]</div><div>Result = </div><div>Metric value = 0</div><div>Angle (rad) = -1.88496</div><div>Angle (degrees) = -108</div><div>Iterations = 13</div><div>Rotation Center = [225.5, 185.5]</div><div>ExhaustiveOptimizerv4: Completed sampling of parametric space of size 3</div></div><div><br></div><div> </div></div><div>Thank you very much,<br></div><div>Pietro </div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature"><div dir="ltr"><div>Pietro Nardelli<i>, MEngSc, BE</i><i><font size="1"><br></font></i></div><div><p style="margin:0px">Ph.D Candidate<u></u><u></u></p><p style="margin:0px">School of Engineering</p><p style="margin:0px">Electrical & Electronic Engineering</p><p style="margin:0px">University College Cork<br></p><p style="margin:0px">College Road<br></p><p style="margin:0px"><u></u></p><p style="margin:0px">Cork, Ireland</p></div></div></div></div>
<br><div class="gmail_quote">On Fri, May 15, 2015 at 7:21 PM, Yaniv, Ziv Rafael (NIH/NLM/LHC) [C] <span dir="ltr"><<a href="mailto:zivrafael.yaniv@nih.gov" target="_blank">zivrafael.yaniv@nih.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello Pietro,<br>
<br>
You should use the ExhaustiveOptimizerv4 (<a href="http://www.itk.org/Doxygen/html/classitk_1_1ExhaustiveOptimizerv4.html" target="_blank">http://www.itk.org/Doxygen/html/classitk_1_1ExhaustiveOptimizerv4.html</a>) which allows you to set a grid on which the similarity metric is evaluated.<br>
<br>
If you are familiar with python, then the following SimpleITK notebook may be of use to you (see last section): <a href="https://github.com/zivy/SimpleITK-Notebook-Staging/blob/master/registration3.ipynb" target="_blank">https://github.com/zivy/SimpleITK-Notebook-Staging/blob/master/registration3.ipynb</a><br>
<br>
regards<br>
Ziv<br>
<br>
From: Pietro Nardelli <<a href="mailto:p.nardelli@umail.ucc.ie">p.nardelli@umail.ucc.ie</a><mailto:<a href="mailto:p.nardelli@umail.ucc.ie">p.nardelli@umail.ucc.ie</a>>><br>
Date: Friday, May 15, 2015 at 2:13 PM<br>
To: "<a href="mailto:insight-users@itk.org">insight-users@itk.org</a><mailto:<a href="mailto:insight-users@itk.org">insight-users@itk.org</a>>" <<a href="mailto:insight-users@itk.org">insight-users@itk.org</a><mailto:<a href="mailto:insight-users@itk.org">insight-users@itk.org</a>>><br>
Subject: [ITK-users] 2D rigid transformation<br>
<div class="HOEnZb"><div class="h5"><br>
Hello guys,<br>
<br>
is there a way to have a 2D rigid registration that uses a specific number of rotations and chooses the best one? I have two images that are simply rotated with respect to each other, and I would like to register them using for example 36 rotations (therefore computing the mean squared error every 10 degrees). At the moment I am using the 2DRigidTransform with a specified center, with a regular step descent optimizer and the ImageRegistrationMethodv4. I saw that the transform has the function SetFixedParameters() but I am not really sure whether I understand correctly that that would tell the optimizer the angles (and translations) to use at every iteration. Could anyone please clarify this?<br>
<br>
Thank you very much,<br>
Pietro<br>
<br>
<br>
</div></div></blockquote></div><br></div>