<div dir="ltr"><div><div>Before the icp, can you:<br></div>target-&gt;Print(std:;cout);<br></div>and post the results<br><br><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sun, Apr 14, 2013 at 11:00 AM, z.adva <span dir="ltr">&lt;<a href="mailto:adva.zair@mail.huji.ac.il" target="_blank">adva.zair@mail.huji.ac.il</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
I&#39;m trying to perform registration on two PolyData objects, but the<br>
resulting transformation is far from  being the solution.<br>
I used the code from<br>
<a href="http://www.vtk.org/Wiki/VTK/Examples/Cxx/Filtering/IterativeClosestPointsTransform" target="_blank">http://www.vtk.org/Wiki/VTK/Examples/Cxx/Filtering/IterativeClosestPointsTransform</a><br>
without much changes.<br>
<br>
For debug, I simply ran the ICP with source=target and expected to get the<br>
identity matrix, but I got different matrix, and the transformation was bad.<br>
<br>
When the ICP&#39;s debug-flag was on, it said that after about 29 iterations the<br>
mean-distance was<br>
very small (~10^-6), although when I viewed the solution it seems not close<br>
at all.<br>
<br>
I started with fractured bone-object and then extracted its fracture-surface<br>
in order to match the two surfaces. When I ran the ICP on one of the<br>
original bones it worked well ( the output was the identity matrix ) so the<br>
odd behavior is only at the extracted PolyData.<br>
<br>
my code:<br>
<br>
    // Setup ICP transform<br>
    vtkSmartPointer&lt;vtkIterativeClosestPointTransform&gt; icp =<br>
        vtkSmartPointer&lt;vtkIterativeClosestPointTransform&gt;::New();<br>
    icp-&gt;SetSource(target);<br>
    icp-&gt;SetTarget(target);<br>
    //icp-&gt;DebugOn();<br>
    //icp-&gt;StartByMatchingCentroidsOn();<br>
    icp-&gt;SetMaximumNumberOfIterations(29);<br>
    icp-&gt;SetMaximumNumberOfLandmarks(target-&gt;GetNumberOfPoints());<br>
    icp-&gt;SetCheckMeanDistance(1);<br>
    icp-&gt;SetMaximumMeanDistance(0.0000001);<br>
    icp-&gt;GetLandmarkTransform()-&gt;SetModeToRigidBody();<br>
    icp-&gt;Modified();<br>
    icp-&gt;Update();<br>
<br>
<br>
    // Get the resulting transformation matrix (this matrix takes the source<br>
points to the target points)<br>
    vtkSmartPointer&lt;vtkMatrix4x4&gt; m = icp-&gt;GetMatrix();<br>
    std::cout &lt;&lt; &quot;The resulting matrix is: &quot; &lt;&lt; *m &lt;&lt; std::endl;<br>
<br>
<br>
<br>
    // Transform the source points by the ICP solution<br>
    vtkSmartPointer&lt;vtkTransformPolyDataFilter&gt; icpTransformFilter =<br>
        vtkSmartPointer&lt;vtkTransformPolyDataFilter&gt;::New();<br>
#if VTK_MAJOR_VERSION &lt;= 5<br>
    icpTransformFilter-&gt;SetInput(target);<br>
#else<br>
    icpTransformFilter-&gt;SetInputData(target);<br>
#endif<br>
    icpTransformFilter-&gt;SetTransform( icp );<br>
    icpTransformFilter-&gt;Update();<br>
<br>
    /*<br>
    // If you need to take the target points to the source points, the<br>
matrix is:<br>
    icp-&gt;Inverse();<br>
    vtkSmartPointer&lt;vtkMatrix4x4&gt; minv = icp-&gt;GetMatrix();<br>
    std::cout &lt;&lt; &quot;The resulting inverse matrix is: &quot; &lt;&lt; *minv &lt;&lt; std::cout;<br>
    */<br>
    vtkSmartPointer&lt;vtkPolyData&gt; output =<br>
vtkSmartPointer&lt;vtkPolyData&gt;::New();<br>
    output = icpTransformFilter-&gt;GetOutput();<br>
    vtkSmartPointer&lt;vtkPolyDataWriter&gt; writer =<br>
vtkSmartPointer&lt;vtkPolyDataWriter&gt;::New();<br>
    writer-&gt;SetFileName( fileName );<br>
    writer-&gt;SetInput( output );<br>
    writer-&gt;Update();<br>
<br>
<br>
One more worth mentioned remark is that in the process of extracting the<br>
surface I get in the pipeline<br>
vtkUnstructuredGrid object that I later convert to PolyData..<br>
<br>
any thoughts?<br>
<br>
Thank you,<br>
Adva<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://vtk.1045678.n5.nabble.com/Iterative-Closest-Point-Transform-problem-tp5720040.html" target="_blank">http://vtk.1045678.n5.nabble.com/Iterative-Closest-Point-Transform-problem-tp5720040.html</a><br>

Sent from the VTK - Users mailing list archive at Nabble.com.<br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
</blockquote></div><br><br clear="all"><br>-- <br>Unpaid intern in BillsBasement at noware dot com<br>
</div>