[Insight-users] SignedMaurerDistanceMapImageFilter performance

Bradley Lowekamp blowekamp at mail.nih.gov
Mon Jul 2 10:07:18 EDT 2012


Hello Sergio,

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.

I wrote the following little SimpleITK python script, which uses the latest ITK 4.2rc04:

import SimpleITK as sitk
import os
from timeit import Timer

repeat = 10

img = sitk.Image( [512,512,110], sitk.sitkUInt8 )
img[255,255,55 ] = 1

filter = sitk.SignedMaurerDistanceMapImageFilter()

print "Defaults:"
print filter

t = Timer( lambda: filter.Execute( img ) )

print "The average time it took to execute", filter.GetName(), "was",  min(t.repeat( repeat=repeat,number=1 )), "seconds. "

filter.InsideIsPositiveOff()
filter.SquaredDistanceOff()
filter.UseImageSpacingOn();

t = Timer( lambda: filter.Execute( img ) )

print "The average time it took to execute", filter.GetName(), "was",  min(t.repeat( repeat=repeat,number=1 )), "seconds. "

t = Timer( lambda: filter.Execute( ~img ) )

print "The average time it took to execute", filter.GetName(), "was",  min(t.repeat( repeat=repeat,number=1 )), "seconds. "

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:

Defaults:
itk::simple::SignedMaurerDistanceMapImageFilter
  InsideIsPositive: 0
  SquaredDistance: 1
  UseImageSpacing: 0

The average time it took to execute SignedMaurerDistanceMap was 2.05940294266 seconds. 
The average time it took to execute SignedMaurerDistanceMap was 2.61217999458 seconds. 
The average time it took to execute SignedMaurerDistanceMap was 2.7291328907 seconds. 


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.

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:

The average time it took to execute SignedMaurerDistanceMap was 8.77108097076 seconds. 
The average time it took to execute SignedMaurerDistanceMap was 9.40146708488 seconds. 
The average time it took to execute SignedMaurerDistanceMap was 9.63690400124 seconds. 

I tend to agree with Bill, there is something funny about how you compiled it.

Brad
 


More information about the Insight-users mailing list