34#include "DGtal/base/Common.h"
36#include "DGtal/shapes/Shapes.h"
37#include "DGtal/shapes/ShapeFactory.h"
39#include "DGtal/geometry/curves/estimation/TrueLocalEstimatorOnPoints.h"
41#include "DGtal/geometry/curves/estimation/ParametricShapeCurvatureFunctor.h"
42#include "DGtal/geometry/curves/estimation/ParametricShapeTangentFunctor.h"
43#include "DGtal/geometry/curves/estimation/ParametricShapeArcLengthFunctor.h"
44#include "DGtal/geometry/curves/estimation/MostCenteredMaximalSegmentEstimator.h"
45#include "DGtal/geometry/curves/ArithmeticalDSSComputer.h"
47#include "DGtal/kernel/SpaceND.h"
48#include "DGtal/kernel/domains/HyperRectDomain.h"
49#include "DGtal/kernel/sets/DigitalSetSelector.h"
50#include "DGtal/topology/KhalimskySpaceND.h"
51#include "DGtal/topology/SurfelAdjacency.h"
52#include "DGtal/topology/SurfelNeighborhood.h"
54#include "DGtal/shapes/GaussDigitizer.h"
55#include "DGtal/geometry/curves/GridCurve.h"
57#include "DGtal/geometry/curves/estimation/CompareLocalEstimators.h"
60#include "ConfigTest.h"
68template <
typename Shape>
82 dig.
init( xLow, xUp, h );
93 std::cerr <<
"[testCompareEstimators]"
94 <<
" error in creating KSpace." << std::endl;
102 std::vector<Point> points;
112 unsigned int nbok = 0;
116 TrueCurvature curvatureEstimator;
117 TrueCurvature curvatureEstimatorBis;
118 curvatureEstimator.
attach( aShape );
119 curvatureEstimatorBis.attach( aShape );
123 trace.
info()<<
"True curvature comparison at "<< *r.begin() <<
" = "
124 << Comparator::compare(curvatureEstimator,curvatureEstimatorBis, r.begin(), h)
127 typename Comparator::OutputStatistic error =
128 Comparator::compare(curvatureEstimator, curvatureEstimatorBis,
129 r.begin(), r.end(), h);
131 trace.
info() <<
"Nb samples= "<< error.samples()<<std::endl;
132 trace.
info() <<
"Error mean= "<< error.mean()<<std::endl;
133 trace.
info() <<
"Error max= "<< error.max()<<std::endl;
134 nbok += ( ( ( (
unsigned int)error.samples() ) == r.size())
135 && (error.max() == 0) )
138 trace.
info() << nbok <<
"/" << nb << std::endl;
154 MSTangentEstimator tang2(sc, f);
156 tang1.attach( aShape );
157 tang2.init( r.begin(), r.end() );
161 trace.
info()<<
"Tangent comparison at "<< *r.begin() <<
" = "
162 << ComparatorTan::compareVectors( tang1, tang2, r.begin(), h)
165 typename ComparatorTan::OutputVectorStatistic error2
166 = ComparatorTan::compareVectors(tang1, tang2, r.begin(), r.end(), h);
168 trace.
info()<<
"Nb samples= "<< error2.samples()<<std::endl;
169 trace.
info()<<
"Error mean= "<< error2.mean()<<std::endl;
170 trace.
info()<<
"Error max= "<< error2.max()<<std::endl;
171 nbok += (error.samples() == r.size())?1:0;
173 trace.
info() << nbok <<
"/" << nb << std::endl;
179 std::cerr <<
"[testCompareEstimator]"
180 <<
" error in finding a bel." << std::endl;
183 trace.
emphase() << ( ok ?
"Passed." :
"Error." ) << endl;
193int main(
int argc,
char** argv )
197 for (
int i = 0; i < argc; ++i )
202 MyFlower flower( 0.5, -2.3, 5.0, 0.7, 6, 0.3 );
203 bool res = testCompareEstimator<MyFlower>(
"Flower", flower, 0.25);
Aim: This class is a wrapper around ArithmeticalDSS that is devoted to the dynamic recognition of dig...
Aim: Model of the concept StarShaped represents any flower with k-petals in the plane.
Aim: A class for computing the Gauss digitization of some Euclidean shape, i.e. its intersection with...
const Point & getUpperBound() const
void attach(ConstAlias< EuclideanShape > shape)
const Point & getLowerBound() const
void init(const RealPoint &xLow, const RealPoint &xUp, typename RealVector::Component gridStep)
Aim: describes, in a cellular space of dimension n, a closed or open sequence of signed d-cells (or d...
PointsRange getPointsRange() const
bool initFromVector(const std::vector< Point > &aVectorOfPoints)
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex,...
bool init(const Point &lower, const Point &upper, bool isClosed)
Specifies the upper and lower bounds for the maximal cells in this space.
Aim: A model of CLocalCurveGeometricEstimator that assigns to each element of a (sub)range a quantity...
Aim: implements a functor that computes the curvature at a given point of a parametric shape.
Aim: implements a functor that computes the tangent vector at a given point of a parametric shape.
Aim: Implements basic operations that will be used in Point and Vector classes.
Aim: model of CBidirectionalRangeFromPoint that adapts any range of elements bounded by two iterators...
TConstIterator ConstIterator
static void track2DBoundaryPoints(std::vector< Point > &aVectorOfPoints, const KSpace &K, const SurfelAdjacency< KSpace::dimension > &surfel_adj, const PointPredicate &pp, const SCell &start_surfel)
static SCell findABel(const KSpace &K, const PointPredicate &pp, unsigned int nbtries=1000)
Aim: Represent adjacencies between surfel elements, telling if it follows an interior to exterior ord...
void beginBlock(const std::string &keyword="")
Aim: Computes the true quantity to each element of a range associated to a parametric shape.
void attach(const ParametricShape &aShape)
DGtal is the top-level namespace which contains all DGtal functions and types.
Aim: Functor to compare two local geometric estimators.
Represents a signed cell in a cellular grid space by its Khalimsky coordinates and a boolean value.
ArithmeticalDSSComputer< std::vector< Z2i::Point >::const_iterator, int, 4 > SegmentComputer
InHalfPlaneBySimple3x3Matrix< Point, double > Functor
bool testCompareEstimator(const std::string &name, const Shape &aShape, double h)