33 #include "DGtal/base/Common.h" 36 #include "DGtal/shapes/implicit/ImplicitBall.h" 39 #include "DGtal/shapes/GaussDigitizer.h" 40 #include "DGtal/topology/LightImplicitDigitalSurface.h" 41 #include "DGtal/topology/DigitalSurface.h" 42 #include "DGtal/graph/DepthFirstVisitor.h" 43 #include "DGtal/graph/GraphVisitorRange.h" 46 #include "DGtal/geometry/surfaces/estimation/IIGeometricFunctors.h" 47 #include "DGtal/geometry/surfaces/estimation/IntegralInvariantCovarianceEstimator.h" 53 using namespace DGtal;
75 double realValue = 1.0/(radius * radius);
87 trace.
error() <<
"Problem with Khalimsky space" << std::endl;
93 MyDigitalSurface surf ( boundary );
100 VisitorConstIterator ibegin = range.begin();
101 VisitorConstIterator iend = range.end();
103 MyIICurvatureFunctor curvatureFunctor;
104 curvatureFunctor.init( h, re );
106 MyIICurvatureEstimator curvatureEstimator( curvatureFunctor );
107 curvatureEstimator.attach( K, dshape );
108 curvatureEstimator.setParams( re/h );
109 curvatureEstimator.init( h, ibegin, iend );
115 std::vector< Value > results;
116 std::back_insert_iterator< std::vector< Value > > resultsIt( results );
117 curvatureEstimator.eval( ibegin, iend, resultsIt );
121 trace.
beginBlock (
"Comparing results of integral invariant 3D Gaussian curvature ..." );
124 unsigned int rsize = results.size();
128 trace.
error() <<
"ERROR: surface is empty" << std::endl;
133 for (
unsigned int i = 0; i < rsize; ++i )
135 mean += results[ i ];
141 trace.
error() <<
"ERROR: result is NaN" << std::endl;
146 double v = std::abs ( realValue - mean );
148 trace.
warning() <<
"True value: " << realValue << std::endl;
150 trace.
warning() <<
"Delta: " << delta <<
" |true - mean|: " << v << std::endl;
188 trace.
error() <<
"Problem with Khalimsky space" << std::endl;
194 MyDigitalSurface surf ( boundary );
200 VisitorRange range(
new Visitor( surf, *surf.
begin() ));
201 VisitorConstIterator ibegin = range.begin();
202 VisitorConstIterator iend = range.end();
204 MyIICurvatureFunctor curvatureFunctor;
205 curvatureFunctor.init( h, re );
207 MyIICurvatureEstimator curvatureEstimator( curvatureFunctor );
208 curvatureEstimator.attach( K, dshape );
209 curvatureEstimator.setParams( re/h );
210 curvatureEstimator.init( h, ibegin, iend );
216 std::vector< Value > results;
217 std::back_insert_iterator< std::vector< Value > > resultsIt( results );
218 curvatureEstimator.eval( ibegin, iend, resultsIt );
222 trace.
beginBlock (
"Comparing results of integral invariant 3D Gaussian curvature ..." );
224 unsigned int error_order = 0;
225 unsigned int rsize = results.size();
229 trace.
error() <<
"ERROR: surface is empty" << std::endl;
234 for (
unsigned int i = 0; i < rsize; ++i )
236 if( std::abs(results[i].first) < std::abs(results[i].second) )
242 trace.
warning() <<
"Error order: " << error_order << std::endl;
243 trace.
warning() <<
"If not equals to 0, something is wrong..." << std::endl;
247 if( error_order != 0 )
259 trace.
beginBlock (
"Testing class IntegralInvariantCovarianceEstimator and 3d functors" );
261 trace.
emphase() << ( res ?
"Passed." :
"Error." ) << std::endl;
void beginBlock(const std::string &keyword="")
Aim: A model of CDigitalSurfaceContainer which defines the digital surface as the boundary of an impl...
MyDigitalSurface::ConstIterator ConstIterator
const Point & getLowerBound() const
const Point & getUpperBound() const
Aim: This class is useful to perform a depth-first exploration of a graph given a starting point or s...
Aim: Represent adjacencies between surfel elements, telling if it follows an interior to exterior ord...
Aim: Represents a set of n-1-cells in a nD space, together with adjacency relation between these cell...
BreadthFirstVisitor< MyDigitalSurface > Visitor
Aim: This class implement an Integral Invariant estimator which computes for each surfel the covarian...
ConstIterator begin() const
Aim: Implements basic operations that will be used in Point and Vector classes.
static SCell findABel(const KSpace &K, const PointPredicate &pp, unsigned int nbtries=1000)
void attach(const EuclideanShape &shape)
Aim: A functor Matrix -> std::pair<Real,Real> that returns the first and the second principal curvatu...
void init(const RealPoint &xLow, const RealPoint &xUp, typename RealVector::Component gridStep)
bool init(const Point &lower, const Point &upper, bool isClosed)
bool testGaussianCurvature3d(double h, double delta)
Aim: A class for computing the Gauss digitization of some Euclidean shape, i.e. its intersection with...
Aim: model of CEuclideanOrientedShape concepts to create a shape from a polynomial.
Aim: model of CEuclideanOrientedShape and CEuclideanBoundedShape concepts to create a ball in nD...
bool testPrincipalCurvatures3d(double h)
DGtal is the top-level namespace which contains all DGtal functions and types.
Aim: Transforms a graph visitor into a single pass input range.
Represents a signed cell in a cellular grid space by its Khalimsky coordinates and a boolean value...
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex...
DigitalSurface< MyDigitalSurfaceContainer > MyDigitalSurface
Aim: A functor Matrix -> Real that returns the Gaussian curvature by diagonalizing the given covarian...