DGtalTools  1.5.beta
volInfo.cpp
1 
27 #include <iostream>
28 #include <map>
29 #include <DGtal/base/Common.h>
30 #include <DGtal/io/readers/GenericReader.h>
31 #include <DGtal/helpers/StdDefs.h>
32 #include <DGtal/images/Image.h>
33 #include <DGtal/images/ImageContainerBySTLVector.h>
34 
35 #include "CLI11.hpp"
36 
37 
38 using namespace std;
39 using namespace DGtal;
40 using namespace Z3i;
41 
77 void missingParam ( std::string param )
78 {
79  trace.error() <<" Parameter: "<<param<<" is required..";
80  trace.info() <<std::endl;
81  exit ( 1 );
82 }
83 
84 
85 int main(int argc, char**argv)
86 {
87  // parse command line using CLI ----------------------------------------------
88  CLI::App app;
89  std::string inputFileName;
90 
91  app.description("Retreive information from vol file\n Basic usage: \n \tvolInfo <volFileName> ");
92  app.add_option("-i,--input,1", inputFileName, "Input vol file." )->required()->check(CLI::ExistingFile);
93 
94  app.get_formatter()->column_width(40);
95  CLI11_PARSE(app, argc, argv);
96  // END parse command line using CLI ----------------------------------------------
97 
98  trace.beginBlock("Loading file");
100 
101  MyImageC imageC = GenericReader<MyImageC>::import(inputFileName);
102 
103  trace.info()<<imageC<<std::endl;
104  trace.info()<<"Scanning the values:"<<std::endl;
105 
106  std::map<unsigned char, size_t> values;
107  for(auto v: imageC.range())
108  values[ v ] ++;
109 
110  for(auto val: values)
111  std::cout<<"\tvalue "<< (int)val.first<<": "<< val.second<<" voxels."<<std::endl;
112 
113  trace.endBlock();
114  return 0;
115 }
int main(int argc, char **argv)
std::ostream & error()
void beginBlock(const std::string &keyword="")
std::ostream & info()
double endBlock()
Trace trace(traceWriterTerm)