DGtal  0.9.2
VoronoiCovarianceMeasure.h
1 
17 #pragma once
18 
31 #if defined(VoronoiCovarianceMeasure_RECURSES)
32 #error Recursive header files inclusion detected in VoronoiCovarianceMeasure.h
33 #else // defined(VoronoiCovarianceMeasure_RECURSES)
34 
35 #define VoronoiCovarianceMeasure_RECURSES
36 
37 #if !defined VoronoiCovarianceMeasure_h
38 
39 #define VoronoiCovarianceMeasure_h
40 
42 // Inclusions
43 #include <cmath>
44 #include <iostream>
45 #include "DGtal/base/Common.h"
46 #include "DGtal/math/BasicMathFunctions.h"
47 #include "DGtal/kernel/BasicPointPredicates.h"
48 #include "DGtal/kernel/domains/HyperRectDomain.h"
49 #include "DGtal/math/linalg/SimpleMatrix.h"
50 #include "DGtal/kernel/Point2ScalarFunctors.h"
51 #include "DGtal/images/ImageContainerBySTLVector.h"
52 #include "DGtal/geometry/volumes/distance/VoronoiMap.h"
53 #include "DGtal/geometry/tools/SpatialCubicalSubdivision.h"
55 
56 namespace DGtal
57 {
58 
60  // template class VoronoiCovarianceMeasure
78  template <typename TSpace, typename TSeparableMetric>
80  {
83 
84  public:
85  typedef TSpace Space;
86  typedef TSeparableMetric Metric;
87  typedef typename Space::Point Point;
88  typedef typename Space::Size Size;
89  typedef typename Space::Integer Integer;
93 
101  typedef typename Space::Point Point;
104  CharacteristicSetPredicate( const Self& other ) : ptrSet( other.ptrSet ) {}
105  Self& operator=( const Self& other ) { ptrSet = other.ptrSet; return *this; }
106  bool operator()( const Point& p ) const
107  {
108  ASSERT( ptrSet != 0 );
109  return (*ptrSet)( p );
110  }
111  private:
112  const CharacteristicSet* ptrSet;
113  };
116 
117  typedef double Scalar;
118  typedef DGtal::SimpleMatrix< Scalar,
120  Space::dimension > MatrixNN;
121  typedef typename MatrixNN::RowVector VectorN;
122  typedef std::vector<Point> PointContainer;
123  typedef std::map<Point,MatrixNN> Point2MatrixNN;
124 
125  // ----------------------- Standard services ------------------------------
126  public:
127 
143  VoronoiCovarianceMeasure( double _R, double _r, Metric aMetric = Metric(), bool verbose = false );
144 
149 
152  Scalar R() const;
155  Scalar r() const;
156 
161  void clean();
162 
172  template <typename PointInputIterator>
173  void init( PointInputIterator itb, PointInputIterator ite );
174 
176  const Domain& domain() const;
177 
180  const Voronoi& voronoiMap() const;
181 
185  const Point2MatrixNN& vcmMap() const;
186 
200  template <typename Point2ScalarFunction>
201  MatrixNN measure( Point2ScalarFunction chi_r, Point p ) const;
202 
203  // ----------------------- Interface --------------------------------------
204  public:
205 
210  void selfDisplay ( std::ostream & out ) const;
211 
216  bool isValid() const;
217 
218  // ------------------------- Protected Datas ------------------------------
219  private:
220  // ------------------------- Private Datas --------------------------------
221  private:
222 
224  double myBigR;
227  double mySmallR;
229  Metric myMetric;
231  bool myVerbose;
233  Domain myDomain;
235  CharacteristicSet* myCharSet;
237  Voronoi* myVoronoi;
239  Point2MatrixNN myVCM;
241  ProximityStructure* myProximityStructure;
242 
243  // ------------------------- Hidden services ------------------------------
244  protected:
245 
251 
252  private:
253 
260 
268 
269  // ------------------------- Internals ------------------------------------
270  private:
271 
272  }; // end of class VoronoiCovarianceMeasure
273 
274 
281  template <typename TSpace, typename TSeparableMetric>
282  std::ostream&
283  operator<< ( std::ostream & out,
285 
286 } // namespace DGtal
287 
288 
290 // Includes inline functions.
291 #include "DGtal/geometry/volumes/estimation/VoronoiCovarianceMeasure.ih"
292 
293 // //
295 
296 #endif // !defined VoronoiCovarianceMeasure_h
297 
298 #undef VoronoiCovarianceMeasure_RECURSES
299 #endif // else defined(VoronoiCovarianceMeasure_RECURSES)
Aim: The predicate returns true when the point predicate given at construction return false...
Aim: Implementation of the linear in time Voronoi map construction.
Definition: VoronoiMap.h:113
static const Dimension dimension
static constants to store the dimension.
Definition: SpaceND.h:132
void selfDisplay(std::ostream &out) const
DGtal::ImageContainerBySTLVector< Domain, bool > CharacteristicSet
the type of a binary image that is the characteristic function of K.
DGtal::SpatialCubicalSubdivision< Space > ProximityStructure
the structure used for proximity queries.
DGtal::functors::NotPointPredicate< CharacteristicSetPredicate > NotPredicate
the type of the point predicate used by the voronoi map.
Aim: This class encapsulates its parameter class so that to indicate to the user that the object/poin...
Definition: ConstAlias.h:186
bool myVerbose
Tells if it is verbose mode.
DGtal::VoronoiMap< Space, NotPredicate, Metric > Voronoi
the type of the Voronoi map.
MatrixNN measure(Point2ScalarFunction chi_r, Point p) const
Space::Point Point
the type of digital point
const Point2MatrixNN & vcmMap() const
Point2MatrixNN myVCM
The map point -> VCM.
CharacteristicSet * myCharSet
A binary image that defines the characteristic set of K.
Aim: implements basic MxN Matrix services (M,N>=1).
Definition: SimpleMatrix.h:75
const Domain & domain() const
Space::Size Size
the type for counting elements
DGtal::HyperRectDomain< Space > Domain
the type of rectangular domain of the VCM.
TSpace Space
the type of digital space
Space::Integer Integer
the type of each digital point coordinate, some integral type
TSeparableMetric Metric
the type of metric
VoronoiCovarianceMeasure & operator=(const VoronoiCovarianceMeasure &other)
Aim: Defines the concept describing a digital space, ie a cartesian product of integer lines...
Definition: CSpace.h:105
std::ostream & operator<<(std::ostream &out, const ClosedIntegerHalfPlane< TSpace > &object)
Aim: This class precomputes the Voronoi Covariance Measure of a set of points. It can compute the cov...
Aim: This class is a data structure that subdivides a rectangular domains into cubical domains of siz...
TInteger Integer
Arithmetic ring induced by (+,-,*) and Integer numbers.
Definition: SpaceND.h:102
MatrixNN::RowVector VectorN
the type for N-vector of real numbers
const Voronoi & voronoiMap() const
DGtal is the top-level namespace which contains all DGtal functions and types.
Aim: defines the concept of separable metrics.
UnsignedInteger Size
Type used to represent sizes in the digital space.
Definition: SpaceND.h:107
double Scalar
the type for "real" numbers.
std::map< Point, MatrixNN > Point2MatrixNN
Associates a matrix to points.
void init(PointInputIterator itb, PointInputIterator ite)
DGtal::SimpleMatrix< Scalar, Space::dimension, Space::dimension > MatrixNN
the type for nxn matrix of real numbers.
Metric myMetric
The metric chosen for the Voronoi map.
Domain myDomain
The domain in which all computations are done.
Voronoi * myVoronoi
Stores the voronoi map.
double myBigR
The parameter R in the VCM, i.e. the offset radius for the compact set K.
std::vector< Point > PointContainer
the list of points
BOOST_CONCEPT_ASSERT((concepts::CSpace< TSpace >))
ProximityStructure * myProximityStructure
The structure used for proximity queries.