<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">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>On Jul 2, 2012, at 11:38 AM, Sergio Vera wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">Hello Bradley<div><br></div><div>Thanks for your script</div><div><br></div><div>I'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've modified it to read my image (it'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'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'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"><<a href="mailto:blowekamp@mail.nih.gov" target="_blank">blowekamp@mail.nih.gov</a>></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 "Defaults:"<br>
print filter<br>
<br>
t = Timer( lambda: filter.Execute( img ) )<br>
<br>
print "The average time it took to execute", filter.GetName(), "was", min(t.repeat( repeat=repeat,number=1 )), "seconds. "<br>
<br>
filter.InsideIsPositiveOff()<br>
filter.SquaredDistanceOff()<br>
filter.UseImageSpacingOn();<br>
<br>
t = Timer( lambda: filter.Execute( img ) )<br>
<br>
print "The average time it took to execute", filter.GetName(), "was", min(t.repeat( repeat=repeat,number=1 )), "seconds. "<br>
<br>
t = Timer( lambda: filter.Execute( ~img ) )<br>
<br>
print "The average time it took to execute", filter.GetName(), "was", min(t.repeat( repeat=repeat,number=1 )), "seconds. "<br>
<br>
Your large image didn'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's TuboBoost.<br>
<br>
Additionally, it'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>
<span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; 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 class="Apple-converted-space"> </span><span class="Apple-converted-space"> </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 class="Apple-converted-space"> </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">blowekamp@mail.nih.gov</a></font></p><br class="Apple-interchange-newline"></span></div></span></span><br class="Apple-interchange-newline">
</div>
<br></div></div></body></html>