ANIMA  4.0
animaDistanceMap.cxx
Go to the documentation of this file.
1 #include <itkSignedMaurerDistanceMapImageFilter.h>
2 
4 #include <tclap/CmdLine.h>
5 
6 int main(int argc, char **argv)
7 {
8  TCLAP::CmdLine cmd("INRIA / IRISA - VisAGeS/Empenn Team", ' ',ANIMA_VERSION);
9 
10  TCLAP::ValueArg<std::string> inArg("i","inputfile","Input image",true,"","input image",cmd);
11  TCLAP::ValueArg<std::string> outArg("o","outputfile","Output image",true,"","output image",cmd);
12 
13  TCLAP::SwitchArg invArg("I","positive-outside","Positive distances will be outside the object (default: not activated)",cmd,false);
14 
15  try
16  {
17  cmd.parse(argc,argv);
18  }
19  catch (TCLAP::ArgException& e)
20  {
21  std::cerr << "Error: " << e.error() << "for argument " << e.argId() << std::endl;
22  return EXIT_FAILURE;
23  }
24 
25  typedef itk::Image <unsigned short,3> ImageType;
26  typedef itk::Image <double,3> doubleImageType;
27 
28  typedef itk::SignedMaurerDistanceMapImageFilter <ImageType,doubleImageType> MainFilterType;
29 
30  MainFilterType::Pointer mainFilter = MainFilterType::New();
31  mainFilter->SetInput(anima::readImage <ImageType> (inArg.getValue()));
32  mainFilter->SetSquaredDistance(false);
33  mainFilter->SetBackgroundValue(0);
34 
35  if (!invArg.isSet())
36  mainFilter->InsideIsPositiveOn();
37  else
38  mainFilter->InsideIsPositiveOff();
39 
40  mainFilter->UseImageSpacingOn();
41  mainFilter->Update();
42 
43  anima::writeImage <doubleImageType> (outArg.getValue(),mainFilter->GetOutput());
44  return EXIT_SUCCESS;
45 }
int main(int argc, char **argv)