DGtal  0.9.2
ReverseDistanceTransformation.h
1 
17 #pragma once
18 
34 #if defined(ReverseDistanceTransformation_RECURSES)
35 #error Recursive header files inclusion detected in ReverseDistanceTransformation.h
36 #else // defined(ReverseDistanceTransformation_RECURSES)
37 
38 #define ReverseDistanceTransformation_RECURSES
39 
40 #if !defined ReverseDistanceTransformation_h
41 
42 #define ReverseDistanceTransformation_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/geometry/volumes/distance/CPowerSeparableMetric.h"
51 #include "DGtal/geometry/volumes/distance/PowerMap.h"
52 #include "DGtal/images/DefaultConstImageRange.h"
53 #include "DGtal/kernel/domains/HyperRectDomain.h"
54 #include "DGtal/images/ImageContainerBySTLVector.h"
55 #include "DGtal/images/CImage.h"
56 #include "DGtal/base/ConstAlias.h"
58 
59 namespace DGtal
60 {
61 
63  // template class ReverseDistanceTransformation
87  template < typename TWeightImage,
88  typename TPSeparableMetric,
89  typename TImageContainer =
90  ImageContainerBySTLVector<HyperRectDomain<typename TWeightImage::Domain::Space>,
91  typename TWeightImage::Domain::Space::Vector> >
92  class ReverseDistanceTransformation: public PowerMap<TWeightImage,
93  TPSeparableMetric,
94  TImageContainer>
95  {
96 
97  public:
98 
100  typedef TWeightImage WeightImage;
101 
103  typedef TPSeparableMetric PowerSeparableMetric;
104 
106  typedef TImageContainer ImageContainer;
108 
110  typedef typename PowerSeparableMetric::Value Value;
111 
113  typedef typename TWeightImage::Domain::Space::Point Point;
114 
116  typedef typename TWeightImage::Domain::Space::Vector Vector;
117 
119  typedef typename PowerSeparableMetric::Weight Weight;
120 
122  typedef ReverseDistanceTransformation<TWeightImage,
123  TPSeparableMetric,
124  TImageContainer> Self;
125 
127 
130 
131 
133  typedef typename PowerMap<TWeightImage,TPSeparableMetric,
134  TImageContainer>::Domain Domain;
135 
136 
141  ConstAlias<WeightImage> aWeightImage,
143  PowerMap<TWeightImage,TPSeparableMetric,TImageContainer>(aDomain,
144  aWeightImage,
145  aMetric)
146  {}
147 
152 
153  // ------------------- Private functions ------------------------
154  public:
155 
160  const Domain & domain() const
161  {
162  return Parent::domain();
163  }
164 
169  ConstRange constRange() const
170  {
171  return ConstRange(*this);
172  }
173 
180  Value operator()(const Point &aPoint) const
181  {
182  return this->myMetricPtr->powerDistance(aPoint,
183  this->myImagePtr->operator()(aPoint),
184  this->myWeightImagePtr->operator()( this->myImagePtr->operator()(aPoint)));
185  }
186 
193  Vector getPowerVector(const Point &aPoint) const
194  {
195  return this->myImagePtr->operator()(aPoint);
196  }
197 
201  const PowerSeparableMetric* metricPtr() const
202  {
203  return Parent::metricPtr();
204  }
205 
211  void selfDisplay ( std::ostream & out ) const
212  {
213  out << "[ReverseDistanceTransformation] underlying PowerMap={";
214  Parent::selfDisplay(out);
215  out << "}";
216  }
217 
218  // ------------------- protected methods ------------------------
219  protected:
220 
226 
227 
228  // ------------------- Private members ------------------------
229  private:
230 
231  }; // end of class ReverseDistanceTransformation
232 
233 
234 // // //
235 // ///////////////////////////////////////////////////////////////////////////////
236 
237  template <typename W,typename TSep>
238  inline
239  std::ostream&
240  operator<< ( std::ostream & out,
242  {
243  object.selfDisplay( out );
244  return out;
245  }
246 
247 
248 
249 } // namespace DGtal
250 
251 // //
253 
254 #endif // !defined ReverseDistanceTransformation_h
255 
256 #undef ReverseDistanceTransformation_RECURSES
257 #endif // else defined(ReverseDistanceTransformation_RECURSES)
Aim: model of CConstBidirectionalRangeFromPoint that adapts the domain of an image in order to iterat...
const PowerSeparableMetric * metricPtr() const
Definition: PowerMap.h:215
PowerMap< TWeightImage, TPSeparableMetric > Parent
Aim: This class encapsulates its parameter class so that to indicate to the user that the object/poin...
Definition: ConstAlias.h:186
TPSeparableMetric PowerSeparableMetric
Separable Metric type.
void selfDisplay(std::ostream &out) const
TWeightImage::Domain::Space::Point Point
Point type.
Aim: Implementation of the linear in time reverse distance transformation for separable metrics...
ReverseDistanceTransformation(ConstAlias< Domain > aDomain, ConstAlias< WeightImage > aWeightImage, ConstAlias< PowerSeparableMetric > aMetric)
TWeightImage::Domain::Space::Vector Vector
Vector type.
CountedPtr< OutputImage > myImagePtr
Power map image.
Definition: PowerMap.h:295
const PowerSeparableMetric * metricPtr() const
std::ostream & operator<<(std::ostream &out, const ClosedIntegerHalfPlane< TSpace > &object)
Aim: Implementation of the linear in time Power map construction.
Definition: PowerMap.h:98
BOOST_CONCEPT_ASSERT((concepts::CImage< ImageContainer >))
const WeightImage * myWeightImagePtr
Pointer to the point predicate.
Definition: PowerMap.h:298
PowerMap< TWeightImage, TPSeparableMetric, TImageContainer >::Domain Domain
Definition of the image value type.
const Domain & domain() const
Definition: PowerMap.h:187
DGtal is the top-level namespace which contains all DGtal functions and types.
Value operator()(const Point &aPoint) const
ReverseDistanceTransformation< TWeightImage, TPSeparableMetric, TImageContainer > Self
Definition of the image.
DefaultConstImageRange< Self > ConstRange
Definition of the image constRange.
TWeightImage WeightImage
Separable Metric type.
const PowerSeparableMetric * myMetricPtr
Pointer to the separable metric instance.
Definition: PowerMap.h:292
TImageContainer ImageContainer
Image Container type.
Aim: Defines the concept describing a read/write image, having an output iterator.
Definition: CImage.h:102
PowerSeparableMetric::Value Value
Separable Metric type value type.
Vector getPowerVector(const Point &aPoint) const
PowerSeparableMetric::Weight Weight
Separable Metric type weight type.