<div dir="ltr">Thanks, Brad. Checking the snippet about the metric in your example, and the error messages I get, I think there's a problem in that distance metrics in kd-trees are different from PointSetToPointSetMetrics.<div>
<br></div><div>The kd-tree provides an</div><div><br></div><div>itk::Statistics::EuclideanDistanceMetric<TVector></div><div><br></div><div><a href="http://www.itk.org/Doxygen/html/classitk_1_1Statistics_1_1EuclideanDistanceMetric.html">http://www.itk.org/Doxygen/html/classitk_1_1Statistics_1_1EuclideanDistanceMetric.html</a><br>
</div><div><br></div><div>while the registration algorithm requires an</div><div><br></div><div>itk::PointSetToPointSetMetric<TFixedPointSet, TMovingPointSet></div><div>^</div><div>|</div><div>itk::EuclideanDistancePointMetric<TFixedPointSet, TMovingPointSet></div>
<div><br></div><div><a href="http://www.itk.org/Doxygen/html/classitk_1_1PointSetToPointSetMetric.html">http://www.itk.org/Doxygen/html/classitk_1_1PointSetToPointSetMetric.html</a><br></div><div><br></div><div>Thus, this approach will not compile because of type mismatch</div>
<div><br></div><div><WRONG></div><div><div> typedef itk::PointSetToPointSetRegistrationMethod<PointSetType, </div><div><span class="" style="white-space:pre">                                                </span> PointSetType> RegistrationType;</div>
<div><br></div><div> RegistrationType::Pointer registration = RegistrationType::New();</div><div> </div></div><div><div> TreeType *tree = const_cast<TreeType *>(locator->GetKdTree().GetPointer());</div><div> </div>
<div> registration->SetMetric(tree->GetDistanceMetric()); </div></div><div><div></WRONG></div><div></div></div><div><br></div><div><br></div><div>Does anybody have any ideas on how to approach using itk::KdTree to generate the metric of a point-to-point registration algorithm?</div>
<div><br></div><div>Best regards,</div><div><br></div><div>Ramon.</div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On 9 August 2013 13:32, Bradley Lowekamp <span dir="ltr"><<a href="mailto:blowekamp@mail.nih.gov" target="_blank">blowekamp@mail.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 style="word-wrap:break-word">Hello,<div><br></div><div>I am not too familiar with this KDTree. But I recently added some indexing of the ITK Example in the doxygen, which includes cross linking between the examples and the class.</div>
<div><br></div><div>The KdTreeGenerator:</div><div><br></div><div><a href="http://www.itk.org/Doxygen/html/classitk_1_1Statistics_1_1KdTreeGenerator.html" target="_blank">http://www.itk.org/Doxygen/html/classitk_1_1Statistics_1_1KdTreeGenerator.html</a></div>
<div><br></div><div>is used in the KdTree example:</div><div><br></div><div><a href="http://www.itk.org/Doxygen/html/Statistics_2KdTree_8cxx-example.html" target="_blank">http://www.itk.org/Doxygen/html/Statistics_2KdTree_8cxx-example.html</a></div>
<div><br></div><div>I hope this gives you some additional insights.</div><div><br></div><div>Brad</div><div><br><div><div><div class="h5"><div>On Aug 9, 2013, at 8:23 AM, Ramón Casero Cañas <<a href="mailto:rcasero@gmail.com" target="_blank">rcasero@gmail.com</a>> wrote:</div>
<br></div></div><blockquote type="cite"><div><div class="h5"><div dir="ltr">Dear all,<div><br></div><div>I'm trying to build an Iterative Closest Point algorithm with ITK.</div><div><br></div><div>I have googled advice on how it can be put together generally, and checked the three examples</div>
<div><br></div><div><div> Insight/Examples/Registration/</div><div> IterativeClosestPoint1.cxx</div><div> IterativeClosestPoint2.cxx</div><div> IterativeClosestPoint3.cxx</div></div>
<div><br></div><div>recommended here<br></div><div><br></div><div><a href="http://www.itk.org/pipermail/insight-users/2004-June/009092.html" target="_blank">http://www.itk.org/pipermail/insight-users/2004-June/009092.html</a><br>
</div><div>
<br></div><div>These examples don't use kd-trees (the last ones uses a distance transform).</div><div><br></div><div><div>I have also found an example of a kd-tree, that however doesn't use point sets</div><div><br>
</div><div><a href="http://www.itk.org/Wiki/ITK/Examples/Statistics/KdTree" target="_blank">http://www.itk.org/Wiki/ITK/Examples/Statistics/KdTree</a><br></div><div><br></div><div>I found an "itkPointLocator2.h" class developed for itkQuadEdgeMeshRigidRegistration in the ITK journal. I downloaded it from a more up-to-date publication that makes use of it, "Mesh Similarity Calculator" by Li and Magnotta (2010)</div>
<div><br></div><div><a href="http://www.insight-journal.org/browse/publication/762" target="_blank">http://www.insight-journal.org/browse/publication/762</a><br></div><div><br></div><div>What I don't know is how to extract a metric from said locator, to pass it to the registration object.</div>
<div><br></div><div>This is the relevant part of the code I have so far</div><div><br></div><div><CODE></div><div>PointSetType::Pointer fixedPointSet = PointSetType::New();<br></div><div>PointSetType::Pointer movingPointSet = PointSetType::New();<br>
</div><div><br></div><div>// do something to read the points into the point sets</div><div><br></div><div><div> // construct a Kd-tree structure for the reference point set, to</div><div> // accelerate the search for closest point</div>
<div> typedef itk::PointLocator2<PointSetType> PointLocatorType;</div><div> PointLocatorType::Pointer locator = PointLocatorType::New();</div><div><br></div><div> locator->SetPointSet(fixedPointSet);</div><div>
locator->Initialize(); // pre-compute the kd-tree structure</div></div><div></CODE></div><div><br></div><div>I think I could get the metric from the kd-tree with something like</div><div><br></div><div>
tree->GetDistanceMetric()</div><div><br></div><div>but I cannot get the tree from the locator, can I?</div><div><br></div><div><a href="https://github.com/midas-journal/midas-journal-762/blob/master/QuadEdgeMeshRigidRegistration/Source/itkPointLocator2.h" target="_blank">https://github.com/midas-journal/midas-journal-762/blob/master/QuadEdgeMeshRigidRegistration/Source/itkPointLocator2.h</a><br>
</div><div><br></div><div>Is this just a matter of adding a GetKdTree() method to itkPointLocator2.h, or is there some better solution to this?</div><div><br></div><div><br></div><div><br></div><div>Alternatively, if we not only have point sets at the input, but triangular meshes, it would be possible to compute shortest distances from the vertices of movingPointSet to a triangular mesh fixedTriMesh. This is efficient using an AABB tree (which can internally use a kd-tree), as in the CGAL library</div>
<div><br></div><div><a href="http://www.cgal.org/Manual/latest/doc_html/cgal_manual/AABB_tree/Chapter_main.html" target="_blank">http://www.cgal.org/Manual/latest/doc_html/cgal_manual/AABB_tree/Chapter_main.html</a><br></div>
<div><br></div>
<div>but this probably requires a vast amount of work? Or would it be relatively easy to write a new metric PointToTriMesh for ITK that imports CGAL AABB trees? I'm asking because I have no idea of how involved writing a new Metric class would be.</div>
<div><br></div><div><br></div><div>Best regards,</div><div><br></div><div>Ramon.</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><br clear="all"><div><br></div>-- <br>Dr. Ramón Casero Cañas<br>
<br>Oxford e-Research Centre (OeRC)<br>University of Oxford<br>7 Keble Rd<br>Oxford OX1 3QG<br><br>tlf <a href="tel:%2B44%20%280%29%201865%20610739" value="+441865610739" target="_blank">+44 (0) 1865 610739</a><br>web <a href="http://www.cs.ox.ac.uk/people/Ramon.CaseroCanas" target="_blank">http://www.cs.ox.ac.uk/people/Ramon.CaseroCanas</a><br>
photos <a href="http://www.flickr.com/photos/rcasero/" target="_blank">http://www.flickr.com/photos/rcasero/</a>
</div></div></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>
</blockquote></div><br></div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>Dr. Ramón Casero Cañas<br><br>Oxford e-Research Centre (OeRC)<br>University of Oxford<br>7 Keble Rd<br>Oxford OX1 3QG<br><br>
tlf +44 (0) 1865 610739<br>web <a href="http://www.cs.ox.ac.uk/people/Ramon.CaseroCanas" target="_blank">http://www.cs.ox.ac.uk/people/Ramon.CaseroCanas</a><br>photos <a href="http://www.flickr.com/photos/rcasero/" target="_blank">http://www.flickr.com/photos/rcasero/</a>
</div>