int main( int argc, char * argv[] )
{
if( argc < 5 )
{
std::cerr << "Usage: " << std::endl;
std::cerr << argv[0] << " inputImageFile outputImageFile radiusX radiusY iterations" << std::endl;
return EXIT_FAILURE;
}
typedef unsigned char PixelType;
ReaderType::Pointer reader = ReaderType::New();
WriterType::Pointer writer = WriterType::New();
reader->SetFileName( argv[1] );
writer->SetFileName( argv[2] );
ImageType > FilterType;
FilterType::Pointer filter = FilterType::New();
const unsigned int radiusX = atoi( argv[3] );
const unsigned int radiusY = atoi( argv[4] );
ImageType::SizeType indexRadius;
indexRadius[0] = radiusX;
indexRadius[1] = radiusY;
filter->SetRadius( indexRadius );
filter->SetBackgroundValue( 0 );
filter->SetForegroundValue( 255 );
filter->SetMajorityThreshold( 2 );
const unsigned int numberOfIterations = atoi( argv[5] );
filter->SetMaximumNumberOfIterations( numberOfIterations );
filter->SetInput( reader->GetOutput() );
writer->SetInput( filter->GetOutput() );
writer->Update();
const unsigned int iterationsUsed = filter->GetCurrentNumberOfIterations();
std::cout << "The filter used " << iterationsUsed << " iterations " << std::endl;
const unsigned int numberOfPixelsChanged = filter->GetNumberOfPixelsChanged();
std::cout << "and changed a total of " << numberOfPixelsChanged << " pixels" << std::endl;
return EXIT_SUCCESS;
}