40 #include "DGtal/base/Common.h"
42 #include "DGtal/kernel/SpaceND.h"
43 #include "DGtal/kernel/domains/HyperRectDomain.h"
44 #include "DGtal/topology/KhalimskySpaceND.h"
45 #include "DGtal/topology/SurfelAdjacency.h"
46 #include "DGtal/topology/SurfelNeighborhood.h"
48 #include "DGtal/shapes/Shapes.h"
49 #include "DGtal/shapes/ShapeFactory.h"
50 #include "DGtal/shapes/GaussDigitizer.h"
51 #include "DGtal/geometry/curves/GridCurve.h"
53 #include "DGtal/geometry/curves/estimation/MostCenteredMaximalSegmentEstimator.h"
54 #include "DGtal/geometry/curves/StabbingCircleComputer.h"
59 using namespace DGtal;
63 template <
typename Shape,
typename RealPo
int>
65 estimatorOnShapeDigitization(
const string& name,
78 dig.
init( low, up, h );
89 std::cerr <<
"[estimatorOnShapeDigitization]"
90 <<
" error in creating KSpace." << std::endl;
98 std::vector<Point> points;
102 gridcurve.initFromVector( points );
107 Range r = gridcurve.getIncidentPointsRange();
109 std::vector<double> estimations;
110 if (gridcurve.isOpen())
118 CurvatureEstimator estimator(sc, sce);
121 std::cout <<
"# open grid curve" << endl;
124 estimator.init( h, r.
begin(), r.
end() );
128 estimator.eval( r.
begin(), r.
end(), std::back_inserter(estimations) );
138 CurvatureEstimator estimator(sc, sce);
139 std::cout <<
"# closed grid curve" << endl;
140 estimator.init( h, r.
c(), r.
c() );
141 estimator.eval( r.
c(), r.
c(), std::back_inserter(estimations) );
144 std::cout <<
"# idx kappa" << endl;
146 for ( ClassicIterator it = r.
begin(), ite = r.
end();
147 it != ite; ++it, ++i )
149 std::cout << i <<
" " << estimations.at(i) << std::endl;
154 std::cerr <<
"[estimatorOnShapeDigitization]"
155 <<
" error in finding a bel." << std::endl;
158 trace.
emphase() << ( ok ?
"Passed." :
"Error." ) << endl;
167 trace.
info() <<
" Curvature estimation using shape to digitize: flower" << std::endl
168 <<
" with Grid step: 0.01" << std::endl;
173 string shapeName =
"flower";
180 if (shapeName ==
"flower")
183 res = estimatorOnShapeDigitization(
"flower", flower,
188 else if (shapeName ==
"ellipse")
191 res = estimatorOnShapeDigitization(
"ellipse", ellipse,
196 else if (shapeName ==
"ball")
199 res = estimatorOnShapeDigitization(
"ball", ball,
void beginBlock(const std::string &keyword="")
const Point & getUpperBound() const
static Self diagonal(Component val=1)
Aim: A utility class for constructing surfaces (i.e. set of (n-1)-cells).
void attach(ConstAlias< EuclideanShape > shape)
Aim: A model of CLocalCurveGeometricEstimator that assigns to each element of a (sub)range a quantity...
Aim: Model of the concept StarShaped represents any ellipse in the plane.
Aim: Model of the concept StarShaped represents any flower with k-petals in the plane.
Aim: On-line recognition of a digital circular arcs (DCA) defined as a sequence of connected grid edg...
Aim: model of CBidirectionalRangeFromPoint that adapts any range of elements bounded by two iterators...
Aim: Model of the concept StarShaped represents any circle in the plane.
void init(const RealPoint &xLow, const RealPoint &xUp, typename RealVector::Component gridStep)
bool init(const Point &lower, const Point &upper, bool isClosed)
Aim: A class for computing the Gauss digitization of some Euclidean shape, i.e. its intersection with...
Aim: Provides an adapter for classical iterators that can iterate through the underlying data structu...
DGtal is the top-level namespace which contains all DGtal functions and types.
Aim: model of CConstBidirectionalRange that adapts any range of elements bounded by two iterators [it...
Represents a signed cell in a cellular grid space by its Khalimsky coordinates and a boolean value...
const Point & getLowerBound() const
TConstIterator ConstIterator
Aim: describes, in a cellular space of dimension n, a closed or open sequence of signed d-cells (or d...
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex...