<div dir="ltr"><div><div><div>Hello Ziv,<br><br></div>Thanks for the report. There was indeed a bug in itkSimilarity2DTransform and itkCenteredSimilarity2DTransform. I submitted a patch [1] to correct the problem. It would be great if you could test it and review it.<br><br></div>Thanks!<br></div>Francois<br><div><div><br>[1] <a href="http://review.source.kitware.com/#/c/22633/">http://review.source.kitware.com/#/c/22633/</a><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Sep 14, 2017 at 12:34 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">
<div bgcolor="white" link="#0563C1" vlink="#954F72" lang="EN-US">
<div class="m_5528774405204111854WordSection1">
<p class="MsoNormal">Hello ITK developers,</p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">I encountered unexpected behavior with ITK parameter settings in degenerate cases for the CenteredSimilarity2DTransform and Similarity3DTransform classes.</p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">The degenerate parameter values I am referring to is setting the scale to zero. I encountered this issue when I blindly set all parameters to zero to get an identity transform (obviously scale should be one). It appears that setting the
scale factor to zero is acceptable, no exception (arbitrary choice which makes sense for the general SetParameters method – up to the user to make sure the parameter values make sense).</p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">The feature/bug I am referring to has to do with the GetInverse method (ill-defined for this degenerate case):
</p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">2D case - when I print the original transformation, it is identified as singular. When I invoke the GetInverse method vnl generates a warning with the resulting “inverse” transform including Nan and Inf , not identified as singular.</p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">3D case - when I print the original transformation, it is identified as singular. When I invoke the GetInverse method there is no warning and the “inverse” transform has numbers and is identified as singular.</p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Is this behavior fine and up to the user to deal with? Should the GetInverse generate an exception?</p>
<p class="MsoNormal"></p>
<p class="MsoNormal"> thanks</p>
<p class="MsoNormal"> Ziv</p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Code for the two cases below:</p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"> {<u></u><u></u></p>
<p class="MsoNormal"> typedef itk::Similarity3DTransform<<wbr>double> TransformType3D;<u></u><u></u></p>
<p class="MsoNormal"> // Test degenerate parameter settings<u></u><u></u></p>
<p class="MsoNormal"> TransformType3D::Pointer t1 = TransformType3D::New();<u></u><u></u></p>
<p class="MsoNormal"> TransformType3D::Pointer t1Inverse = TransformType3D::New();<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"> // Set parameters<u></u><u></u></p>
<p class="MsoNormal"> TransformType3D::<wbr>ParametersType parameters( t1->GetNumberOfParameters() );<u></u><u></u></p>
<p class="MsoNormal"> // Degenerate configuration with zero scale<u></u><u></u></p>
<p class="MsoNormal"> parameters[0] = 1.0;<u></u><u></u></p>
<p class="MsoNormal"> parameters[1] = 0.0;<u></u><u></u></p>
<p class="MsoNormal"> parameters[2] = 0.0;<u></u><u></u></p>
<p class="MsoNormal"> parameters[3] = 1.0;<u></u><u></u></p>
<p class="MsoNormal"> parameters[4] = 2.0;<u></u><u></u></p>
<p class="MsoNormal"> parameters[5] = 3.0;<u></u><u></u></p>
<p class="MsoNormal"> parameters[6] = 0.0; //scale<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"> t1->SetParameters( parameters );<u></u><u></u></p>
<p class="MsoNormal"> t1Inverse->SetParameters(<wbr>parameters);<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"> t1->GetInverse( t1Inverse );<u></u><u></u></p>
<p class="MsoNormal"> std::cout<< "**original**\n"<<t1;<u></u><u></u></p>
<p class="MsoNormal"> std::cout<< "**inverse**\n"<<t1Inverse<<"\<wbr>n";<u></u><u></u></p>
<p class="MsoNormal"> }<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"> {<u></u><u></u></p>
<p class="MsoNormal"> // Test degenerate parameter settings<u></u><u></u></p>
<p class="MsoNormal"> typedef itk::<wbr>CenteredSimilarity2DTransform<<wbr>double> TransformType2D;<u></u><u></u></p>
<p class="MsoNormal"> TransformType2D::Pointer t1 = TransformType2D::New();<u></u><u></u></p>
<p class="MsoNormal"> TransformType2D::Pointer t1Inverse = TransformType2D::New();<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"> // Set parameters<u></u><u></u></p>
<p class="MsoNormal"> TransformType2D::<wbr>ParametersType parameters( t1->GetNumberOfParameters() );<u></u><u></u></p>
<p class="MsoNormal"> // Degenerate configuration with zero scale<u></u><u></u></p>
<p class="MsoNormal"> parameters[0] = 0.0; //scale<u></u><u></u></p>
<p class="MsoNormal"> parameters[1] = -21.0 / 180.0 * itk::Math::pi;<u></u><u></u></p>
<p class="MsoNormal"> parameters[2] = 12.0;<u></u><u></u></p>
<p class="MsoNormal"> parameters[3] = -8.9;<u></u><u></u></p>
<p class="MsoNormal"> parameters[4] = 67.8;<u></u><u></u></p>
<p class="MsoNormal"> parameters[5] = -0.2;<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"> t1->SetParameters( parameters );<u></u><u></u></p>
<p class="MsoNormal"> t1->GetInverse( t1Inverse );<u></u><u></u></p>
<p class="MsoNormal"> std::cout<< "**original**\n"<<t1;<u></u><u></u></p>
<p class="MsoNormal"> std::cout<< "**inverse**\n"<<t1Inverse<<"\<wbr>n";<u></u><u></u></p>
<p class="MsoNormal"> }</p>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div>
<br>______________________________<wbr>_________________<br>
Community mailing list<br>
<a href="mailto:Community@itk.org">Community@itk.org</a><br>
<a href="http://public.kitware.com/mailman/listinfo/community" rel="noreferrer" target="_blank">http://public.kitware.com/<wbr>mailman/listinfo/community</a><br>
<br></blockquote></div><br></div>