DGtal  1.5.beta
ReducedMedialAxis.h
1 
17 #pragma once
18 
34 #if defined(ReducedMedialAxis_RECURSES)
35 #error Recursive header files inclusion detected in ReducedMedialAxis.h
36 #else // defined(ReducedMedialAxis_RECURSES)
38 #define ReducedMedialAxis_RECURSES
39 
40 #if !defined ReducedMedialAxis_h
42 #define ReducedMedialAxis_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/ImageContainerBySTLMap.h"
55 #include "DGtal/images/CImage.h"
56 #include "DGtal/images/Image.h"
58 
59 namespace DGtal
60 {
61 
63  // template class ReducedMedialAxis
94  template <typename TPowerMap,
95  typename TImageContainer = ImageContainerBySTLMap<typename TPowerMap::Domain,
98  {
99  //MA Container
101 
111  static
112  Type getReducedMedialAxisFromPowerMap(const TPowerMap &aPowerMap)
113  {
114  TImageContainer *computedMA = new TImageContainer( aPowerMap.domain() );
115 
116  for (typename TPowerMap::Domain::ConstIterator it = aPowerMap.domain().begin(),
117  itend = aPowerMap.domain().end(); it != itend; ++it)
118  {
119  const auto v = aPowerMap( *it );
120  const auto pv = aPowerMap.projectPoint( v );
121 
122  if ( aPowerMap.metricPtr()->powerDistance( *it, v, aPowerMap.weightImagePtr()->operator()( pv ) )
124  computedMA->setValue( v, aPowerMap.weightImagePtr()->operator()( pv ) );
125  }
126 
127  return Type( computedMA );
128  }
129  }; // end of class ReducedMedialAxis
130 
131 
132 
133 } // namespace DGtal
134 
135 // //
137 
138 #endif // !defined ReducedMedialAxis_h
139 
140 #undef ReducedMedialAxis_RECURSES
141 #endif // else defined(ReducedMedialAxisdesign pa_RECURSES)
void setValue(const Point &aPoint, const Value &aValue)
Aim: implements association bewteen points lying in a digital domain and values.
Definition: Image.h:70
MyDigitalSurface::ConstIterator ConstIterator
DGtal is the top-level namespace which contains all DGtal functions and types.
Aim: The traits class for all models of Cinteger.
Definition: NumberTraits.h:564
Aim: Implementation of the separable medial axis extraction.
static Type getReducedMedialAxisFromPowerMap(const TPowerMap &aPowerMap)
Image< TImageContainer > Type
HyperRectDomain< Space > Domain
ImageContainerBySTLVector< HyperRectDomain< Z2i::Space >, std::unordered_set< Z2i::Point > > TImageContainer