<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; ">Also, FYI, other point set metrics exist in the toolkit including<div><br></div><div><a href="https://github.com/Kitware/ITK/blob/master/Modules/Registration/Metricsv4/include/itkJensenHavrdaCharvatTsallisPointSetToPointSetMetricv4.h">https://github.com/Kitware/ITK/blob/master/Modules/Registration/Metricsv4/include/itkJensenHavrdaCharvatTsallisPointSetToPointSetMetricv4.h</a></div><div><a href="https://github.com/Kitware/ITK/blob/master/Modules/Registration/Metricsv4/include/itkExpectationBasedPointSetToPointSetMetricv4.h">https://github.com/Kitware/ITK/blob/master/Modules/Registration/Metricsv4/include/itkExpectationBasedPointSetToPointSetMetricv4.h</a><br><div><div><br></div><div>NIck</div><div><br><div><div>On Aug 9, 2013, at 1:06 PM, Ramón Casero Cañas &lt;rcasero@gmail.com&gt; wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr">Nope, I'm a fool.<div><br></div><div>itk::EuclideanDistancePointSetToPointSetMetricv4<br></div><div><br></div><div>has a line</div><div><br></div><div>PointIdentifier pointId = this-&gt;m_MovingTransformedPointsLocator-&gt;FindClosestPoint( point );<br>
</div><div><br></div><div><a href="https://github.com/Kitware/ITK/blob/master/Modules/Registration/Metricsv4/include/itkEuclideanDistancePointSetToPointSetMetricv4.hxx">https://github.com/Kitware/ITK/blob/master/Modules/Registration/Metricsv4/include/itkEuclideanDistancePointSetToPointSetMetricv4.hxx</a><br>
</div><div><br></div><div>I suppose this is an&nbsp;itk::PointsLocator: "This class accelerates the search for the closest point to a user-provided point, by using constructing a Kd-Tree structure for the PointSetContainer."</div>
<div><br></div><div><a href="http://www.itk.org/Doxygen/html/classitk_1_1PointsLocator.html">http://www.itk.org/Doxygen/html/classitk_1_1PointsLocator.html</a></div><div><br></div><div>So the functionality is already there, and I can just use the ITK class directly.</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 17:30, Ramón Casero Cañas <span dir="ltr">&lt;<a href="mailto:rcasero@gmail.com" target="_blank">rcasero@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Nick,<div><br></div><div>Thanks again. OK, so if I understand it correctly, your itk::ManifoldParzenWindowsPointSetFunction is an interpolator of a set of points. You used kd-trees to find nearest neighbours faster, but no metric class derived from&nbsp;<span style="font-size:13px;font-family:arial,sans-serif">itk::</span><span style="font-size:13px;font-family:arial,sans-serif">PointSetToPointSetRegistration</span><span style="font-size:13px;font-family:arial,sans-serif">Method was written.</span></div>

<div><span style="font-size:13px;font-family:arial,sans-serif"><br></span></div><div><span style="font-size:13px;font-family:arial,sans-serif">This is the class of metric that I need to pass to the registration algorithm.</span></div>

<div><span style="font-size:13px;font-family:arial,sans-serif"><br></span></div><div><span style="font-size:13px;font-family:arial,sans-serif">Basically, I think that the way forward for me is to rewrite&nbsp;</span><font face="arial, sans-serif">itk::EuclideanDistancePointMetric, but using a kd-tree instead of the distance map, and&nbsp;</font><span style="font-family:arial,sans-serif">PointLocator2 instead of sampling the distance map, if that makes any sense.</span></div>

<div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif">Best regards,</font></div><div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif">Ramon.</font></div>

<div><span style="font-size:13px;font-family:arial,sans-serif"><br></span></div><div><span style="font-size:13px;font-family:arial,sans-serif"><br></span></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra">
<br><br><div class="gmail_quote">
On 9 August 2013 16:36, Ramón Casero Cañas <span dir="ltr">&lt;<a href="mailto:rcasero@gmail.com" target="_blank">rcasero@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div dir="ltr">Hi Nick,<div><br></div><div>I hit send before receiving your reply. Many thanks, I'm starting to look into your pointers and will report back.</div><div><br></div><div><br>Best regards,</div><div><br></div>


<div>Ramon.</div></div><div><div class="gmail_extra"><br><br><div class="gmail_quote">On 9 August 2013 16:24, Nick Tustison <span dir="ltr">&lt;<a href="mailto:ntustison@gmail.com" target="_blank">ntustison@gmail.com</a>&gt;</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">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" target="_blank">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" target="_blank">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" target="_blank">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><span><font color="#888888"><div><br></div><div>Nick</div><div><br></div><div><br></div></font></span><div>


<br><div><div><div>On Aug 9, 2013, at 8:23 AM, Ramón Casero Cañas &lt;<a href="mailto:rcasero@gmail.com" target="_blank">rcasero@gmail.com</a>&gt; wrote:</div><br></div><blockquote type="cite"><div>
<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" 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&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" 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>&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" 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 &nbsp; &nbsp; <a href="tel:%2B44%20%280%29%201865%20610739" value="+441865610739" target="_blank">+44 (0) 1865 610739</a><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></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>


</div></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 &nbsp; &nbsp; <a href="tel:%2B44%20%280%29%201865%20610739" value="+441865610739" target="_blank">+44 (0) 1865 610739</a><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></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 &nbsp; &nbsp; <a href="tel:%2B44%20%280%29%201865%20610739" value="+441865610739" target="_blank">+44 (0) 1865 610739</a><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></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 &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>
</blockquote></div><br></div></div></div></body></html>