Make sure your ITK is built with Release and not Debug.<br><br><div class="gmail_quote">On Mon, Jul 2, 2012 at 5:55 AM, Sergio Vera <span dir="ltr"><<a href="mailto:sergio.vera@alma3d.com" target="_blank">sergio.vera@alma3d.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">Hello itkusers</span><div style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">
<br></div><div style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">I've having some performance issues related with the calculation of distance maps through ITK's SignedMaurerDistanceMapImageFilter.</div>
<div style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif"><br></div><div style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">
My execution times were a bit high so I've setup the following test:</div><div style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif"><br></div><div style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">
a 512x512x110 binary image</div><div style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif"><br></div><div style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">
Matlab's bwdist (uses Maurer method, but does not generates a signed map) is the fastest one.</div><div style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif"><br></div>
<div style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">Matlab Code:</div><div style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">
<br></div><div style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif"><font face="courier new, monospace">tic, d1 = bwdist(i); toc</font></div><div style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">
<font face="courier new, monospace">Elapsed time is 2.415929 seconds.</font></div><div style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif"><div><font face="courier new, monospace">tic, d2 = bwdist(~i); toc</font></div>
<div><font face="courier new, monospace">Elapsed time is 2.509455 seconds.</font></div><div><br></div><div>The dmap is computed for the image and the negated image, to compensate that bwdist does only "half" of the distance map. Total time is about 5 seconds.</div>
<div><br></div><div>Now, I load the same image in Mevislab Using ITK filters and compute the signedMaurer distance with this pipeline:</div><div><br></div><div><img src="cid:ii_1382d587b5d72197" alt="Inline image 1"></div>
<div><br></div><div>Mevislab Reports execution times in the range of 6.4 to 7.2 seconds which is comparable to Matlab's 5 seconds</div><div><br></div><div>However, my code runs in 15 seconds, (13 if I enable 2 threads into SignedMaurer). I've checked that I use Release version of ITK (3.20)</div>
<div><br></div><div>C++ Code:</div><div><div><font face="courier new, monospace">itk::TimeProbe timer;</font></div><div><font face="courier new, monospace">timer.Start();</font></div><div><font face="courier new, monospace">typedef itk::SignedMaurerDistanceMapImageFilter <seg::ITKImgLabelType, F1d3ITKImgType> DistanceMapper;</font></div>
<div><font face="courier new, monospace">DistanceMapper::Pointer distanceMapper = DistanceMapper::New();</font></div><div><font face="courier new, monospace">distanceMapper->ReleaseDataFlagOn();</font></div><div><font face="courier new, monospace">distanceMapper->SetUseImageSpacing(true);</font></div>
<div><font face="courier new, monospace">distanceMapper->SetSquaredDistance(false);</font></div><div><font face="courier new, monospace">distanceMapper->SetInsideIsPositive(false);<span style="white-space:pre-wrap">        </span></font></div>
<div><font face="courier new, monospace">distanceMapper->SetInput(&a_segmentedImgIn);</font></div><div><font face="courier new, monospace">distanceMapper->SetNumberOfThreads(2);</font></div><div><font face="courier new, monospace">distanceMapper->Update();</font></div>
<div><font face="courier new, monospace">timer.Stop();</font></div><div><font face="courier new, monospace">SpyITK::OutputTimeToComplete(std::cout, __FUNCTION__, timer);</font></div></div><div><br></div><div>The image is already readed. </div>
<div><br></div><div>I've included the image that I use to benchmark the filter... It is strange that I'm having such a different result between Mevislab and my Own ITK code. The setup of the filter is similar (the only activated flag is the UseImageSpacingFlag).</div>
<div><br></div><div>Perhaps is some flag that has to be used when compiling ITK? Any further tips on how to speed the distance map calculation?</div><div><br></div><div>I can provide the file to used to test the performance if needed.</div>
<div><br></div><div>Thanks in advance</div></div><span class="HOEnZb"><font color="#888888"><div><br></div>-- <br>Sergio Vera<br><br> Alma IT Systems<br> C/ Vilana, 4B, 4º 1ª<br> 08022 Barcelona<br> T. <a href="tel:%28%2B34%29%20932%20380%20592" value="+34932380592" target="_blank">(+34) 932 380 592</a><br>
<a href="http://www.alma3d.com" target="_blank">www.alma3d.com</a><br>
</font></span><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<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>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br>Unpaid intern in BillsBasement at noware dot com<br><br>