1 #include <tclap/CmdLine.h> 3 #include <itkTimeProbe.h> 7 int main(
int argc,
const char** argv)
9 const unsigned int Dimension = 3;
10 typedef itk::Image <unsigned char,Dimension> UCImageType;
11 typedef itk::Image <unsigned int,Dimension> UIImageType;
15 TCLAP::CmdLine cmd(
"INRIA / IRISA - VisAGeS/Empenn Team",
' ',ANIMA_VERSION);
20 TCLAP::ValueArg<std::string> inArg(
"i",
"inputfile",
"Input image",
true,
"",
"input image",cmd);
21 TCLAP::ValueArg<std::string> outArg(
"o",
"outputfile",
"Output image",
true,
"",
"output image",cmd);
23 TCLAP::ValueArg<std::string> maskFileArg(
"m",
"mask",
"Brain mask",
true,
"",
"brain mask",cmd);
25 TCLAP::SwitchArg noContourDetectionArg(
"C",
"noContour",
"Avoid contour detection (default: false)",cmd,
false);
26 TCLAP::SwitchArg rmNonTouchingArg(
"R",
"rmNonTouching",
"Remove non touching components instead of touching components (default: false)",cmd,
false);
27 TCLAP::SwitchArg labeledImageArg(
"L",
"labeledImage",
"Input image is a labeled image (default: false)",cmd,
false);
30 TCLAP::ValueArg<unsigned int> numThreadsArg(
"T",
"threads",
"Number of execution threads (default: 0 = all cores)",
false,0,
"number of threads",cmd);
31 TCLAP::SwitchArg verboseArg(
"v",
"verbose",
"verbose mode (default: false)",cmd,
false);
37 catch (TCLAP::ArgException& e)
39 std::cerr <<
"Error: " << e.error() <<
"for argument " << e.argId() << std::endl;
43 FilterTypeSeg::Pointer segFilter = FilterTypeSeg::New();
45 if(inArg.getValue() !=
"")
46 segFilter->SetInputImageSeg(anima::readImage<UIImageType> (inArg.getValue()));
48 if(outArg.getValue() !=
"")
50 if(rmNonTouchingArg.isSet())
51 segFilter->SetOutputTouchingBorderFilename(outArg.getValue());
53 segFilter->SetOutputNonTouchingBorderFilename(outArg.getValue());
56 if(maskFileArg.getValue() !=
"")
57 segFilter->SetMask(anima::readImage<UCImageType> (maskFileArg.getValue()));
60 segFilter->SetLabeledImage( labeledImageArg.getValue() );
61 segFilter->SetNoContour( noContourDetectionArg.getValue() );
62 segFilter->SetVerbose( verboseArg.getValue() );
63 segFilter->SetNumberOfWorkUnits( numThreadsArg.getValue() );
68 std::cout <<
"Remove lesions touching border..." << std::endl;
75 segFilter->WriteOutputs();
77 catch (itk::ExceptionObject &e)
79 std::cerr << e << std::endl;
85 std::cout <<
"Elapsed Time: " << timer.GetTotal() << timer.GetUnit() << std::endl;
Class selecting the connected components touching a given mask border. In MRI, external CSF may conta...
int main(int argc, const char **argv)