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" 65 using namespace DGtal;
68 template <
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.
init( h, r.begin(), r.end() );
119 curvatureEstimator.attach( &aShape );
120 curvatureEstimatorBis.init( h, r.begin(), r.end() );
121 curvatureEstimatorBis.attach( &aShape );
125 trace.
info()<<
"True curvature comparison at "<< *r.begin() <<
" = " 129 typename Comparator::OutputStatistic error
134 trace.
info() <<
"Nb samples= "<< error.samples()<<std::endl;
135 trace.
info() <<
"Error mean= "<< error.mean()<<std::endl;
136 trace.
info() <<
"Error max= "<< error.max()<<std::endl;
137 nbok += ( ( ( (
unsigned int)error.samples() ) == r.size())
138 && (error.max() == 0) )
141 trace.
info() << nbok <<
"/" << nb << std::endl;
157 MSTangentEstimator tang2(sc, f);
159 tang1.init( h, r.begin(), r.end() );
160 tang1.attach( &aShape );
161 tang2.init( h, r.begin(), r.end() );
165 trace.
info()<<
"Tangent comparison at "<< *r.begin() <<
" = " 166 << ComparatorTan::compareVectors( tang1, tang2, r.begin())
169 typename ComparatorTan::OutputVectorStatistic error2
170 =ComparatorTan::compareVectors(tang1, tang2,
174 trace.
info()<<
"Nb samples= "<< error2.samples()<<std::endl;
175 trace.
info()<<
"Error mean= "<< error2.mean()<<std::endl;
176 trace.
info()<<
"Error max= "<< error2.max()<<std::endl;
177 nbok += (error.samples() == r.size())?1:0;
179 trace.
info() << nbok <<
"/" << nb << std::endl;
185 std::cerr <<
"[testCompareEstimator]" 186 <<
" error in finding a bel." << std::endl;
189 trace.
emphase() << ( ok ?
"Passed." :
"Error." ) << endl;
199 int main(
int argc,
char** argv )
203 for (
int i = 0; i < argc; ++i )
208 MyFlower flower( 0.5, -2.3, 5.0, 0.7, 6, 0.3 );
209 bool res = testCompareEstimator<MyFlower>(
"Flower", flower, 0.25);
void beginBlock(const std::string &keyword="")
InHalfPlaneBySimple3x3Matrix< Point, double > Functor
Aim: Functor to compare two local geometric estimators.
const Point & getLowerBound() const
Aim: A utility class for constructing surfaces (i.e. set of (n-1)-cells).
const Point & getUpperBound() const
void attach(ConstAlias< EuclideanShape > shape)
Aim: A model of CLocalCurveGeometricEstimator that assigns to each element of a (sub)range a quantity...
bool testCompareEstimator(const std::string &name, Shape &aShape, double h)
Aim: Implements basic operations that will be used in Point and Vector classes.
PointVector< 3, double > RealPoint
Aim: Model of the concept StarShaped represents any flower with k-petals in the plane.
Aim: This class is a wrapper around ArithmeticalDSS that is devoted to the dynamic recognition of dig...
PointsRange getPointsRange() const
Aim: model of CBidirectionalRangeFromPoint that adapts any range of elements bounded by two iterators...
bool initFromVector(const std::vector< Point > &aVectorOfPoints)
void init(const RealPoint &xLow, const RealPoint &xUp, typename RealVector::Component gridStep)
void init(const double h, const ConstIterator &itb, const ConstIterator &ite)
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 class for computing the Gauss digitization of some Euclidean shape, i.e. its intersection with...
int main(int argc, char **argv)
Aim: Computes the true quantity to each element of a range associated to a parametric shape.
DGtal is the top-level namespace which contains all DGtal functions and types.
Represents a signed cell in a cellular grid space by its Khalimsky coordinates and a boolean value.
Aim: implements a functor that computes the tangent vector at a given point of a parametric shape.
TConstIterator ConstIterator
Aim: describes, in a cellular space of dimension n, a closed or open sequence of signed d-cells (or d...
bool compare(const Range1 &pts, const Range2 &groundTruth)
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex,...
Aim: implements a functor that computes the curvature at a given point of a parametric shape.