[vtkusers] Binary Closing (and Dilate+Erode) have no effect

snrf at no-log.org snrf at no-log.org
Wed Sep 5 09:48:56 EDT 2007


Dear all:

For the last day I've been struggling to have a simple binary closing to
work:
I tried the binarymorphologicalclosing add-on extensions and a manual
Dilate + Erode approach (codes are below). Still, I do not have anything
on the output , the image is still like the one I input.

Any help, suggestions are appreciated.

Flo.

binarymorphologicalclosing
---------------------------

typedef itk::BinaryBallStructuringElement< PixelType2, Dimension2>
KernelType;
KernelType ball;
KernelType::SizeType ballSize;
ballSize.Fill( BallValue );
ball.SetRadius(ballSize);
ball.CreateStructuringElement();

typedef itk::SliceBySliceImageFilter< ImageType, ImageType > FilterType;
FilterType::Pointer filter = FilterType::New();

typedef itk::BinaryMorphologicalClosingImageFilter<
FilterType::InternalInputImageType,
FilterType::InternalOutputImageType, KernelType > Filter;
Filter::Pointer fil = Filter::New();

fil->SetKernel( ball );
fil->SetSafeBorder( true );
filter->SetInput( caster->GetOutput() );
filter->SetFilter( fil );

Dilate + Erode:
---------------

typedef itk::BinaryBallStructuringElement < PixelType, Dimension> KernelType;
KernelType ball;
KernelType::SizeType ballSize;
 ballSize.Fill( BallValue );
 ball.SetRadius(ballSize);
 ball.CreateStructuringElement();

typedef itk::BinaryErodeImageFilter<BinaryImageType3,
BinaryImageType3,KernelType >  ErodeFilterType;
typedef itk::BinaryDilateImageFilter<ImageType, BinaryImageType3,
KernelType >  DilateFilterType;

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

binaryDilate->SetKernel( ball );
binaryErode->SetKernel(  ball );
binaryDilate->SetInput( caster->GetOutput() );
binaryErode->SetInput( binaryDilate->GetOutput() );

PixelType background =   0;
PixelType foreground = 100;
binaryDilate->SetDilateValue( foreground );
binaryErode->SetErodeValue( foreground );
binaryErode->SetBoundaryToForeground(true);

binaryDilate->Update();
binaryErode->Update();



More information about the vtkusers mailing list