Hi 
<span style="font-family:arial,sans-serif;text-align:left;white-space:nowrap;background-color:rgb(255,255,255)">Dženan and Bradley,</span><div><div style="text-align:left"><font face="arial, sans-serif"><span style="white-space:nowrap"><br>
</span></font></div><div style="text-align:left"><font face="arial, sans-serif"><span style="white-space:nowrap">I use Control+F5 normally. and it&#39;s a Professional version of Visual Studio 9 (2008)</span></font></div>
<div style="text-align:left"><font face="arial, sans-serif"><span style="white-space:nowrap"><br></span></font></div><div style="text-align:left"><font face="arial, sans-serif"><span style="white-space:nowrap">I&#39;ve made a minimum test scenario to remove any possible interferences from other libraries/dependencies. This one only links against ITK, and still times are arrount 13-14 segs. </span></font></div>
<div style="text-align:left"><font face="arial, sans-serif"><span style="white-space:nowrap">By the way switching to ITK 4.0 did not improve my numbers :(</span></font></div><div style="text-align:left"><font face="arial, sans-serif"><span style="white-space:nowrap"><div>
<br></div><div>cmake_minimum_required(VERSION 2.6)</div><div>project(dmap)</div><div>find_package(ITK REQUIRED)</div><div>include(${ITK_USE_FILE})</div><div>add_executable(dmap main.cxx)</div><div>target_link_libraries(dmap  ${ITK_LIBRARIES})</div>
</span></font></div><div style="text-align:left"><font face="arial, sans-serif"><span style="white-space:nowrap"><br></span></font></div><table cellpadding="0" class="cf an5" id=":2ct" style="border-collapse:collapse;outline:none;overflow:hidden;table-layout:fixed;width:202px;color:rgb(34,34,34);font-family:arial,sans-serif;background-color:rgb(255,255,255)">
<tbody><tr><td class="anQ" style="margin:0px;font-family:arial,sans-serif;overflow:hidden;text-align:left;text-overflow:ellipsis;white-space:nowrap;vertical-align:top"><span style="background-color:transparent">#include &lt;itkTimeProbe.h&gt;</span></td>
</tr></tbody></table><div>#include &lt;itkImage.h&gt;</div><div>#include &lt;itkImageFileReader.h&gt;</div><div>#include &lt;itkSignedMaurerDistanceMapImageFilter.h&gt;</div><div><br></div><div>int main(int argc, char *argv[])</div>
<div>{</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>typedef itk::Image&lt;unsigned char,3&gt; ITKImg;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>typedef itk::ImageFileReader&lt;ITKImg&gt; Reader;</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>Reader::Pointer reader = Reader::New();</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>reader-&gt;SetFileName(&quot;C:/Users/sergio.vera/Documents/MATLAB/images/CTAbdomenThr1800.mha&quot;);</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>reader-&gt;Update();</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>std::cout &lt;&lt; &quot;Image readed!\n &quot;;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>itk::TimeProbe timer;</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>timer.Start();</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>typedef itk::SignedMaurerDistanceMapImageFilter &lt;ITKImg, ITKImg&gt; DistanceMapper;</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>DistanceMapper::Pointer distanceMapper = DistanceMapper::New();</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>distanceMapper-&gt;SetUseImageSpacing(true);</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>distanceMapper-&gt;SetSquaredDistance(false);</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>distanceMapper-&gt;SetInsideIsPositive(false);<span class="Apple-tab-span" style="white-space:pre">        </span></div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>distanceMapper-&gt;SetInput(reader-&gt;GetOutput());</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>distanceMapper-&gt;SetNumberOfThreads(2);</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>distanceMapper-&gt;Update();</div><div><span class="Apple-tab-span" style="white-space:pre">        </span></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>timer.Stop();</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>std::cout &lt;&lt; &quot;Time Spent: &quot; &lt;&lt; timer.GetMeanTime() &lt;&lt; &quot;\n&quot;;</div><div>  return EXIT_SUCCESS;</div><div>}</div><br><br>
<div class="gmail_quote">On Mon, Jul 2, 2012 at 6:02 PM, Bradley Lowekamp <span dir="ltr">&lt;<a href="mailto:blowekamp@mail.nih.gov" target="_blank">blowekamp@mail.nih.gov</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">Would you by any chance be using an express Visual Studio version? Those compiler are missing a fair amount of optimization. I have not compared the difference myself though.<div><br></div>
<div>Brad</div><div><br><div><div><div class="h5"><div><div>On Jul 2, 2012, at 11:38 AM, Sergio Vera wrote:</div><br><blockquote type="cite">Hello Bradley<div><br></div><div>Thanks for your script</div><div><br></div><div>
I&#39;ve tried your script and the timings are coherent with yours (although my desktop is slower than your laptop :) )</div>
<div><br></div><div><div>The average time it took to execute SignedMaurerDistanceMap was 5.3353600223 seconds. </div><div>The average time it took to execute SignedMaurerDistanceMap was 6.62535580948 seconds. </div><div>


The average time it took to execute SignedMaurerDistanceMap was 6.90300935124 seconds. </div>
<div><br></div><div>I&#39;ve modified it to read my image (it&#39;s only 300k but it seems too big for the list) and the results are definitely lower than 13 seconds, closer to the 7 seconds from Mevislab&#39;s ITK....</div>


<div><br></div><div><div>The average time it took to execute SignedMaurerDistanceMap was 8.87152283895 seconds. </div><div>The average time it took to execute SignedMaurerDistanceMap was 9.38857726434 seconds. </div><div>


The average time it took to execute SignedMaurerDistanceMap was 9.54250972999 seconds. </div></div><div><br></div><div>Indeed it is strange that my code runs slower :( My executable being compiled in release mode, compiler flags are /02 and Visual studio is clearly put in release. Also, when I launch the debug version the distance map time is 114 seconds. However I&#39;m not sure why it tools so long to compute the distance map..</div>

<div><br></div><div>Thanks</div>
<br><div class="gmail_quote">On Mon, Jul 2, 2012 at 4:07 PM, Bradley Lowekamp <span dir="ltr">&lt;<a href="mailto:blowekamp@mail.nih.gov" target="_blank">blowekamp@mail.nih.gov</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div>Hello Sergio,<br>
<br>
But are you compiling your program also in release mode? The filter is not part of the ITK code in the library, because it is a templated filter, it will be compiled in your application, so that is where it matters if you are in Release or debug mode.<br>




<br>
I wrote the following little SimpleITK python script, which uses the latest ITK 4.2rc04:<br>
<br>
import SimpleITK as sitk<br>
import os<br>
from timeit import Timer<br>
<br>
repeat = 10<br>
<br>
img = sitk.Image( [512,512,110], sitk.sitkUInt8 )<br>
img[255,255,55 ] = 1<br>
<br>
filter = sitk.SignedMaurerDistanceMapImageFilter()<br>
<br>
print &quot;Defaults:&quot;<br>
print filter<br>
<br>
t = Timer( lambda: filter.Execute( img ) )<br>
<br>
print &quot;The average time it took to execute&quot;, filter.GetName(), &quot;was&quot;,  min(t.repeat( repeat=repeat,number=1 )), &quot;seconds. &quot;<br>
<br>
filter.InsideIsPositiveOff()<br>
filter.SquaredDistanceOff()<br>
filter.UseImageSpacingOn();<br>
<br>
t = Timer( lambda: filter.Execute( img ) )<br>
<br>
print &quot;The average time it took to execute&quot;, filter.GetName(), &quot;was&quot;,  min(t.repeat( repeat=repeat,number=1 )), &quot;seconds. &quot;<br>
<br>
t = Timer( lambda: filter.Execute( ~img ) )<br>
<br>
print &quot;The average time it took to execute&quot;, filter.GetName(), &quot;was&quot;,  min(t.repeat( repeat=repeat,number=1 )), &quot;seconds. &quot;<br>
<br>
Your large image didn&#39;t come attached, so I just created a trivial on to run performance. This is my results in my i7 laptop:<br>
<br>
Defaults:<br>
itk::simple::SignedMaurerDistanceMapImageFilter<br>
  InsideIsPositive: 0<br>
  SquaredDistance: 1<br>
  UseImageSpacing: 0<br>
<br>
The average time it took to execute SignedMaurerDistanceMap was 2.05940294266 seconds.<br>
The average time it took to execute SignedMaurerDistanceMap was 2.61217999458 seconds.<br>
The average time it took to execute SignedMaurerDistanceMap was 2.7291328907 seconds.<br>
<br>
<br>
As I was running this multiple times, I appear to be getting a variation of ~.5 seconds due to what I am assuming is the temperature of my CPU, and intel&#39;s TuboBoost.<br>
<br>
Additionally, it&#39;s not clear which timings are using only one thread and which are using more. So I also ran the test with only one thread:<br>
<br>
The average time it took to execute SignedMaurerDistanceMap was 8.77108097076 seconds.<br>
The average time it took to execute SignedMaurerDistanceMap was 9.40146708488 seconds.<br>
The average time it took to execute SignedMaurerDistanceMap was 9.63690400124 seconds.<br>
<br>
I tend to agree with Bill, there is something funny about how you compiled it.<br>
<br>
Brad<br>
<br>
</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></div></blockquote></div><br><br clear="all"><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>

</div>
</blockquote></div><br></div></div><div>
<span style="text-indent:0px;letter-spacing:normal;font-variant:normal;text-align:-webkit-auto;font-style:normal;font-weight:normal;line-height:normal;border-collapse:separate;text-transform:none;font-size:medium;white-space:normal;font-family:Helvetica;word-spacing:0px"><span style="text-indent:0px;letter-spacing:normal;font-variant:normal;font-style:normal;font-weight:normal;line-height:normal;border-collapse:separate;text-transform:none;font-size:12px;white-space:normal;font-family:Helvetica;word-spacing:0px"><div style="word-wrap:break-word">
<span style="text-indent:0px;letter-spacing:normal;font-variant:normal;font-style:normal;font-weight:normal;line-height:normal;border-collapse:separate;text-transform:none;font-size:12px;white-space:normal;font-family:Helvetica;word-spacing:0px"><p style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">
<font face="Helvetica" size="3" style="font:normal normal normal 12px/normal Helvetica">========================================================</font></p><p style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">
<font face="Helvetica" size="3" style="font:normal normal normal 12px/normal Helvetica">Bradley Lowekamp<span> </span><span> </span></font></p><p style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px"><font face="Helvetica" size="3" style="font:normal normal normal 12px/normal Helvetica">Medical Science and Computing for</font></p>
<p style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px"><font face="Helvetica" size="3" style="font:normal normal normal 12px/normal Helvetica">Office of High Performance Computing and Communications</font></p>
<p style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px"><font face="Helvetica" size="3" style="font:normal normal normal 12px/normal Helvetica">National Library of Medicine<span> </span></font></p><p style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">
<font face="Helvetica" size="3" style="font:normal normal normal 12px/normal Helvetica"><a href="mailto:blowekamp@mail.nih.gov" target="_blank">blowekamp@mail.nih.gov</a></font></p><br></span></div></span></span><br>
</div>
<br></div></div></div></blockquote></div><br><br clear="all"><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>

</div>