[Insight-users] Speed: Is this the right way?

Koen Vermeer koen at vermeer.tv
Tue Oct 28 10:49:53 EDT 2008


Hi,

I'm just doing some tests to see if ITK is feasible for my projects. As
one of the tests, I tried to do binary dilation of a 3D volume. The code
I use is shown below. Given that I'm new to ITK, I was wondering if this
is the right way to do the dilation. The speed is not bad, but I'd like
it to be faster.


typedef itk::Image<unsigned char,3> ImageType;

ImageType::Pointer BinaryDilate( ImageType::Pointer image )
{
   typedef unsigned char PixelType;
   typedef itk::BinaryBallStructuringElement< PixelType, 3 > SEType;
   typedef itk::BinaryDilateImageFilter< ImageType, ImageType, SEType >
DilateFilterType;

   DilateFilterType::Pointer binaryDilate = DilateFilterType::New();

   SEType sE;
   sE.SetRadius( 2 );
   sE.CreateStructuringElement();
   binaryDilate->SetKernel( sE );

   binaryDilate->SetInput( image );
   binaryDilate->SetDilateValue( 1 );

   ImageType::Pointer imout = binaryDilate->GetOutput();
   imout->Update();
   return imout;
}


Thanks for any comments!

Best,
Koen




More information about the Insight-users mailing list