DGtal  1.4.beta
DistanceTransformation.h
1 
17 #pragma once
18 
34 #if defined(DistanceTransformation_RECURSES)
35 #error Recursive header files inclusion detected in DistanceTransformation.h
36 #else // defined(DistanceTransformation_RECURSES)
38 #define DistanceTransformation_RECURSES
39 
40 #if !defined DistanceTransformation_h
42 #define DistanceTransformation_h
43 
45 // Inclusions
46 #include <iostream>
47 #include <vector>
48 #include "DGtal/kernel/NumberTraits.h"
49 #include "DGtal/kernel/CPointPredicate.h"
50 #include "DGtal/geometry/volumes/distance/CSeparableMetric.h"
51 #include "DGtal/geometry/volumes/distance/VoronoiMap.h"
52 #include "DGtal/images/DefaultConstImageRange.h"
53 #include "DGtal/kernel/domains/HyperRectDomain.h"
54 #include "DGtal/base/ConstAlias.h"
56 
57 namespace DGtal
58 {
59 
61  // template class DistanceTransformation
90  template < typename TSpace,
91  typename TPointPredicate,
92  typename TSeparableMetric,
93  typename TImageContainer =
94  ImageContainerBySTLVector< HyperRectDomain<TSpace>,
95  typename TSpace::Vector >
96  >
98  : public VoronoiMap<TSpace,TPointPredicate, TSeparableMetric, TImageContainer>
99  {
100 
101  public:
105 
107  typedef TSeparableMetric SeparableMetric;
108 
110  typedef TSpace Space;
111 
113  typedef typename TSpace::Vector Vector;
114 
116  typedef TPointPredicate PointPredicate;
117 
119  typedef typename SeparableMetric::Value Value;
120 
122  typedef typename SeparableMetric::Point Point;
123  BOOST_STATIC_ASSERT((boost::is_same< typename Space::Point,
124  typename SeparableMetric::Point>::value));
125 
128 
130 
133 
134 
136  typedef typename VoronoiMap<TSpace,TPointPredicate,
137  TSeparableMetric,TImageContainer>::Domain Domain;
138 
145  ConstAlias<PointPredicate> predicate,
147  VoronoiMap<TSpace,TPointPredicate,TSeparableMetric,TImageContainer>(aDomain,
148  predicate,
149  aMetric)
150  {}
151 
158  ConstAlias<PointPredicate> predicate,
160  typename Parent::PeriodicitySpec const & aPeriodicitySpec)
161  : VoronoiMap<TSpace,TPointPredicate,TSeparableMetric,TImageContainer>(aDomain,
162  predicate,
163  aMetric,
164  aPeriodicitySpec)
165  {}
166 
171 
172  // ------------------- Private functions ------------------------
173  public:
174 
179  const Domain & domain() const
180  {
181  return Parent::domain();
182  }
183 
189  {
190  return ConstRange(*this);
191  }
192 
199  Value operator()(const Point &aPoint) const
200  {
201  return this->myMetricPtr->operator()(aPoint,
202  this->myImagePtr->operator()(aPoint));
203  }
204 
211  Vector getVoronoiSite(const Point &aPoint) const
212  {
213  return this->myImagePtr->operator()(aPoint);
214  }
215 
219  const SeparableMetric* metric() const
220  {
221  return Parent::metric();
222  }
223 
229  void selfDisplay ( std::ostream & out ) const
230  {
231  out << "[DistanceTransformation] underlying VoronoiMap={";
232  Parent::selfDisplay(out);
233  out << "}";
234  }
235 
236  // ------------------- protected methods ------------------------
237  protected:
238 
244 
245 
246  // ------------------- Private members ------------------------
247  private:
248 
249  }; // end of class DistanceTransformation
250 
251 
252 // // //
253 // ///////////////////////////////////////////////////////////////////////////////
254 
255  template <typename S,typename P,typename TSep>
256  inline
257  std::ostream&
258  operator<< ( std::ostream & out,
259  const DistanceTransformation<S,P,TSep> & object )
260  {
261  object.selfDisplay( out );
262  return out;
263  }
264 
265 
266 
267 } // namespace DGtal
268 
269 // //
271 
272 #endif // !defined DistanceTransformation_h
273 
274 #undef DistanceTransformation_RECURSES
275 #endif // else defined(DistanceTransformation_RECURSES)
Aim: This class encapsulates its parameter class so that to indicate to the user that the object/poin...
Definition: ConstAlias.h:187
Aim: model of CConstBidirectionalRangeFromPoint that adapts the domain of an image in order to iterat...
Aim: Implementation of the linear in time distance transformation for separable metrics.
TPointPredicate PointPredicate
Point Predicate type.
DistanceTransformation< TSpace, TPointPredicate, TSeparableMetric > Self
Definition of the image.
VoronoiMap< TSpace, TPointPredicate, TSeparableMetric > Parent
TSpace Space
Separable Metric type.
const SeparableMetric * metric() const
Vector getVoronoiSite(const Point &aPoint) const
VoronoiMap< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::Domain Domain
Definition of the image value type.
TSeparableMetric SeparableMetric
Separable Metric type.
BOOST_CONCEPT_ASSERT((concepts::CPointPredicate< TPointPredicate >))
Value operator()(const Point &aPoint) const
TSpace::Vector Vector
Separable Metric type.
DistanceTransformation(ConstAlias< Domain > aDomain, ConstAlias< PointPredicate > predicate, ConstAlias< SeparableMetric > aMetric)
DefaultConstImageRange< Self > ConstRange
Definition of the image constRange.
SeparableMetric::Point Point
Definition of the image value type.
DistanceTransformation(ConstAlias< Domain > aDomain, ConstAlias< PointPredicate > predicate, ConstAlias< SeparableMetric > aMetric, typename Parent::PeriodicitySpec const &aPeriodicitySpec)
void selfDisplay(std::ostream &out) const
SeparableMetric::Value Value
Definition of the image value type.
BOOST_CONCEPT_ASSERT((concepts::CSeparableMetric< TSeparableMetric >))
BOOST_STATIC_ASSERT((boost::is_same< typename Space::Point, typename SeparableMetric::Point >::value))
BOOST_CONCEPT_ASSERT((concepts::CSpace< TSpace >))
Aim: Implementation of the linear in time Voronoi map construction.
Definition: VoronoiMap.h:127
std::array< bool, Space::dimension > PeriodicitySpec
Periodicity specification type.
Definition: VoronoiMap.h:187
void selfDisplay(std::ostream &out) const
const SeparableMetric * metric() const
Definition: VoronoiMap.h:293
const Domain & domain() const
Definition: VoronoiMap.h:265
DigitalPlane::Point Vector
DGtal is the top-level namespace which contains all DGtal functions and types.
std::ostream & operator<<(std::ostream &out, const ATu0v1< TKSpace, TLinearAlgebra > &object)
Aim: Defines a predicate on a point.
Aim: defines the concept of separable metrics.
Aim: Defines the concept describing a digital space, ie a cartesian product of integer lines.
Definition: CSpace.h:106
MyPointD Point
Definition: testClone2.cpp:383
const Point aPoint(3, 4)
ImageContainerBySTLVector< HyperRectDomain< Z2i::Space >, std::unordered_set< Z2i::Point > > TImageContainer