DGtal  0.9.2
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)
37 
38 #define DistanceTransformation_RECURSES
39 
40 #if !defined DistanceTransformation_h
41 
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  >
98  class DistanceTransformation: public VoronoiMap<TSpace,TPointPredicate,
99  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 
145  ConstAlias<PointPredicate> predicate,
147  VoronoiMap<TSpace,TPointPredicate,TSeparableMetric,TImageContainer>(aDomain,
148  predicate,
149  aMetric)
150  {}
151 
156 
157  // ------------------- Private functions ------------------------
158  public:
159 
164  const Domain & domain() const
165  {
166  return Parent::domain();
167  }
168 
173  ConstRange constRange() const
174  {
175  return ConstRange(*this);
176  }
177 
184  Value operator()(const Point &aPoint) const
185  {
186  return this->myMetricPtr->operator()(aPoint,
187  this->myImagePtr->operator()(aPoint));
188  }
189 
196  Vector getVoronoiVector(const Point &aPoint) const
197  {
198  return this->myImagePtr->operator()(aPoint);
199  }
200 
204  const SeparableMetric* metric() const
205  {
206  return Parent::metric();
207  }
208 
214  void selfDisplay ( std::ostream & out ) const
215  {
216  out << "[DistanceTransformation] underlying VoronoiMap={";
217  Parent::selfDisplay(out);
218  out << "}";
219  }
220 
221  // ------------------- protected methods ------------------------
222  protected:
223 
229 
230 
231  // ------------------- Private members ------------------------
232  private:
233 
234  }; // end of class DistanceTransformation
235 
236 
237 // // //
238 // ///////////////////////////////////////////////////////////////////////////////
239 
240  template <typename S,typename P,typename TSep>
241  inline
242  std::ostream&
243  operator<< ( std::ostream & out,
244  const DistanceTransformation<S,P,TSep> & object )
245  {
246  object.selfDisplay( out );
247  return out;
248  }
249 
250 
251 
252 } // namespace DGtal
253 
254 // //
256 
257 #endif // !defined DistanceTransformation_h
258 
259 #undef DistanceTransformation_RECURSES
260 #endif // else defined(DistanceTransformation_RECURSES)
Vector getVoronoiVector(const Point &aPoint) const
BOOST_CONCEPT_ASSERT((concepts::CSpace< TSpace >))
Aim: Implementation of the linear in time Voronoi map construction.
Definition: VoronoiMap.h:113
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.
TSpace::Vector Vector
Separable Metric type.
Aim: This class encapsulates its parameter class so that to indicate to the user that the object/poin...
Definition: ConstAlias.h:186
SeparableMetric::Point Point
Definition of the image value type.
const SeparableMetric * metric() const
Definition: VoronoiMap.h:242
VoronoiMap< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::Domain Domain
Definition of the image value type.
DistanceTransformation< TSpace, TPointPredicate, TSeparableMetric > Self
Definition of the image.
const SeparableMetric * myMetricPtr
Pointer to the separable metric instance.
Definition: VoronoiMap.h:315
TSeparableMetric SeparableMetric
Separable Metric type.
const SeparableMetric * metric() const
TSpace Space
Separable Metric type.
Aim: Defines a predicate on a point.
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)
DefaultConstImageRange< Self > ConstRange
Definition of the image constRange.
DGtal is the top-level namespace which contains all DGtal functions and types.
Aim: defines the concept of separable metrics.
void selfDisplay(std::ostream &out) const
void selfDisplay(std::ostream &out) const
const Domain & domain() const
Definition: VoronoiMap.h:213
CountedPtr< OutputImage > myImagePtr
Voronoi map image.
Definition: VoronoiMap.h:318
PointVector< dim, Integer > Point
Points in DGtal::SpaceND.
Definition: SpaceND.h:110
VoronoiMap< TSpace, TPointPredicate, TSeparableMetric > Parent
BOOST_STATIC_ASSERT((boost::is_same< typename Space::Point, typename SeparableMetric::Point >::value))
Value operator()(const Point &aPoint) const
SeparableMetric::Value Value
Definition of the image value type.
DistanceTransformation(ConstAlias< Domain > aDomain, ConstAlias< PointPredicate > predicate, ConstAlias< SeparableMetric > aMetric)