DGtal  0.9.2
IntegralInvariantCovarianceEstimator.h
1 
17 #pragma once
18 
34 #if defined(IntegralInvariantCovarianceEstimator_RECURSES)
35 #error Recursive header files inclusion detected in IntegralInvariantCovarianceEstimator.h
36 #else // defined(IntegralInvariantCovarianceEstimator_RECURSES)
37 
38 #define IntegralInvariantCovarianceEstimator_RECURSES
39 
40 #if !defined IntegralInvariantCovarianceEstimator_h
41 
42 #define IntegralInvariantCovarianceEstimator_h
43 
45 // Inclusions
46 #include <iostream>
47 #include "DGtal/base/Common.h"
48 
49 #include "DGtal/kernel/CPointPredicate.h"
50 #include "DGtal/kernel/BasicPointFunctors.h"
51 #include "DGtal/topology/CCellFunctor.h"
52 #include "DGtal/topology/CCellularGridSpaceND.h"
53 #include "DGtal/geometry/surfaces/FunctorOnCells.h"
54 
55 #include "DGtal/shapes/GaussDigitizer.h"
56 #include "DGtal/shapes/Shapes.h"
57 
58 #include "DGtal/geometry/surfaces/DigitalSurfaceConvolver.h"
59 #include "DGtal/geometry/surfaces/estimation/IIGeometricFunctors.h"
60 #include "DGtal/shapes/EuclideanShapesDecorator.h"
61 
62 #include "DGtal/shapes/implicit/ImplicitBall.h"
64 
65 
66 namespace DGtal
67 {
68 
70 // template class IntegralInvariantCovarianceEstimator
114 template <typename TKSpace, typename TPointPredicate, typename TCovarianceMatrixFunctor>
116 {
117 public:
119  typedef TKSpace KSpace;
120  typedef TPointPredicate PointPredicate;
121  typedef TCovarianceMatrixFunctor CovarianceMatrixFunctor;
122 
125 
126  typedef typename KSpace::Space Space;
128  typedef typename Space::Point Point;
129  typedef typename Space::RealPoint RealPoint;
130  typedef typename Space::RealVector RealVector;
132  typedef typename KSpace::SCell Spel;
133  typedef typename KSpace::Surfel Surfel;
134  typedef typename KSpace::SurfelSet SurfelSet;
135  typedef typename SurfelSet::const_iterator ConstIteratorKernel;
136 
138  typedef typename CovarianceMatrixFunctor::Quantity Quantity;
140  typedef int Value;
141 
148 
149 
155 
157  KSpace, DigitalShapeKernel> Convolver;
160  typedef typename Matrix::Component Component;
161  typedef double Scalar;
165  typename CovarianceMatrixFunctor::Argument >::value ));
166 
167 
168  // ----------------------- Standard services ------------------------------
169 public:
170 
178  IntegralInvariantCovarianceEstimator( CovarianceMatrixFunctor fct = CovarianceMatrixFunctor() );
179 
190  ConstAlias< PointPredicate > aPointPredicate,
191  CovarianceMatrixFunctor fct = CovarianceMatrixFunctor() );
192 
197 
202  IntegralInvariantCovarianceEstimator ( const Self& other );
203 
209  Self& operator= ( const Self& other );
210 
214  void clear();
215 
216  // ----------------------- Interface --------------------------------------
217 public:
218 
220  Scalar h() const;
221 
229  void attach( ConstAlias< KSpace > K,
230  ConstAlias<PointPredicate> aPointPredicate );
231 
237  void setParams( const double dRadius );
238 
247  template <typename SurfelConstIterator>
248  void init( const double _h, SurfelConstIterator itb, SurfelConstIterator ite );
249 
264  template< typename SurfelConstIterator >
265  Quantity eval ( SurfelConstIterator it ) const;
266 
267 
288  template <typename OutputIterator, typename SurfelConstIterator>
289  OutputIterator eval( SurfelConstIterator itb,
290  SurfelConstIterator ite,
291  OutputIterator result ) const;
292 
297  void selfDisplay ( std::ostream & out ) const;
298 
303  bool isValid() const;
304 
305  // ------------------------- Private Datas --------------------------------
306 private:
307 
308  CovarianceMatrixFunctor myFct;
309  const KernelSpelFunctor myKernelFunctor;
310  std::vector< PairIterators > myKernels;
311  std::vector< DigitalSet * > myKernelsSet;
319  Scalar myH;
320  Scalar myRadius;
321 
322 private:
323 
324 
325 }; // end of class IntegralInvariantCovarianceEstimator
326 
333  template <typename TKSpace, typename TPointPredicate, typename TCovarianceMatrixFunctor>
334  std::ostream&
335  operator<< ( std::ostream & out,
337 
338 } // namespace DGtal
339 
340 
342 // Includes inline functions.
343 #include "DGtal/geometry/surfaces/estimation/IntegralInvariantCovarianceEstimator.ih"
344 
345 // //
347 
348 #endif // !defined IntegralInvariantCovarianceEstimator_h
349 
350 #undef IntegralInvariantCovarianceEstimator_RECURSES
351 #endif // else defined(IntegralInvariantCovarianceEstimator_RECURSES)
BOOST_STATIC_ASSERT((concepts::ConceptUtils::SameType< typename Convolver::CovarianceMatrix, typename CovarianceMatrixFunctor::Argument >::value))
IntegralInvariantCovarianceEstimator< TKSpace, TPointPredicate, TCovarianceMatrixFunctor > Self
CovarianceMatrixFunctor::Quantity Quantity
The returned type of the estimator, depends on the functor.
std::pair< KernelConstIterator, KernelConstIterator > PairIterators
Aim: Smart pointer based on reference counts.
Definition: CountedPtr.h:79
Aim: This class encapsulates its parameter class so that to indicate to the user that the object/poin...
Definition: ConstAlias.h:186
Aim: Defines a functor on cells.
Definition: CCellFunctor.h:89
CountedConstPtrOrConstPtr< PointPredicate > myPointPredicate
Smart pointer (if required) on a point predicate.
Quantity eval(SurfelConstIterator it) const
Scalar myRadius
"digital" radius of the kernel (but may be non integer).
const KernelSpelFunctor myKernelFunctor
Kernel functor (on Spel)
BOOST_CONCEPT_ASSERT((concepts::CCellularGridSpaceND< KSpace >))
std::vector< PairIterators > myKernels
array of begin/end iterator of shifting masks.
void selfDisplay(std::ostream &out) const
FunctorOnCells< ShapePointFunctor, KSpace > ShapeSpelFunctor
Aim: This class implement an Integral Invariant estimator which computes for each surfel the covarian...
IntegralInvariantCovarianceEstimator(CovarianceMatrixFunctor fct=CovarianceMatrixFunctor())
Aim: Defines a unary functor, which associates arguments to results.
Definition: CUnaryFunctor.h:89
void attach(ConstAlias< KSpace > K, ConstAlias< PointPredicate > aPointPredicate)
Aim: implements basic MxN Matrix services (M,N>=1).
Definition: SimpleMatrix.h:75
void setParams(const double dRadius)
Aim: Convert a functor on Digital Point to a Functor on Khalimsky Cell.
std::vector< DigitalSet * > myKernelsSet
Array of shifting masks. Size = 9 for each shifting (0-adjacent and full kernel included) ...
void init(const double _h, SurfelConstIterator itb, SurfelConstIterator ite)
TComponent Component
Definition: SimpleMatrix.h:79
functors::PointFunctorFromPointPredicateAndDomain< PointPredicate, Domain, unsigned int > ShapePointFunctor
Aim: Constructive Solid Geometry (CSG) between models of CEuclideanBoundedShape and CEuclideanOriente...
Aim: Defines a predicate on a point.
DigitalSetSelector< Domain, BIG_DS+HIGH_VAR_DS >::Type DigitalSet
Create a point functor from a point predicate and a domain.
Aim: A class for computing the Gauss digitization of some Euclidean shape, i.e. its intersection with...
std::ostream & operator<<(std::ostream &out, const ClosedIntegerHalfPlane< TSpace > &object)
CountedPtr< DigitalShapeKernel > myDigKernel
Digital kernel.
CovarianceMatrixFunctor myFct
The covariance matrix functor that transforms the II covariance matrix into a quantity.
Aim: model of CEuclideanOrientedShape and CEuclideanBoundedShape concepts to create a ball in nD...
Definition: ImplicitBall.h:64
CountedPtr< Domain > myShapeDomain
Smart pointer on domain.
DGtal is the top-level namespace which contains all DGtal functions and types.
Aim: A wrapper class around a STL associative container for storing sets of digital points within som...
CountedPtr< ShapeSpelFunctor > myShapeSpelFunctor
Smart pointer on functor spel -> {0,1}.
DigitalSurfaceConvolver< ShapeSpelFunctor, KernelSpelFunctor, KSpace, DigitalShapeKernel > Convolver
CountedPtr< ShapePointFunctor > myShapePointFunctor
Smart pointer on functor point -> {0,1}.
Aim: This concept describes a cellular grid space in nD. In these spaces obtained by cartesian produc...
Aim: Define a simple functor that returns a constant quantity (0 by default).
CountedPtr< KernelSupport > myKernel
Euclidean kernel.
EuclideanShapesCSG< KernelSupport, KernelSupport > EuclideanMinus