int main( int argc, char * argv[] )
{
if( argc < 4 )
{
std::cerr << "Usage: " << std::endl;
std::cerr << argv[0] << " inputImageFile ";
std::cerr << " outputImageFileErosion outputImageFileDilation" << std::endl;
return EXIT_FAILURE;
}
const unsigned int Dimension = 2;
typedef unsigned char InputPixelType;
typedef unsigned char OutputPixelType;
InputPixelType,
Dimension > StructuringElementType;
InputImageType,
OutputImageType,
StructuringElementType > ErodeFilterType;
InputImageType,
OutputImageType,
StructuringElementType > DilateFilterType;
ReaderType::Pointer reader = ReaderType::New();
WriterType::Pointer writerDilation = WriterType::New();
WriterType::Pointer writerErosion = WriterType::New();
ErodeFilterType::Pointer grayscaleErode = ErodeFilterType::New();
DilateFilterType::Pointer grayscaleDilate = DilateFilterType::New();
StructuringElementType structuringElement;
structuringElement.SetRadius( 1 );
structuringElement.CreateStructuringElement();
grayscaleErode->SetKernel( structuringElement );
grayscaleDilate->SetKernel( structuringElement );
reader->SetFileName( argv[1] );
writerErosion->SetFileName( argv[2] );
writerDilation->SetFileName( argv[3] );
grayscaleErode->SetInput( reader->GetOutput() );
grayscaleDilate->SetInput( reader->GetOutput() );
writerDilation->SetInput( grayscaleDilate->GetOutput() );
writerDilation->Update();
writerErosion->SetInput( grayscaleErode->GetOutput() );
writerErosion->Update();
return EXIT_SUCCESS;
}