<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">HI Ramon,<div><br></div><div>A couple years ago or so, I contributed the following to the Insight Journal</div><div><br></div><div><a href="http://www.insight-journal.org/browse/publication/317">http://www.insight-journal.org/browse/publication/317</a></div><div><br></div><div>based on</div><div><br></div><div><a href="http://www.ncbi.nlm.nih.gov/pubmed/20937578">http://www.ncbi.nlm.nih.gov/pubmed/20937578</a></div><div><br></div><div>We used kd-trees to speed up the point search. &nbsp;You can see this in</div><div>the function where we use the kd-tree directory</div><div><br></div><div><a href="https://github.com/midas-journal/midas-journal-317/blob/master/Source/JHCT/itkManifoldParzenWindowsPointSetFunction.txx">https://github.com/midas-journal/midas-journal-317/blob/master/Source/JHCT/itkManifoldParzenWindowsPointSetFunction.txx</a></div><div><br></div><div>starting at line 63. &nbsp;Part of our ITKv4 registration refactoring included</div><div>this work so these functions are part of the current repository albeit</div><div>slightly modified and we ended up using the PointsLocator class</div><div><br></div><div>ITK/Modules/Registration/Metricsv4/include/itkManifoldParzenWindowsPointSetFunction.hxx</div><div><br></div><div>Nick</div><div><br></div><div><br></div><div><br><div><div>On Aug 9, 2013, at 8:23 AM, Ramón Casero Cañas &lt;<a href="mailto:rcasero@gmail.com">rcasero@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><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>&nbsp; &nbsp;Insight/Examples/Registration/</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; IterativeClosestPoint1.cxx</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; IterativeClosestPoint2.cxx</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 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">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">http://www.itk.org/Wiki/ITK/Examples/Statistics/KdTree</a><br></div><div><br></div><div>I found an "itkPointLocator2.h" class developed for&nbsp;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">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>&lt;CODE&gt;</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>&nbsp; // construct a Kd-tree structure for the reference point set, to</div><div>&nbsp; // accelerate the search for closest point</div>
<div>&nbsp; typedef itk::PointLocator2&lt;PointSetType&gt; PointLocatorType;</div><div>&nbsp; PointLocatorType::Pointer locator = PointLocatorType::New();</div><div><br></div><div>&nbsp; locator-&gt;SetPointSet(fixedPointSet);</div><div>
&nbsp; locator-&gt;Initialize(); // pre-compute the kd-tree structure</div></div><div>&lt;/CODE&gt;</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-&gt;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">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">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 &nbsp; &nbsp; +44 (0) 1865 610739<br>web &nbsp; &nbsp; <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 &nbsp;<a href="http://www.flickr.com/photos/rcasero/" target="_blank">http://www.flickr.com/photos/rcasero/</a>
</div></div>
_____________________________________<br>Powered by <a href="http://www.kitware.com">www.kitware.com</a><br><br>Visit other Kitware open-source projects at<br><a 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>http://www.kitware.com/products/protraining.php<br><br>Please keep messages on-topic and check the ITK FAQ at:<br>http://www.itk.org/Wiki/ITK_FAQ<br><br>Follow this link to subscribe/unsubscribe:<br>http://www.itk.org/mailman/listinfo/insight-users<br></blockquote></div><br></div></body></html>