<div dir="ltr"><div><div>Before the icp, can you:<br></div>target->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"><<a href="mailto:adva.zair@mail.huji.ac.il" target="_blank">adva.zair@mail.huji.ac.il</a>></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'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'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<vtkIterativeClosestPointTransform> icp =<br>
vtkSmartPointer<vtkIterativeClosestPointTransform>::New();<br>
icp->SetSource(target);<br>
icp->SetTarget(target);<br>
//icp->DebugOn();<br>
//icp->StartByMatchingCentroidsOn();<br>
icp->SetMaximumNumberOfIterations(29);<br>
icp->SetMaximumNumberOfLandmarks(target->GetNumberOfPoints());<br>
icp->SetCheckMeanDistance(1);<br>
icp->SetMaximumMeanDistance(0.0000001);<br>
icp->GetLandmarkTransform()->SetModeToRigidBody();<br>
icp->Modified();<br>
icp->Update();<br>
<br>
<br>
// Get the resulting transformation matrix (this matrix takes the source<br>
points to the target points)<br>
vtkSmartPointer<vtkMatrix4x4> m = icp->GetMatrix();<br>
std::cout << "The resulting matrix is: " << *m << std::endl;<br>
<br>
<br>
<br>
// Transform the source points by the ICP solution<br>
vtkSmartPointer<vtkTransformPolyDataFilter> icpTransformFilter =<br>
vtkSmartPointer<vtkTransformPolyDataFilter>::New();<br>
#if VTK_MAJOR_VERSION <= 5<br>
icpTransformFilter->SetInput(target);<br>
#else<br>
icpTransformFilter->SetInputData(target);<br>
#endif<br>
icpTransformFilter->SetTransform( icp );<br>
icpTransformFilter->Update();<br>
<br>
/*<br>
// If you need to take the target points to the source points, the<br>
matrix is:<br>
icp->Inverse();<br>
vtkSmartPointer<vtkMatrix4x4> minv = icp->GetMatrix();<br>
std::cout << "The resulting inverse matrix is: " << *minv << std::cout;<br>
*/<br>
vtkSmartPointer<vtkPolyData> output =<br>
vtkSmartPointer<vtkPolyData>::New();<br>
output = icpTransformFilter->GetOutput();<br>
vtkSmartPointer<vtkPolyDataWriter> writer =<br>
vtkSmartPointer<vtkPolyDataWriter>::New();<br>
writer->SetFileName( fileName );<br>
writer->SetInput( output );<br>
writer->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>