<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">&nbsp; sorry I accidentally press the wrong button to send -<br><br>---------------------------------------------------------------------<br>Thanks a lot, for the help!<br>&nbsp; I did successfully use itk::LandmarkBasedTransformInitializer to generate results.<br>&nbsp;
My question is - does this class support affine transform? looks to me
it is working fine with rigid body transform, but the results not
correct if it is affine, for example, I input the following points -<br><br>The points are <br>&nbsp;
X=[36,257; 77,257; 30,370; 62,370;77,323];<br>&nbsp;
X'=[118,257;77,257;126,370;93,370;77,323];<br><br>&nbsp;R =<br><br>&nbsp;&nbsp; -0.9999&nbsp;&nbsp;&nbsp; 0.0110<br>&nbsp;&nbsp;&nbsp; 0.0110&nbsp;&nbsp;&nbsp; 0.9999<br><br>is the rotation matrix I am expecting to get (I got from MATLAB svd), but I got <br><br>R =<br><br>&nbsp;&nbsp; 0.980838 &nbsp;&nbsp; -0.194827<br>&nbsp;&nbsp; 0.194827 &nbsp;&nbsp; 0.980838<br><br>Below are the codes I am using .<br><br>&nbsp; Did I do something wrong here?<br><br>Thanks a lot,<br><br>Suyang<br><br>/////////////////////////////////////////////////////////////<br>&nbsp;&nbsp;&nbsp; const double nPI = 4.0 * vcl_atan( 1.0 );&nbsp; <br><br>&nbsp;&nbsp;&nbsp; typedef&nbsp; unsigned char&nbsp; PixelType;<br>&nbsp;&nbsp;&nbsp; const unsigned int Dimension = 2;<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; typedef itk::Image&lt; PixelType, Dimension &gt;&nbsp; FixedImageType;<br>&nbsp;&nbsp;&nbsp; typedef itk::Image&lt; PixelType, Dimension &gt;&nbsp;
 MovingImageType;<br><br>&nbsp;&nbsp;&nbsp; FixedImageType::Pointer fixedImage&nbsp;&nbsp; = FixedImageType::New();<br>&nbsp;&nbsp;&nbsp; MovingImageType::Pointer movingImage = MovingImageType::New();<br><br>&nbsp;<br>&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; // Set the transform type..<br>&nbsp;&nbsp;&nbsp; typedef itk::Rigid2DTransform&lt; double &gt; TransformType;<br>&nbsp;&nbsp;&nbsp; TransformType::Pointer transform = TransformType::New();<br>&nbsp;&nbsp;&nbsp; typedef itk::LandmarkBasedTransformInitializer&lt; TransformType, <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FixedImageType, MovingImageType &gt; TransformInitializerType;<br>&nbsp;&nbsp;&nbsp; TransformInitializerType::Pointer initializer = TransformInitializerType::New();<br>&nbsp;&nbsp;&nbsp; initializer-&gt;DebugOn();<br><br>&nbsp;&nbsp;&nbsp; // Set fixed and moving landmarks<br>&nbsp;&nbsp;&nbsp; TransformInitializerType::LandmarkPointContainer
 fixedLandmarks;<br>&nbsp;&nbsp;&nbsp; TransformInitializerType::LandmarkPointContainer movingLandmarks;<br>&nbsp;&nbsp;&nbsp; TransformInitializerType::LandmarkPointType point;<br>&nbsp;&nbsp;&nbsp; TransformInitializerType::LandmarkPointType tmp;<br><br>&nbsp;&nbsp;&nbsp; TransformInitializerType::LandmarkPointContainer testLandmarks;<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; //pt1<br>&nbsp;&nbsp;&nbsp; point[0]=36.0;<br>&nbsp;&nbsp;&nbsp; point[1]=257.0;<br>&nbsp;&nbsp;&nbsp; fixedLandmarks.push_back(point);<br>&nbsp;&nbsp;&nbsp; point[0]=118.0;<br>&nbsp;&nbsp;&nbsp; point[1]=257.0;<br>&nbsp;&nbsp;&nbsp; movingLandmarks.push_back(point);<br><br>&nbsp;&nbsp;&nbsp; //pt2<br>&nbsp;&nbsp;&nbsp; point[0]=77.0;<br>&nbsp;&nbsp;&nbsp; point[1]=257.0;<br>&nbsp;&nbsp;&nbsp; fixedLandmarks.push_back(point);<br>&nbsp;&nbsp;&nbsp; point[0]=77.0;<br>&nbsp;&nbsp;&nbsp; point[1]=257.0;<br>&nbsp;&nbsp;&nbsp;
 movingLandmarks.push_back(point);<br><br>&nbsp;&nbsp;&nbsp; //pt3<br>&nbsp;&nbsp;&nbsp; point[0]=30.0;<br>&nbsp;&nbsp;&nbsp; point[1]=370.0;<br>&nbsp;&nbsp;&nbsp; fixedLandmarks.push_back(point);<br>&nbsp;&nbsp;&nbsp; point[0]=126.0;<br>&nbsp;&nbsp;&nbsp; point[1]=370.0;<br>&nbsp;&nbsp;&nbsp; movingLandmarks.push_back(point);<br><br>&nbsp;&nbsp;&nbsp; //pt4<br>&nbsp;&nbsp;&nbsp; point[0]=62.0;<br>&nbsp;&nbsp;&nbsp; point[1]=370.0;<br>&nbsp;&nbsp;&nbsp; fixedLandmarks.push_back(point);<br>&nbsp;&nbsp;&nbsp; point[0]=93.0;<br>&nbsp;&nbsp;&nbsp; point[1]=370.0;<br>&nbsp;&nbsp;&nbsp; movingLandmarks.push_back(point);<br><br>&nbsp;&nbsp;&nbsp; //pt5<br>&nbsp;&nbsp;&nbsp; point[0]=77.0;<br>&nbsp;&nbsp;&nbsp; point[1]=323.0;<br>&nbsp;&nbsp;&nbsp; fixedLandmarks.push_back(point);<br>&nbsp;&nbsp;&nbsp; point[0]=77.0;<br>&nbsp;&nbsp;&nbsp; point[1]=323.0;<br>&nbsp;&nbsp;&nbsp; movingLandmarks.push_back(point);<br><br>&nbsp;&nbsp;&nbsp; // test
 pt<br>&nbsp;&nbsp;&nbsp; point[0]=51.0;<br>&nbsp;&nbsp;&nbsp; point[1]=320.0;<br>&nbsp;&nbsp;&nbsp; testLandmarks.push_back(point);<br><br>&nbsp;&nbsp;&nbsp; initializer-&gt;SetFixedLandmarks(fixedLandmarks);<br>&nbsp;&nbsp;&nbsp; initializer-&gt;SetMovingLandmarks(movingLandmarks);<br><br>&nbsp;&nbsp;&nbsp; initializer-&gt;SetTransform( transform );<br>&nbsp;&nbsp;&nbsp; initializer-&gt;InitializeTransform();<br><br>&nbsp;&nbsp;&nbsp; TransformInitializerType::PointsContainerConstIterator <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fitr = fixedLandmarks.begin();<br>&nbsp;&nbsp;&nbsp; TransformInitializerType::PointsContainerConstIterator <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mitr = movingLandmarks.begin();<br><br>&nbsp;&nbsp;&nbsp; TransformInitializerType::PointsContainerConstIterator <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; testtr = testLandmarks.begin();<br><br>&nbsp;&nbsp;&nbsp; typedef TransformInitializerType::OutputVectorType&nbsp;
 OutputVectorType;<br>&nbsp;&nbsp;&nbsp; OutputVectorType error;<br>&nbsp;&nbsp;&nbsp; OutputVectorType::RealValueType tolerance = 0.1;<br>&nbsp;&nbsp;&nbsp; bool failed = false;<br>&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; std::cout &lt;&lt; transform-&gt;TransformPoint( *testtr ) &lt;&lt; std::endl;<br><br>&nbsp;&nbsp;&nbsp;&nbsp; std::cout &lt;&lt; "&nbsp; The transform computed was: ";<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; transform-&gt;Print(std::cout);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; std::cout &lt;&lt; " DONE " &lt;&lt; std::endl;<br>&nbsp;<br><br>--- On <b>Thu, 5/6/10, Suyang Mei <i>&lt;suyang_mei@yahoo.com&gt;</i></b> wrote:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><br>From: Suyang Mei &lt;suyang_mei@yahoo.com&gt;<br>Subject: Re: [Insight-users] point based registration using least square<br>To: "Andinet Enquobahrie" &lt;andinet.enqu@kitware.com&gt;<br>Cc: insight-users@itk.org<br>Date:
 Thursday, May 6, 2010, 2:13 PM<br><br><div id="yiv1005139106"><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td style="font-family: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-size: inherit; line-height: inherit; font-size-adjust: inherit; font-stretch: inherit; -x-system-font: none;" valign="top"><br>&nbsp; Thanks a lot, for the help!<br>&nbsp; I did successfully use itk::LandmarkBasedTransformInitializer to generate results.<br>&nbsp; My question is - does this class support affine transform? looks to me it is working fine with rigid body transform, but the results not correct if it is affine, for example, I input the following points -<br><br>The points are <br>&nbsp;
X=[36,257; <br>77,257; 30,370; 62,370;77,323];<br>&nbsp;
X'=[118,257;77,257;126,370;93,370;77,323];<br><br>&nbsp;R =<br><br>&nbsp;&nbsp; -0.9999&nbsp;&nbsp;&nbsp; 0.0110<br>&nbsp;&nbsp;&nbsp; 0.0110&nbsp;&nbsp;&nbsp; 0.9999<br><br>is the rotation matrix I am expecting to get (I got from MATLAB svd), but I got <br><br>R =<br><br>&nbsp;&nbsp; 0.980838 &nbsp;&nbsp; -0.194827<br>&nbsp;&nbsp; 0.194827 &nbsp;&nbsp; 0.980838<br><br><br><br>--- On <b>Wed, 5/5/10, Andinet Enquobahrie <i>&lt;andinet.enqu@kitware.com&gt;</i></b> wrote:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><br>From: Andinet Enquobahrie &lt;andinet.enqu@kitware.com&gt;<br>Subject: Re: [Insight-users] point based registration using least square<br>To: "Suyang Mei" &lt;suyang_mei@yahoo.com&gt;<br>Cc: insight-users@itk.org<br>Date: Wednesday, May 5, 2010, 4:54 AM<br><br><div id="yiv495672498">Hi Suyang-<div><br></div><div>There is ITK&nbsp;landmark-based registration class that probably does what
 you are looking for.&nbsp;</div><div><br></div><div>itk::LandmarkBasedTransformInitializer</div><div><br></div><div>This registration class implements&nbsp;an absolute orientation solution using unit quaternions. It is&nbsp;a closed-form solution to the least-squares problem of computing transformation&nbsp;parameters between two coordinate systems.</div>
<div><br></div><div>Hope that helps</div><div>-Andinet</div><div><br><div class="gmail_quote">On Tue, May 4, 2010 at 8:56 PM, Suyang Mei <span dir="ltr">&lt;<a rel="nofollow">suyang_mei@yahoo.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td style="font-family: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-size: inherit; line-height: inherit; font-size-adjust: inherit; font-stretch: inherit;" valign="top">Hi, all -<br><br>&nbsp; I have a simple question here -<br><br>I'd like to perform point based image registration by using least square approach (basically finding the rotation matrix by using singular value decomposition SVD). Inputs are two sets of corresponding points, and I just need to get the transformation matrix back. <br>

<br>More like the functions in Examples\Patened\ICP*.cxx, but use closed form instead of iterative approach. What is the ITK filter to perform this?<br><br>&nbsp; Thanks a lot in advance.<br><br>Suyang<br></td></tr></tbody></table>

<br>

      <br>_____________________________________<br>
Powered by <a rel="nofollow" target="_blank" href="http://www.kitware.com">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at<br>
<a rel="nofollow" target="_blank" href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Kitware offers ITK Training Courses, for more information visit:<br>
<a rel="nofollow" target="_blank" href="http://www.kitware.com/products/protraining.html">http://www.kitware.com/products/protraining.html</a><br>
<br>
Please keep messages on-topic and check the ITK FAQ at:<br>
<a rel="nofollow" target="_blank" href="http://www.itk.org/Wiki/ITK_FAQ">http://www.itk.org/Wiki/ITK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a rel="nofollow" target="_blank" href="http://www.itk.org/mailman/listinfo/insight-users">http://www.itk.org/mailman/listinfo/insight-users</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>Andinet Enquobahrie, Ph.D.<br>Kitware, Inc. - North Carolina Office<br><a rel="nofollow" target="_blank" href="http://www.kitware.com">http://www.kitware.com</a><br>(919) 969-6990 x311<br>

</div>
</div></blockquote></td></tr></tbody></table><br>

      </div></blockquote></td></tr></table><br>