DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
SetFromImage.h
1 
17 #pragma once
18 
31 #if defined(SetFromImage_RECURSES)
32 #error Recursive header files inclusion detected in SetFromImage.h
33 #else // defined(SetFromImage_RECURSES)
34 
35 #define SetFromImage_RECURSES
36 
37 #if !defined SetFromImage_h
38 
39 #define SetFromImage_h
40 
42 // Inclusions
43 #include <iostream>
44 #include "DGtal/base/Common.h"
45 #include "DGtal/images/CImage.h"
46 #include "DGtal/kernel/sets/CDigitalSet.h"
47 #include "DGtal/images/imagesSetsUtils/IntervalForegroundPredicate.h"
49 
50 namespace DGtal
51 {
52 
54  // template class SetFromImage
62  template <typename TSet>
63  struct SetFromImage
64  {
65  typedef TSet Set;
66 
67 
68  //BOOST_CONCEPT_ASSERT(( CDigitalSet<Set> ));
69 
70 
82  template<typename Image, typename ForegroundPredicate>
83  static
84  void append(Set &aSet,
85  const ForegroundPredicate &isForeground,
86  typename Image::Domain::ConstIterator itBegin,
87  typename Image::Domain::ConstIterator itEnd);
88 
102  template<typename Image>
103  static
104  void append(Set &aSet, const Image &aImage,
105  const typename Image::Value minVal,
106  const typename Image::Value maxVal,
107  typename Image::Domain::ConstIterator itBegin,
108  typename Image::Domain::ConstIterator itEnd)
109  {
110  IntervalForegroundPredicate<Image> isForeground(aImage,minVal,maxVal);
111 
112  append(aSet, isForeground,itBegin,itEnd);
113  }
114 
125  template<typename Image,typename ForegroundPredicate>
126  static
127  void append(Set &aSet, const Image &aImage, const ForegroundPredicate &isForeground)
128  {
129  typename Image::Domain domain=aImage.domain();
130 
131  append<Image,ForegroundPredicate>(aSet,isForeground,domain.begin(),domain.end());
132  }
133 
147  template<typename Image>
148  static
149  void append(Set &aSet, const Image &aImage,
150  const typename Image::Value minVal,
151  const typename Image::Value maxVal)
152  {
153  IntervalForegroundPredicate<Image> isForeground(aImage,minVal,maxVal);
154  append(aSet,aImage,isForeground);
155  }
156 
157  };
158 } // namespace DGtal
159 
160 
162 // Includes inline functions.
163 #include "DGtal/images/imagesSetsUtils/SetFromImage.ih"
164 
165 // //
167 
168 #endif // !defined SetFromImage_h
169 
170 #undef SetFromImage_RECURSES
171 #endif // else defined(SetFromImage_RECURSES)