int main( int argc, char *argv[] )
{
if( argc < 5 )
{
std::cerr << "Missing Parameters " << std::endl;
std::cerr << "Usage: " << argv[0];
std::cerr << " inputImage outputImage lowerThreshold outputScaleLevel" << std::endl;
return EXIT_FAILURE;
}
typedef float InternalPixelType;
ReaderType::Pointer reader = ReaderType::New();
WriterType::Pointer writer = WriterType::New();
reader->SetFileName( argv[1] );
writer->SetFileName( argv[2] );
InternalImageType,
InternalImageType
> GradientMagnitudeFilterType;
GradientMagnitudeFilterType::Pointer gradienMagnitudeFilter = GradientMagnitudeFilterType::New();
gradienMagnitudeFilter->SetInput( reader->GetOutput() );
gradienMagnitudeFilter->SetSigma( 1.0 );
InternalImageType
> WatershedFilterType;
WatershedFilterType::Pointer watershedFilter = WatershedFilterType::New();
watershedFilter->SetInput( gradienMagnitudeFilter->GetOutput() );
watershedFilter->SetThreshold( atof( argv[3] ) );
watershedFilter->SetLevel( atof( argv[4] ) );
unsigned long
> ColorMapFunctorType;
typedef WatershedFilterType::OutputImageType LabeledImageType;
LabeledImageType,
RGBImageType,
ColorMapFunctorType
> ColorMapFilterType;
ColorMapFilterType::Pointer colorMapFilter = ColorMapFilterType::New();
colorMapFilter->SetInput( watershedFilter->GetOutput() );
writer->SetInput( colorMapFilter->GetOutput() );
try
{
writer->Update();
}
{
std::cerr << "Exception caught !" << std::endl;
std::cerr << excep << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}