int main( int argc, char *argv[] )
{
if( argc < 7 )
{
std::cerr << "Missing Parameters." << std::endl;
std::cerr << "Usage: " << argv[0]
<< " inputImage outputImage"
<< " seedX seedY"
<< " lowerThreshold upperThreshold" << std::endl;
return EXIT_FAILURE;
}
typedef float InternalPixelType;
const unsigned int Dimension = 2;
typedef unsigned char OutputPixelType;
CastingFilterType;
CastingFilterType::Pointer caster = CastingFilterType::New();
ReaderType::Pointer reader = ReaderType::New();
WriterType::Pointer writer = WriterType::New();
reader->SetFileName( argv[1] );
writer->SetFileName( argv[2] );
CurvatureFlowImageFilterType;
CurvatureFlowImageFilterType::Pointer smoothing =
CurvatureFlowImageFilterType::New();
InternalImageType > ConnectedFilterType;
ConnectedFilterType::Pointer neighborhoodConnected
= ConnectedFilterType::New();
smoothing->SetInput( reader->GetOutput() );
neighborhoodConnected->SetInput( smoothing->GetOutput() );
caster->SetInput( neighborhoodConnected->GetOutput() );
writer->SetInput( caster->GetOutput() );
smoothing->SetNumberOfIterations( 5 );
smoothing->SetTimeStep( 0.125 );
const InternalPixelType lowerThreshold = atof( argv[5] );
const InternalPixelType upperThreshold = atof( argv[6] );
neighborhoodConnected->SetLower( lowerThreshold );
neighborhoodConnected->SetUpper( upperThreshold );
InternalImageType::SizeType radius;
radius[0] = 2;
radius[1] = 2;
neighborhoodConnected->SetRadius( radius );
InternalImageType::IndexType index;
index[0] = atoi( argv[3] );
index[1] = atoi( argv[4] );
neighborhoodConnected->SetSeed( index );
neighborhoodConnected->SetReplaceValue( 255 );
try
{
writer->Update();
}
{
std::cerr << "Exception caught !" << std::endl;
std::cerr << excep << std::endl;
}
return EXIT_SUCCESS;
}