DGtalTools 2.0.0
Loading...
Searching...
No Matches
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
38using namespace std;
39using namespace DGtal;
40using namespace Z3i;
41
77void missingParam ( std::string param )
78{
79 trace.error() <<" Parameter: "<<param<<" is required..";
80 trace.info() <<std::endl;
81 exit ( 1 );
82}
83
84
85int 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");
99 typedef ImageContainerBySTLVector<Z3i::Domain, unsigned char> MyImageC;
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}
Definition ATu0v1.h:57