<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">Hello itkusers</span><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
<br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">I&#39;ve having some performance issues related with the calculation of distance maps through ITK&#39;s SignedMaurerDistanceMapImageFilter.</div>
<div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)"><br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
My execution times were a bit high so I&#39;ve setup  the following test:</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)"><br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
a 512x512x110 binary image</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)"><br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
Matlab&#39;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-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)"><br></div>
<div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">Matlab Code:</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
<br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)"><font face="courier new, monospace">tic, d1 = bwdist(i); toc</font></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
<font face="courier new, monospace">Elapsed time is 2.415929 seconds.</font></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)"><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 &quot;half&quot; 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&#39;s 5 seconds</div><div><br></div><div>However, my code runs in 15 seconds, (13 if I enable 2 threads into SignedMaurer). I&#39;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 &lt;seg::ITKImgLabelType, F1d3ITKImgType&gt; DistanceMapper;</font></div>
<div><font face="courier new, monospace">DistanceMapper::Pointer distanceMapper = DistanceMapper::New();</font></div><div><font face="courier new, monospace">distanceMapper-&gt;ReleaseDataFlagOn();</font></div><div><font face="courier new, monospace">distanceMapper-&gt;SetUseImageSpacing(true);</font></div>
<div><font face="courier new, monospace">distanceMapper-&gt;SetSquaredDistance(false);</font></div><div><font face="courier new, monospace">distanceMapper-&gt;SetInsideIsPositive(false);<span style="white-space:pre-wrap">        </span></font></div>
<div><font face="courier new, monospace">distanceMapper-&gt;SetInput(&amp;a_segmentedImgIn);</font></div><div><font face="courier new, monospace">distanceMapper-&gt;SetNumberOfThreads(2);</font></div><div><font face="courier new, monospace">distanceMapper-&gt;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&#39;ve included the image that I use to benchmark the filter... It is strange that I&#39;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><div><br></div>-- <br>Sergio Vera<br><br> Alma IT Systems<br> C/ Vilana, 4B, 4º 1ª<br> 08022 Barcelona<br> T. (+34) 932 380 592<br> <a href="http://www.alma3d.com">www.alma3d.com</a><br>