32#include "DGtal/base/Common.h"
35#include "DGtal/kernel/SpaceND.h"
36#include "DGtal/kernel/domains/HyperRectDomain.h"
37#include "DGtal/topology/KhalimskySpaceND.h"
40#include "DGtal/shapes/ShapeFactory.h"
41#include "DGtal/shapes/Shapes.h"
42#include "DGtal/helpers/StdDefs.h"
43#include "DGtal/topology/helpers/Surfaces.h"
45#include "DGtal/shapes/GaussDigitizer.h"
46#include "DGtal/geometry/curves/GridCurve.h"
49#include "DGtal/geometry/curves/estimation/TrueLocalEstimatorOnPoints.h"
50#include "DGtal/geometry/curves/estimation/TrueGlobalEstimatorOnPoints.h"
51#include "DGtal/geometry/curves/estimation/ParametricShapeCurvatureFunctor.h"
52#include "DGtal/geometry/curves/estimation/ParametricShapeTangentFunctor.h"
53#include "DGtal/geometry/curves/estimation/ParametricShapeArcLengthFunctor.h"
55#include "DGtal/geometry/curves/estimation/L1LengthEstimator.h"
56#include "DGtal/geometry/curves/estimation/TwoStepLocalLengthEstimator.h"
57#include "DGtal/geometry/curves/estimation/BLUELocalLengthEstimator.h"
58#include "DGtal/geometry/curves/estimation/RosenProffittLocalLengthEstimator.h"
60#include "DGtal/geometry/curves/estimation/MLPLengthEstimator.h"
61#include "DGtal/geometry/curves/estimation/FPLengthEstimator.h"
62#include "DGtal/geometry/curves/estimation/DSSLengthEstimator.h"
64#include "ConfigTest.h"
66#include "DGtal/io/boards/Board2D.h"
78bool testLengthEstimatorsOnBall(
double radius,
double h)
97 trace.info() <<
"#ball created, r=" << radius << endl;
104 dig.
init( xLow, xUp, h );
114 <<
" error in creating KSpace." << std::endl;
127 <<
" error in finding a bel." << std::endl;
132 std::vector<Point> points;
134 trace.info() <<
"#tracking..." << endl;
138 trace.info() <<
"#grid curve created, h=" << h << endl;
145 double trueValue = M_PI*2*radius;
154 trace.info() <<
"#Estimations" <<std::endl;
155 trace.info() <<
"#h true naive 1-sqrt(2) BLUE RosenProffitt DSS MLP FP " <<std::endl;
156 trace.info() << h <<
" " << trueValue
157 <<
" " << l1length.
eval(rp.c(), rp.c(), h)
158 <<
" " << locallength.eval(ra.begin(), ra.end(), h)
159 <<
" " << BLUElength.
eval(ra.begin(), ra.end(), h)
160 <<
" " << RosenProffittlength.
eval(ra.begin(), ra.end(), h)
161 <<
" " << DSSlength.
eval(rp.c(), rp.c(), h)
162 <<
" " << MLPlength.
eval(rp.c(), rp.c(), h)
163 <<
" " << FPlength.
eval(rp.c(), rp.c(), h)
190 trace.info() <<
"#ball created, r=" << radius << endl;
197 dig.
init( xLow, xUp, h );
207 <<
" error in creating KSpace." << std::endl;
216 std::vector<Point> points;
218 trace.info() <<
"# tracking..." << endl;
222 trace.info() <<
"#grid curve created, h=" << h << endl;
236 board.
saveSVG(
"Ranges-Set.svg" );
244 board.
saveSVG(
"Ranges-Points.svg" );
253 board.
saveSVG(
"Ranges-SCells.svg" );
268 board.
saveSVG(
"Ranges-Arrows.svg" );
274 <<
" error in finding a bel." << std::endl;
286int main(
int argc,
char** argv )
288 trace.beginBlock (
"Testing class LengthEstimators" );
289 trace.info() <<
"Args:";
290 for (
int i = 0; i < argc; ++i )
291 trace.info() <<
" " << argv[ i ];
292 trace.info() << endl;
295 bool res = testLengthEstimatorsOnBall(r,1)
296 && testLengthEstimatorsOnBall(r,0.1)
297 && testLengthEstimatorsOnBall(r,0.01)
298 && testLengthEstimatorsOnBall(r,0.001)
302 trace.emphase() << ( res ?
"Passed." :
"Error." ) << endl;
Aim: Best Linear Unbiased Two step length estimator.
Aim: Model of the concept StarShaped represents any circle in the plane.
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
Aim: a model of CGlobalCurveEstimator that segments the digital curve into DSS and computes the lengt...
Quantity eval(const ConstIterator &itb, const ConstIterator &ite, const double h=1.) const
Aim: a model of CGlobalCurveEstimator that computes the length of a digital curve using its FP (faith...
Quantity eval(const ConstIterator &itb, const ConstIterator &ite, const double h=1.) const
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...
bool initFromPointsVector(const std::vector< Point > &aVectorOfPoints)
ConstRangeAdapter< typename Storage::const_iterator, functors::Identity, SCell > SCellsRange
SCellsRange getSCellsRange() const
PointsRange getPointsRange() const
ConstRangeAdapter< typename Storage::const_iterator, functors::SCellToPoint< KSpace >, Point > PointsRange
ArrowsRange getArrowsRange() const
ConstRangeAdapter< typename Storage::const_iterator, functors::SCellToArrow< KSpace >, std::pair< Point, Vector > > ArrowsRange
Aim: Parallelepidec region of a digital space, model of a 'CDomain'.
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex,...
SignedKhalimskyCell< dim, Integer > SCell
Aim: a simple model of CGlobalCurveEstimator that compute the length of a curve using the l_1 metric ...
Quantity eval(const ConstIterator &itb, const ConstIterator &ite, const double h) const
Aim: a model of CGlobalCurveEstimator that computes the length of a digital curve using its MLP (give...
Quantity eval(const ConstIterator &itb, const ConstIterator &ite, const double h=1.) const
Aim: Rosen-Proffitt Length Estimator.
static void euclideanShaper(TDigitalSet &aSet, const TShapeFunctor &aFunctor, const double h=1.0)
PointVector< dim, Integer > Point
PointVector< dim, double > RealPoint
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...
Aim: a simple model of CGlobalCurveEstimator that compute the length of a curve using the l_1 metric ...
Quantity eval(const ConstIterator &itb, const ConstIterator &ite, const double h=1.) const
void clear(const DGtal::Color &color=DGtal::Color::None)
void saveSVG(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Point::Coordinate Integer
DigitalSetSelector< Domain, BIG_DS+HIGH_BEL_DS >::Type DigitalSet
DGtal is the top-level namespace which contains all DGtal functions and types.
PointVector< 3, double > RealPoint