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/ArithmeticalDSSComputer.h"
47 #include "DGtal/geometry/curves/estimation/MostCenteredMaximalSegmentEstimator.h"
48 #include "DGtal/geometry/curves/estimation/SegmentComputerEstimators.h"
57 using namespace DGtal;
117 template<
typename I,
typename O>
118 void estimationFromLength(
double h,
const I& itb,
const I& ite,
const O& ito )
125 Estimator CurvatureEstimator(sc, f);
127 CurvatureEstimator.eval( itb, ite, ito, h );
138 template<
typename I,
typename O>
139 void estimationFromLengthAndWidth(
double h,
const I& itb,
const I& ite,
const O& ito )
146 Estimator CurvatureEstimator(sc, f);
148 CurvatureEstimator.eval( itb, ite, ito, h );
154 int main(
int argc,
char** argv )
161 app.description(
"Estimates curvature using length of most centered segment computers.\n Typical use example:\n \t curvatureMCMS [options] --input <fileName>\n");
162 app.add_option(
"-i,--input, 1",fileName,
"Input FreemanChain file name")->required()->check(CLI::ExistingFile);
163 app.add_option(
"--GridStep", h,
"Grid step",
true);
165 app.get_formatter()->column_width(40);
166 CLI11_PARSE(app, argc, argv);
170 typedef Space::Point
Point;
171 typedef Space::Integer
Integer;
177 for(
unsigned int i=0; i<vectFcs.size(); i++){
185 cout <<
"# grid curve " << i+1 <<
"/"
186 << gridcurve.
size() <<
" "
187 << ( (gridcurve.
isClosed())?
"closed":
"open" ) << endl;
194 cout <<
"# Curvature estimation from maximal segments" << endl;
195 std::vector<double> estimations1;
196 std::vector<double> estimations2;
199 cout <<
"# open grid curve" << endl;
200 estimationFromLength( h, r.begin(), r.end(), back_inserter(estimations1) );
201 estimationFromLengthAndWidth( h, r.begin(), r.end(), back_inserter(estimations2) );
205 cout <<
"# closed grid curve" << endl;
206 estimationFromLength( h, r.c(), r.c(), back_inserter(estimations1) );
207 estimationFromLengthAndWidth( h, r.c(), r.c(), back_inserter(estimations2) );
211 cout <<
"# id curvatureFromLength curvatureFromLengthAndWidth" << endl;
213 for ( Range::ConstIterator it = r.begin(), itEnd = r.end();
214 it != itEnd; ++it, ++j ) {
215 cout << j << setprecision( 15 )
216 <<
" " << estimations1[ j ]
217 <<
" " << estimations2[ j ] << endl;
int main(int argc, char **argv)
ConstIterator begin() const
ConstIterator end() const
PointsRange getPointsRange() const
bool initFromPointsRange(const TIterator &itb, const TIterator &ite)
Storage::size_type size() const
typename Self::Point Point
SpaceND< 2, Integer > Space