DGtal  0.9.4beta
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  >
94  : public PowerMap<TWeightImage, TPSeparableMetric, 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 
143  ConstAlias<WeightImage> aWeightImage,
145  PowerMap<TWeightImage,TPSeparableMetric,TImageContainer>(aDomain,
146  aWeightImage,
147  aMetric)
148  {}
149 
156  ConstAlias<WeightImage> aWeightImage,
158  typename Parent::PeriodicitySpec const & aPeriodicitySpec)
159  : PowerMap<TWeightImage,TPSeparableMetric,TImageContainer>(aDomain,
160  aWeightImage,
161  aMetric,
162  aPeriodicitySpec)
163  {}
164 
169 
170  // ------------------- Private functions ------------------------
171  public:
172 
177  const Domain & domain() const
178  {
179  return Parent::domain();
180  }
181 
186  ConstRange constRange() const
187  {
188  return ConstRange(*this);
189  }
190 
197  Value operator()(const Point &aPoint) const
198  {
199  return this->myMetricPtr->powerDistance(aPoint,
200  this->myImagePtr->operator()(aPoint),
201  this->myWeightImagePtr->operator()( this->myImagePtr->operator()(aPoint)));
202  }
203 
210  Vector getPowerVector(const Point &aPoint) const
211  {
212  return this->myImagePtr->operator()(aPoint);
213  }
214 
218  const PowerSeparableMetric* metricPtr() const
219  {
220  return Parent::metricPtr();
221  }
222 
228  void selfDisplay ( std::ostream & out ) const
229  {
230  out << "[ReverseDistanceTransformation] underlying PowerMap={";
231  Parent::selfDisplay(out);
232  out << "}";
233  }
234 
235  // ------------------- protected methods ------------------------
236  protected:
237 
243 
244 
245  // ------------------- Private members ------------------------
246  private:
247 
248  }; // end of class ReverseDistanceTransformation
249 
250 
251 // // //
252 // ///////////////////////////////////////////////////////////////////////////////
253 
254  template <typename W,typename TSep>
255  inline
256  std::ostream&
257  operator<< ( std::ostream & out,
259  {
260  object.selfDisplay( out );
261  return out;
262  }
263 
264 
265 
266 } // namespace DGtal
267 
268 // //
270 
271 #endif // !defined ReverseDistanceTransformation_h
272 
273 #undef ReverseDistanceTransformation_RECURSES
274 #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:263
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
std::array< bool, Space::dimension > PeriodicitySpec
Periodicity specification type.
Definition: PowerMap.h:159
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:404
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:110
BOOST_CONCEPT_ASSERT((concepts::CImage< ImageContainer >))
const WeightImage * myWeightImagePtr
Pointer to the point predicate.
Definition: PowerMap.h:407
const Domain & domain() const
Definition: PowerMap.h:235
DGtal is the top-level namespace which contains all DGtal functions and types.
PowerMap< TWeightImage, TPSeparableMetric, TImageContainer >::Domain Domain
Definition of the image value type.
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:401
ReverseDistanceTransformation(ConstAlias< Domain > aDomain, ConstAlias< WeightImage > aWeightImage, ConstAlias< PowerSeparableMetric > aMetric, typename Parent::PeriodicitySpec const &aPeriodicitySpec)
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.