DGtal  1.1.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)
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 
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)
DGtal::VoronoiMap::metric
const SeparableMetric * metric() const
Definition: VoronoiMap.h:293
DGtal::ConstAlias
Aim: This class encapsulates its parameter class so that to indicate to the user that the object/poin...
Definition: ConstAlias.h:187
DGtal::concepts::CSpace
Aim: Defines the concept describing a digital space, ie a cartesian product of integer lines.
Definition: CSpace.h:106
DGtal::VoronoiMap
Aim: Implementation of the linear in time Voronoi map construction.
Definition: VoronoiMap.h:127
DGtal::DistanceTransformation::Space
TSpace Space
Separable Metric type.
Definition: DistanceTransformation.h:111
DGtal::DistanceTransformation::BOOST_CONCEPT_ASSERT
BOOST_CONCEPT_ASSERT((concepts::CSeparableMetric< TSeparableMetric >))
DGtal::DistanceTransformation::DistanceTransformation
DistanceTransformation(ConstAlias< Domain > aDomain, ConstAlias< PointPredicate > predicate, ConstAlias< SeparableMetric > aMetric)
Definition: DistanceTransformation.h:145
DGtal::DistanceTransformation::DistanceTransformation
DistanceTransformation(ConstAlias< Domain > aDomain, ConstAlias< PointPredicate > predicate, ConstAlias< SeparableMetric > aMetric, typename Parent::PeriodicitySpec const &aPeriodicitySpec)
Definition: DistanceTransformation.h:158
aPoint
const Point aPoint(3, 4)
DGtal::VoronoiMap< TSpace, TPointPredicate, TSeparableMetric, ImageContainerBySTLVector< HyperRectDomain< TSpace >, typename TSpace::Vector > >::myMetricPtr
const SeparableMetric * myMetricPtr
Pointer to the separable metric instance.
Definition: VoronoiMap.h:406
DGtal::DistanceTransformation::domain
const Domain & domain() const
Definition: DistanceTransformation.h:180
DGtal::DistanceTransformation::PointPredicate
TPointPredicate PointPredicate
Point Predicate type.
Definition: DistanceTransformation.h:117
DGtal::DistanceTransformation::SeparableMetric
TSeparableMetric SeparableMetric
Separable Metric type.
Definition: DistanceTransformation.h:108
DGtal::VoronoiMap::domain
const Domain & domain() const
Definition: VoronoiMap.h:265
DGtal::DefaultConstImageRange
Aim: model of CConstBidirectionalRangeFromPoint that adapts the domain of an image in order to iterat...
Definition: DefaultConstImageRange.h:77
DGtal::DistanceTransformation::Value
SeparableMetric::Value Value
Definition of the image value type.
Definition: DistanceTransformation.h:120
DGtal::DistanceTransformation::Domain
VoronoiMap< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::Domain Domain
Definition of the image value type.
Definition: DistanceTransformation.h:138
DGtal::VoronoiMap< TSpace, TPointPredicate, TSeparableMetric, ImageContainerBySTLVector< HyperRectDomain< TSpace >, typename TSpace::Vector > >::myImagePtr
CountedPtr< OutputImage > myImagePtr
Voronoi map image.
Definition: VoronoiMap.h:409
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition: ClosedIntegerHalfPlane.h:49
DGtal::VoronoiMap::selfDisplay
void selfDisplay(std::ostream &out) const
DGtal::DistanceTransformation::DistanceTransformation
DistanceTransformation()
DGtal::DistanceTransformation::BOOST_CONCEPT_ASSERT
BOOST_CONCEPT_ASSERT((concepts::CSpace< TSpace >))
DGtal::VoronoiMap::PeriodicitySpec
std::array< bool, Space::dimension > PeriodicitySpec
Periodicity specification type.
Definition: VoronoiMap.h:187
DGtal::DistanceTransformation::~DistanceTransformation
~DistanceTransformation()
Definition: DistanceTransformation.h:171
DGtal::DistanceTransformation::ConstRange
DefaultConstImageRange< Self > ConstRange
Definition of the image constRange.
Definition: DistanceTransformation.h:133
DGtal::operator<<
std::ostream & operator<<(std::ostream &out, const ClosedIntegerHalfPlane< TSpace > &object)
DGtal::DistanceTransformation::metric
const SeparableMetric * metric() const
Definition: DistanceTransformation.h:220
Vector
FreemanChain< int >::Vector Vector
Definition: testCombinDSS.cpp:60
DGtal::DistanceTransformation::constRange
ConstRange constRange() const
Definition: DistanceTransformation.h:189
DGtal::DistanceTransformation::Parent
VoronoiMap< TSpace, TPointPredicate, TSeparableMetric > Parent
Definition: DistanceTransformation.h:130
DGtal::DistanceTransformation::getVoronoiVector
Vector getVoronoiVector(const Point &aPoint) const
Definition: DistanceTransformation.h:212
DGtal::DistanceTransformation::selfDisplay
void selfDisplay(std::ostream &out) const
Definition: DistanceTransformation.h:230
DGtal::PointVector< dim, Integer >
DGtal::DistanceTransformation::operator()
Value operator()(const Point &aPoint) const
Definition: DistanceTransformation.h:200
DGtal::DistanceTransformation::BOOST_STATIC_ASSERT
BOOST_STATIC_ASSERT((boost::is_same< typename Space::Point, typename SeparableMetric::Point >::value))
DGtal::concepts::CPointPredicate
Aim: Defines a predicate on a point.
Definition: CPointPredicate.h:81
DGtal::DistanceTransformation::Point
SeparableMetric::Point Point
Definition of the image value type.
Definition: DistanceTransformation.h:123
DGtal::DistanceTransformation
Aim: Implementation of the linear in time distance transformation for separable metrics.
Definition: DistanceTransformation.h:100
DGtal::DistanceTransformation::BOOST_CONCEPT_ASSERT
BOOST_CONCEPT_ASSERT((concepts::CPointPredicate< TPointPredicate >))
DGtal::DistanceTransformation::Self
DistanceTransformation< TSpace, TPointPredicate, TSeparableMetric > Self
Definition of the image.
Definition: DistanceTransformation.h:128
Point
MyPointD Point
Definition: testClone2.cpp:383
DGtal::concepts::CSeparableMetric
Aim: defines the concept of separable metrics.
Definition: CSeparableMetric.h:102
Value
double Value
Definition: testSimpleRandomAccessRangeFromPoint.cpp:38
DGtal::DistanceTransformation::Vector
TSpace::Vector Vector
Separable Metric type.
Definition: DistanceTransformation.h:114