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> ImageType;
11 typedef itk::ImageRegionConstIterator <ImageType> ImageIterator;
14 TCLAP::CmdLine cmd(
"INRIA / IRISA - VisAGeS/Empenn Team",
' ',ANIMA_VERSION);
17 TCLAP::ValueArg<std::string> inArg(
"i",
"inputfile",
"Input image",
true,
"",
"input image", cmd);
19 TCLAP::ValueArg<std::string> outArg(
"o",
"outputfile",
"Output TLL score",
false,
"",
"output image", cmd);
25 catch (TCLAP::ArgException& e)
27 std::cerr <<
"Error: " << e.error() <<
"for argument " << e.argId() << std::endl;
31 ImageType::Pointer inputImage = anima::readImage <ImageType> (inArg.getValue());
33 ImageIterator inputIt(inputImage,inputImage->GetLargestPossibleRegion());
36 while(!inputIt.IsAtEnd())
38 if(inputIt.Get() != 0)
44 ImageType::SpacingType spacing = inputImage->GetSpacing();
45 ImageType::SpacingValueType spacingTot = spacing[0];
46 for (
unsigned int i = 1; i < 3;++i)
47 spacingTot *= spacing[i];
49 std::ofstream oFileOut;
50 if (outArg.getValue() !=
"")
52 oFileOut.open(outArg.getValue(), std::ios::out | std::ios::trunc);
53 if (!oFileOut.is_open())
55 std::cerr <<
"Can not open file: " << outArg.getValue() <<
"to store TLL value" << std::endl;
59 if (oFileOut.is_open())
61 oFileOut << cpt * spacingTot;
65 std::cout << cpt * spacingTot << std::endl;
int main(int argc, const char **argv)