<div dir="ltr">Hi John,<div class="gmail_extra"><br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><br>But am I interpreting the results from the inverse correctly here? It is a 2D transform.<div class="">
<br><br>  TransformType::InverseTransformBasePointer inverse =  transform->GetInverseTransform();<br>  TransformType::ParametersType inverseParameters  = inverse->GetParameters();<br>
    <br>    float a11 = inverseParameters[0];<br>    float a12 = inverseParameters[1];<br>    float a21 = inverseParameters[2];<br>    float a22 = inverseParameters[3];<br></div>    float Tx =  inverseParameters[4]; //Is this correct?</div>
</div></div></blockquote><div><br></div><div>Yes, this should be correct.</div><div><br></div><div>HTH,</div><div>Matt</div><div><br></div><div>PS.  Please reply-to-all so the message hits the lists.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><div><div><div class=""><br>
    float Ty =  inverseParameters[5];<br></div><div class="">    Cx = transform->GetCenter()[0];<br></div><div class="">    Cy = transform->GetCenter()[1];<br><br></div></div>Thank you<span class="HOEnZb"><font color="#888888"><br>
</font></span></div><span class="HOEnZb"><font color="#888888">John<br><div><div><br><div><div><br></div></div></div></div></font></span></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra">
<br><br><div class="gmail_quote">On Wed, Feb 12, 2014 at 10:02 AM, Matt McCormick <span dir="ltr"><<a href="mailto:matt.mccormick@kitware.com" target="_blank">matt.mccormick@kitware.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div dir="ltr">Hi John,<div><br></div><div>Could a fully buildable version of the code demonstrating the issue be posted, possibly through a Github Gist [1]?</div><div><br></div><div>The center of the inverse should be the same, and it is important to set it before calling GetInverse() as documented here: [2].</div>


<div><br></div><div>Hope this helps,</div><div>Matt</div><div><br></div><div>[1] <a href="https://gist.github.com/" target="_blank">https://gist.github.com/</a></div><div>[2] <a href="http://www.itk.org/Doxygen/html/classitk_1_1MatrixOffsetTransformBase.html#a1e97fbe21d53aa805a9692ca9ab95fdb" target="_blank">http://www.itk.org/Doxygen/html/classitk_1_1MatrixOffsetTransformBase.html#a1e97fbe21d53aa805a9692ca9ab95fdb</a></div>


</div><div class="gmail_extra"><br><br><div class="gmail_quote"><div><div>On Wed, Feb 12, 2014 at 12:43 PM, John D <span dir="ltr"><<a href="mailto:john.dz.eis@gmail.com" target="_blank">john.dz.eis@gmail.com</a>></span> wrote:<br>


</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div><div dir="ltr"><div>Sorry. Forgot to include the code in the earlier post<br><br></div>
%The affine parameters come in the vAffineParameters vector to the function<br>
<br><div><div>typedef itk::AffineTransform< double, 2 > TransformType;<br>
    TransformType::Pointer      transform     = TransformType::New();<br>    TransformType::ParametersType affParameters(transform->GetNumberOfParameters());<br>    for(int i=0;i<6;i++)<br>        affParameters[i] = vAffineParameters[i];<br>



    transform->SetParameters(affParameters);<br>    <br>   double center[2];<br>    center[0] = vAffineParameters[6];<br>    center[1] = vAffineParameters[7];<br>    transform->SetCenter(center);<br><br>    TransformType::InverseTransformBasePointer inverse =  transform->GetInverseTransform();<br>



    TransformType::ParametersType inverseParameters  = inverse->GetParameters();<br>    <br>    float a11 = inverseParameters[0];<br>    float a12 = inverseParameters[1];<br>    float a21 = inverseParameters[2];<br>    float a22 = inverseParameters[3];<br>



    float Tx = inverseParameters[4]; //Tx and Ty seems to be not correct?<br>    float Ty = inverseParameters[5]; //Tx and Ty seems to be not correct? <br>    Cx = transform->GetCenter()[0]; //Is there a way to get the center from the inverse transform?<br>



    Cy = transform->GetCenter()[1];<br><br></div></div></div><div><div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Feb 12, 2014 at 9:40 AM, John D <span dir="ltr"><<a href="mailto:john.dz.eis@gmail.com" target="_blank">john.dz.eis@gmail.com</a>></span> wrote:<br>



<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div><div><div>Hello users,<br><br>  I have a problem where I need to compute the inverse of an affine transform in 2D.<br>



<br></div>I am seeing a problem in the results. Lets say my affine matrix has just pure rotation at 45 degree.<br>
<br>So my A matrix is [cost(45) -sin(45); sin(45 cos(45)]. There is no translation and so [Tx Ty] = [0 0].  I am trying to rotate a square that is 6000 on each side and my center of rotation is mid point of the square [3000 3000]<br>




<br></div>When I use transform->GetInverseTransform() to find the inverse transform<br><br></div>I am getting the correct coordinates for the A matrix. However the returned translations in the inverse matrix are wrong. I would have expected the Tx, Ty to be [0 0] in the inverse also since rotation is wrt to the center. However I am getting [Tx, Ty] = [3000, -1243]<br>




<br></div>What am I missing? Also when computing the inverse, will the center of rotation get changed? How can I get the new center of rotation?<br><br></div>Thanks,<br></div>John<br><div><div><br><br></div></div></div>
</blockquote></div><br></div>
</div></div><br></div></div>_____________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at<br>
<a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Kitware offers ITK Training Courses, for more information visit:<br>
<a href="http://www.kitware.com/products/protraining.php" target="_blank">http://www.kitware.com/products/protraining.php</a><br>
<br>
Please keep messages on-topic and check the ITK FAQ at:<br>
<a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
<br>_______________________________________________<br>
Community mailing list<br>
<a href="mailto:Community@itk.org" target="_blank">Community@itk.org</a><br>
<a href="http://public.kitware.com/cgi-bin/mailman/listinfo/community" target="_blank">http://public.kitware.com/cgi-bin/mailman/listinfo/community</a><br>
<br></blockquote></div><br></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div></div>