DGtal  1.0.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)
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  >
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 
189  ConstRange constRange() const
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)
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:126
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:293
VoronoiMap< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::Domain Domain
Definition of the image value type.
std::ostream & operator<<(std::ostream &out, const ATu0v1< TKSpace, TLinearAlgebra > &object)
DistanceTransformation< TSpace, TPointPredicate, TSeparableMetric > Self
Definition of the image.
const SeparableMetric * myMetricPtr
Pointer to the separable metric instance.
Definition: VoronoiMap.h:406
TSeparableMetric SeparableMetric
Separable Metric type.
const SeparableMetric * metric() const
TSpace Space
Separable Metric type.
DistanceTransformation(ConstAlias< Domain > aDomain, ConstAlias< PointPredicate > predicate, ConstAlias< SeparableMetric > aMetric, typename Parent::PeriodicitySpec const &aPeriodicitySpec)
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
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:265
CountedPtr< OutputImage > myImagePtr
Voronoi map image.
Definition: VoronoiMap.h:409
std::array< bool, Space::dimension > PeriodicitySpec
Periodicity specification type.
Definition: VoronoiMap.h:187
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)