DGtal  1.2.0
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/base/Common.h"
49 #include "DGtal/kernel/NumberTraits.h"
50 #include "DGtal/kernel/CPointPredicate.h"
51 #include "DGtal/geometry/volumes/distance/CSeparableMetric.h"
52 #include "DGtal/geometry/volumes/distance/VoronoiMap.h"
53 #include "DGtal/images/DefaultConstImageRange.h"
54 #include "DGtal/kernel/domains/HyperRectDomain.h"
55 #include "DGtal/base/ConstAlias.h"
57 
58 namespace DGtal
59 {
60 
62  // template class DistanceTransformation
91  template < typename TSpace,
92  typename TPointPredicate,
93  typename TSeparableMetric,
94  typename TImageContainer =
95  ImageContainerBySTLVector< HyperRectDomain<TSpace>,
96  typename TSpace::Vector >
97  >
99  : public VoronoiMap<TSpace,TPointPredicate, TSeparableMetric, TImageContainer>
100  {
101 
102  public:
106 
108  typedef TSeparableMetric SeparableMetric;
109 
111  typedef TSpace Space;
112 
114  typedef typename TSpace::Vector Vector;
115 
117  typedef TPointPredicate PointPredicate;
118 
120  typedef typename SeparableMetric::Value Value;
121 
123  typedef typename SeparableMetric::Point Point;
124  BOOST_STATIC_ASSERT((boost::is_same< typename Space::Point,
125  typename SeparableMetric::Point>::value));
126 
129 
131 
134 
135 
137  typedef typename VoronoiMap<TSpace,TPointPredicate,
138  TSeparableMetric,TImageContainer>::Domain Domain;
139 
146  ConstAlias<PointPredicate> predicate,
148  VoronoiMap<TSpace,TPointPredicate,TSeparableMetric,TImageContainer>(aDomain,
149  predicate,
150  aMetric)
151  {}
152 
159  ConstAlias<PointPredicate> predicate,
161  typename Parent::PeriodicitySpec const & aPeriodicitySpec)
162  : VoronoiMap<TSpace,TPointPredicate,TSeparableMetric,TImageContainer>(aDomain,
163  predicate,
164  aMetric,
165  aPeriodicitySpec)
166  {}
167 
172 
173  // ------------------- Private functions ------------------------
174  public:
175 
180  const Domain & domain() const
181  {
182  return Parent::domain();
183  }
184 
190  {
191  return ConstRange(*this);
192  }
193 
200  Value operator()(const Point &aPoint) const
201  {
202  return this->myMetricPtr->operator()(aPoint,
203  this->myImagePtr->operator()(aPoint));
204  }
205 
212  Vector getVoronoiVector(const Point &aPoint) const
213  {
214  return this->myImagePtr->operator()(aPoint);
215  }
216 
220  const SeparableMetric* metric() const
221  {
222  return Parent::metric();
223  }
224 
230  void selfDisplay ( std::ostream & out ) const
231  {
232  out << "[DistanceTransformation] underlying VoronoiMap={";
233  Parent::selfDisplay(out);
234  out << "}";
235  }
236 
237  // ------------------- protected methods ------------------------
238  protected:
239 
245 
246 
247  // ------------------- Private members ------------------------
248  private:
249 
250  }; // end of class DistanceTransformation
251 
252 
253 // // //
254 // ///////////////////////////////////////////////////////////////////////////////
255 
256  template <typename S,typename P,typename TSep>
257  inline
258  std::ostream&
259  operator<< ( std::ostream & out,
260  const DistanceTransformation<S,P,TSep> & object )
261  {
262  object.selfDisplay( out );
263  return out;
264  }
265 
266 
267 
268 } // namespace DGtal
269 
270 // //
272 
273 #endif // !defined DistanceTransformation_h
274 
275 #undef DistanceTransformation_RECURSES
276 #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
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
Vector getVoronoiVector(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
DGtal is the top-level namespace which contains all DGtal functions and types.
std::ostream & operator<<(std::ostream &out, const ClosedIntegerHalfPlane< TSpace > &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
FreemanChain< int >::Vector Vector
const Point aPoint(3, 4)