29 #include <DGtal/base/Common.h>
30 #include <DGtal/helpers/StdDefs.h>
31 #include <DGtal/io/readers/VolReader.h>
35 #include <DGtal/images/ImageContainerBySTLVector.h>
36 #include <DGtal/images/IntervalForegroundPredicate.h>
39 using namespace DGtal;
84 int main(
int argc,
char**argv)
91 int thresholdMax {255};
93 app.description(
"Computes the Euleur Characteristic of a vol to a 8-bit raw file.\n Typical use example:\n \t eulerCharacteristic <volFileName> -m <minlevel> -M <maxlevel>\n");
94 app.add_option(
"--input,-i,1", filename,
"Input vol file." )->required()->check(CLI::ExistingFile);
95 app.add_option(
"--thresholdMin,-m", thresholdMin,
"threshold min (excluded) to define binary shape (default 0)",
true);
96 app.add_option(
"--thresholdMax,-M", thresholdMax,
"threshold max (included) to define binary shape (default 255)",
true);
98 app.get_formatter()->column_width(40);
99 CLI11_PARSE(app, argc, argv);
113 bool space_ok = ks.
init( imageC.domain().lowerBound(), imageC.domain().upperBound(),
true );
116 trace.
error() <<
"Error in the Khamisky space construction."<<std::endl;
120 for(MyImageC::Domain::ConstIterator it =imageC.domain().begin(), itend= imageC.domain().end();
125 Domain dom( 2*(*it), 2*(*it) + Point::diagonal(2));
127 myCellSet.insert( ks.
uCell( *itdom) );
130 trace.
info() <<
"Got "<< myCellSet.size()<<
" cells"<<std::endl;
134 std::vector<int> cells(4,0);
136 for(KSpace::CellSet::const_iterator it = myCellSet.begin(), itend = myCellSet.end(); it !=itend; ++it)
137 cells[ ks.
uDim(*it) ] ++;
139 trace.
info() <<
"Got "<< cells[0]<<
" pointels "<<cells[1]<<
" linels "<< cells[2]<<
" surfels and "<<cells[3]<<
" bells"<<std::endl;
142 trace.
info() <<
"Volumetric Euler Characteristic = "<<cells[0] - cells[1] + cells[2] - cells[3]<<std::endl;
int main(int argc, char **argv)
typename Self::Domain Domain
bool init(const Point &lower, const Point &upper, bool isClosed)
Dimension uDim(const Cell &p) const
Cell uCell(const PreCell &c) const
void beginBlock(const std::string &keyword="")
Trace trace(traceWriterTerm)