IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
ExtremaUtils.h
Go to the documentation of this file.
1 // ExtremaUtils.h:
3 // ---------------
4 //
14 
15 #ifndef __IPSDKMATH_EXTREMAUTILS_H__
16 #define __IPSDKMATH_EXTREMAUTILS_H__
17 
20 #include <boost/bind.hpp>
21 #include <boost/function.hpp>
22 
23 namespace ipsdk {
24 namespace math {
25 
28 
32 template <typename T,
33  typename IndexType>
34 IPSDKMATH_API void
35 findLocalStrictExtrema(const std::vector<T>& inputColl,
36  const eExtremaBorderPolicy& extremaBorderPolicy,
37  const eExtremaType& extremaType,
38  std::vector<IndexType>& extremaIdxColl);
39 
46 template <typename T,
47  typename IndexType>
48 void
49 findLocalStrictMinima(const std::vector<T>& inputColl,
50  const eExtremaBorderPolicy& extremaBorderPolicy,
51  std::vector<IndexType>& extremaIdxColl)
52 {
53  findLocalStrictExtrema(inputColl, extremaBorderPolicy,
55  extremaIdxColl);
56 }
57 
64 template <typename T,
65  typename IndexType>
66 void
67 findLocalStrictMaxima(const std::vector<T>& inputColl,
68  const eExtremaBorderPolicy& extremaBorderPolicy,
69  std::vector<IndexType>& extremaIdxColl)
70 {
71  findLocalStrictExtrema(inputColl, extremaBorderPolicy,
73  extremaIdxColl);
74 }
75 
78 
89 template <typename T>
90 IPSDKMATH_API void
91 findLocalDilatedExtrema(const std::vector<T>& inputColl,
92  const eExtremaBorderPolicy& extremaBorderPolicy,
93  const eExtremaType& extremaType,
94  const T& dilateFactor,
95  ExtremaRangeColl& extremaRangeColl);
96 
99 
103 template <typename T,
104  typename IndexType>
105 IPSDKMATH_API void
106 findLocalExtrema(const std::vector<T>& inputColl,
107  const eExtremaBorderPolicy& extremaBorderPolicy,
108  const eExtremaType& extremaType,
109  std::vector<IndexType>& extremaIdxColl);
110 
117 template <typename T,
118  typename IndexType>
119 void
120 findLocalMinima(const std::vector<T>& inputColl,
121  const eExtremaBorderPolicy& extremaBorderPolicy,
122  std::vector<IndexType>& extremaIdxColl)
123 {
124  findLocalExtrema(inputColl, extremaBorderPolicy, eExtremaType::eET_Minima, extremaIdxColl);
125 }
126 
133 template <typename T,
134  typename IndexType>
135 void
136 findLocalMaxima(const std::vector<T>& inputColl,
137  const eExtremaBorderPolicy& extremaBorderPolicy,
138  std::vector<IndexType>& extremaIdxColl)
139 {
140  findLocalExtrema(inputColl, extremaBorderPolicy, eExtremaType::eET_Maxima, extremaIdxColl);
141 }
142 
145 
185 template <typename ExtremaInfo,
186  typename T>
187 IPSDKMATH_API void
188 filterExtrema(const eExtremaType& extremaType,
189  const ipReal64 minDistance,
190  const T extremaThresholdValue,
191  boost::function<void (const ExtremaInfo&, ipReal64&, T&)> extractExtremaCoordsWrapper,
192  std::vector<ExtremaInfo>& extremaInfoColl);
193 
196 template <typename T,
197  typename IndexType>
198 void
199 extractBasicExtremaCoords(const std::vector<T>& inputColl,
200  const IndexType& dataIdx,
201  ipReal64& extremaLocation,
202  T& extremaValue)
203 {
204  extremaLocation = static_cast<ipReal64>(dataIdx);
205  extremaValue = inputColl[dataIdx];
206 }
207 
214 template <typename T>
215 IPSDKMATH_API void
216 extractBasicExtremaCoords(const std::vector<T>& inputColl,
217  const ExtremaRange& extremaRange,
218  ipReal64& extremaLocation,
219  T& extremaValue);
220 
232 template <typename T,
233  typename IndexType>
234 void
235 filterMinima(const std::vector<T>& inputColl,
236  const ipReal64 minDistance,
237  std::vector<IndexType>& extremaInfoColl)
238 {
239  const T extremaThresholdValue = NumericLimits<T>::max();
240  typedef void (*ExtractExtremaCoordsFun) (const std::vector<T>&, const IndexType&, ipReal64&, T&);
241  typedef boost::function<void (const IndexType&, ipReal64&, T&)> ExtractExtremaCoordsWrapper;
242  ExtractExtremaCoordsWrapper extractExtremaCoordsWrapper = boost::bind(static_cast<ExtractExtremaCoordsFun>(extractBasicExtremaCoords<T>), boost::cref(inputColl), _1, _2, _3);
243  filterExtrema(eExtremaType::eET_Minima, minDistance, extremaThresholdValue,
244  extractExtremaCoordsWrapper, extremaInfoColl);
245 }
246 
260 template <typename T,
261  typename IndexType>
262 void
263 filterMinima(const std::vector<T>& inputColl,
264  const ipReal64 minDistance,
265  const T extremaThresholdValue,
266  std::vector<IndexType>& extremaInfoColl)
267 {
268  typedef void (*ExtractExtremaCoordsFun) (const std::vector<T>&, const IndexType&, ipReal64&, T&);
269  typedef boost::function<void (const IndexType&, ipReal64&, T&)> ExtractExtremaCoordsWrapper;
270  ExtractExtremaCoordsWrapper extractExtremaCoordsWrapper = boost::bind(static_cast<ExtractExtremaCoordsFun>(extractBasicExtremaCoords<T>), boost::cref(inputColl), _1, _2, _3);
271  filterExtrema(eExtremaType::eET_Minima, minDistance, extremaThresholdValue,
272  extractExtremaCoordsWrapper, extremaInfoColl);
273 }
274 
286 template <typename T,
287  typename IndexType>
288 void
289 filterMaxima(const std::vector<T>& inputColl,
290  const ipReal64 minDistance,
291  std::vector<IndexType>& extremaInfoColl)
292 {
293  const T extremaThresholdValue = NumericLimits<T>::min();
294  typedef void (*ExtractExtremaCoordsFun) (const std::vector<T>&, const IndexType&, ipReal64&, T&);
295  typedef boost::function<void (const IndexType&, ipReal64&, T&)> ExtractExtremaCoordsWrapper;
296  ExtractExtremaCoordsWrapper extractExtremaCoordsWrapper = boost::bind(static_cast<ExtractExtremaCoordsFun>(extractBasicExtremaCoords<T>), boost::cref(inputColl), _1, _2, _3);
297  filterExtrema(eExtremaType::eET_Maxima, minDistance, extremaThresholdValue,
298  extractExtremaCoordsWrapper, extremaInfoColl);
299 }
300 
314 template <typename T,
315  typename IndexType>
316 void
317 filterMaxima(const std::vector<T>& inputColl,
318  const ipReal64 minDistance,
319  const T extremaThresholdValue,
320  std::vector<IndexType>& extremaInfoColl)
321 {
322  typedef void (*ExtractExtremaCoordsFun) (const std::vector<T>&, const IndexType&, ipReal64&, T&);
323  typedef boost::function<void (const IndexType&, ipReal64&, T&)> ExtractExtremaCoordsWrapper;
324  ExtractExtremaCoordsWrapper extractExtremaCoordsWrapper = boost::bind(static_cast<ExtractExtremaCoordsFun>(extractBasicExtremaCoords<T>), boost::cref(inputColl), _1, _2, _3);
325  filterExtrema(eExtremaType::eET_Maxima, minDistance, extremaThresholdValue,
326  extractExtremaCoordsWrapper, extremaInfoColl);
327 }
328 
331 
332 } // end of namespace math
333 } // end of namespace ipsdk
334 
335 #endif // __IPSDKMATH_EXTREMAUTILS_H__
Definition of import/export macro for library.
Main namespace for IPSDK library.
Definition: AlgorithmFunctionEfficiency.h:22
Minima extrema.
Definition: ExtremaTypes.h:34
double ipReal64
Base types definition.
Definition: BaseTypes.h:57
Definition: NumericLimits.h:27
IPSDKMATH_API void filterExtrema(const eExtremaType &extremaType, const ipReal64 minDistance, const T extremaThresholdValue, boost::function< void(const ExtremaInfo &, ipReal64 &, T &)> extractExtremaCoordsWrapper, std::vector< ExtremaInfo > &extremaInfoColl)
function allowing to filter a collection of extrema using a distance criterion
void extractBasicExtremaCoords(const std::vector< T > &inputColl, const IndexType &dataIdx, ipReal64 &extremaLocation, T &extremaValue)
Definition: ExtremaUtils.h:199
#define IPSDKMATH_API
Import/Export macro for library IPSDKMath.
Definition: IPSDKMathExports.h:27
std::pair< ipUInt64, ipUInt64 > ExtremaRange
index for dilated local extrema
Definition: ExtremaTypes.h:55
void filterMaxima(const std::vector< T > &inputColl, const ipReal64 minDistance, std::vector< IndexType > &extremaInfoColl)
function allowing to filter a collection of maxima using a distance criterion Extrema are first sorte...
Definition: ExtremaUtils.h:289
void filterMinima(const std::vector< T > &inputColl, const ipReal64 minDistance, std::vector< IndexType > &extremaInfoColl)
function allowing to filter a collection of minima using a distance criterion Extrema are first sorte...
Definition: ExtremaUtils.h:235
IPSDKMATH_API void findLocalDilatedExtrema(const std::vector< T > &inputColl, const eExtremaBorderPolicy &extremaBorderPolicy, const eExtremaType &extremaType, const T &dilateFactor, ExtremaRangeColl &extremaRangeColl)
generic function allowing to search for local &#39;dilated&#39; extrema into a collection of values ...
void findLocalMaxima(const std::vector< T > &inputColl, const eExtremaBorderPolicy &extremaBorderPolicy, std::vector< IndexType > &extremaIdxColl)
function allowing to search for local maxima into a collection of values
Definition: ExtremaUtils.h:136
void findLocalMinima(const std::vector< T > &inputColl, const eExtremaBorderPolicy &extremaBorderPolicy, std::vector< IndexType > &extremaIdxColl)
function allowing to search for local minima into a collection of values
Definition: ExtremaUtils.h:120
eExtremaType
Enumerate allowing to define an extrema type.
Definition: ExtremaTypes.h:32
Predefined types for extrema management.
IPSDKMATH_API void findLocalExtrema(const std::vector< T > &inputColl, const eExtremaBorderPolicy &extremaBorderPolicy, const eExtremaType &extremaType, std::vector< IndexType > &extremaIdxColl)
function allowing to search for local extrema into a collection of values (this is the non strict ext...
void findLocalStrictMaxima(const std::vector< T > &inputColl, const eExtremaBorderPolicy &extremaBorderPolicy, std::vector< IndexType > &extremaIdxColl)
generic function allowing to search for local strict maxima into a collection of values ...
Definition: ExtremaUtils.h:67
IPSDKMATH_API void findLocalStrictExtrema(const std::vector< T > &inputColl, const eExtremaBorderPolicy &extremaBorderPolicy, const eExtremaType &extremaType, std::vector< IndexType > &extremaIdxColl)
generic function allowing to search for local strict extrema into a collection of values ...
Maxima extrema.
Definition: ExtremaTypes.h:36
std::vector< ExtremaRange > ExtremaRangeColl
collection of indexes for dilated local extrema
Definition: ExtremaTypes.h:64
void findLocalStrictMinima(const std::vector< T > &inputColl, const eExtremaBorderPolicy &extremaBorderPolicy, std::vector< IndexType > &extremaIdxColl)
generic function allowing to search for local strict minima into a collection of values ...
Definition: ExtremaUtils.h:49
eExtremaBorderPolicy
Enumerate allowing to describe border policy used during extrema extraction processing.
Definition: ExtremaTypes.h:45