Example of curvature estimation based on Digital Circular Arc (DCA) estimator.
#include <iostream>
#include "DGtal/base/Common.h"
#include "DGtal/kernel/SpaceND.h"
#include "DGtal/kernel/domains/HyperRectDomain.h"
#include "DGtal/topology/KhalimskySpaceND.h"
#include "DGtal/topology/SurfelAdjacency.h"
#include "DGtal/topology/SurfelNeighborhood.h"
#include "DGtal/shapes/Shapes.h"
#include "DGtal/shapes/ShapeFactory.h"
#include "DGtal/shapes/GaussDigitizer.h"
#include "DGtal/geometry/curves/GridCurve.h"
#include "DGtal/geometry/curves/estimation/MostCenteredMaximalSegmentEstimator.h"
#include "DGtal/geometry/curves/StabbingCircleComputer.h"
template <typename Shape, typename RealPoint>
bool
double h )
{
trace.beginBlock ( (
"Curvature estimation on digitization of "
+ name ). c_str() );
if ( ! ok )
{
std::cerr << "[estimatorOnShapeDigitization]"
<< " error in creating KSpace." << std::endl;
}
else
try {
std::vector<Point> points;
typedef Range::ConstIterator ClassicIterator;
typedef Range::ConstCirculator CircularIterator;
std::vector<double> estimations;
{
SCEstimator sce;
CurvatureEstimator estimator(sc, sce);
std::cout << "# open grid curve" << endl;
estimator.init( r.begin(), r.end() );
estimator.eval( r.begin(), r.end(), std::back_inserter(estimations), h );
}
else
{
SCEstimator sce;
CurvatureEstimator estimator(sc, sce);
std::cout << "# closed grid curve" << endl;
estimator.init( r.c(), r.c() );
estimator.eval( r.c(), r.c(), std::back_inserter(estimations), h );
}
std::cout << "# idx kappa" << endl;
unsigned int i = 0;
for ( ClassicIterator it = r.begin(), ite = r.end();
it != ite; ++it, ++i )
{
std::cout << i << " " << estimations.at(i) << std::endl;
}
}
{
std::cerr << "[estimatorOnShapeDigitization]"
<< " error in finding a bel." << std::endl;
ok = false;
}
trace.emphase() << ( ok ?
"Passed." :
"Error." ) << endl;
return ok;
}
{
trace.beginBlock (
"Example exampleCurvature" );
trace.info() <<
" Curvature estimation using shape to digitize: flower" << std::endl
<< " with Grid step: 0.01" << std::endl;
double h = 0.01;
string shapeName = "flower";
bool res = true;
if (shapeName == "flower")
{
RealPoint::diagonal(-10),
RealPoint::diagonal(10),
h);
}
else if (shapeName == "ellipse")
{
RealPoint::diagonal(-10),
RealPoint::diagonal(10),
h);
}
else if (shapeName == "ball")
{
RealPoint::diagonal(-10),
RealPoint::diagonal(10),
h);
}
return res;
}
Aim: Model of the concept StarShaped represents any circle in the plane.
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: 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)
IncidentPointsRange getIncidentPointsRange() const
ConstRangeAdapter< typename Storage::const_iterator, functors::SCellToIncidentPoints< KSpace >, std::pair< Point, Point > > IncidentPointsRange
Aim: A model of CLocalCurveGeometricEstimator that assigns to each element of a (sub)range a quantity...
PointVector< dim, double > RealPoint
Aim: On-line recognition of a digital circular arcs (DCA) defined as a sequence of connected grid edg...
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...
bool estimatorOnShapeDigitization(const string &name, Shape &aShape, const RealPoint &low, const RealPoint &up, double h)
Z2i this namespace gathers the standard of types for 2D imagery.
SpaceND< 2, Integer > Space
DGtal is the top-level namespace which contains all DGtal functions and types.
ArithmeticalDSSComputer< std::vector< Z2i::Point >::const_iterator, int, 4 > SegmentComputer
HyperRectDomain< Space > Domain
PointVector< 3, double > RealPoint