34 #include "DGtal/base/Common.h"
36 #include "DGtal/shapes/ShapeFactory.h"
37 #include "DGtal/shapes/Shapes.h"
38 #include "DGtal/helpers/StdDefs.h"
39 #include "DGtal/topology/helpers/Surfaces.h"
42 #include "DGtal/geometry/curves/FreemanChain.h"
43 #include "DGtal/geometry/curves/GridCurve.h"
46 #include "DGtal/geometry/curves/BinomialConvolver.h"
54 using namespace DGtal;
109 int main(
int argc,
char** argv )
113 std::string fileName;
116 app.description(
"Estimates curvature using length of most centered segment computers.\n Typical use example:\n \t curvatureMCMS [options] --input <fileName>\n");
117 app.add_option(
"-i,--input,1",fileName,
"Input FreemanChain file name")->required()->check(CLI::ExistingFile);
118 app.add_option(
"--GridStep", h,
"Grid step",
true);
120 app.get_formatter()->column_width(40);
121 CLI11_PARSE(app, argc, argv);
126 typedef Space::Point
Point;
127 typedef Space::Integer
Integer;
129 typedef std::vector< Point > Storage;
130 typedef Storage::const_iterator ConstIteratorOnPoints;
135 for(
unsigned int i=0; i<vectFcs.size(); i++){
137 bool isClosed = vectFcs.at(i).isClosed();
138 std::cout <<
"# grid curve " << i+1 <<
"/" << vectFcs.size() <<
" "
139 << ( (isClosed)?
"closed":
"open" ) << std::endl;
145 std::cout <<
"# Curvature estimation from binomial convolution" << std::endl;
147 std::cout <<
"# mask size = " <<
148 MyBinomialConvolver::suggestedSize( h, vectPts.begin(), vectPts.end() ) << std::endl;
153 BCCurvatureEstimator.
init( h, vectPts.begin(), vectPts.end(), isClosed );
155 std::vector <double> curvatures( vectPts.size() );
156 BCCurvatureEstimator.
eval( vectPts.begin(), vectPts.end(), curvatures.begin() );
159 std::cout <<
"# id curvature" << std::endl;
161 for ( ConstIteratorOnPoints it = vectPts.begin(), it_end = vectPts.end();
162 it != it_end; ++it, ++j ) {
163 std::cout << j << std::setprecision( 15 )
164 <<
" " << curvatures[ j ] << std::endl;
int main(int argc, char **argv)
void init(const double h, const ConstIterator &itb, const ConstIterator &ite, const bool isClosed=true)
Quantity eval(const ConstIterator &it)
static void getContourPoints(const FreemanChain &fc, std::vector< Point > &aVContour)
typename Self::Point Point
SpaceND< 2, Integer > Space