1#ifndef __JMATH__JWATERSHED__
2#define __JMATH__JWATERSHED__
11namespace JPP {
using namespace JMATH; }
28 template<
class T,
class JFunction_t,
class JDistance_t>
31 const JFunction_t& getValue,
32 const JDistance_t& getDistance,
34 int N = std::numeric_limits<int>::max())
38 typedef typename iterator_traits<T>::reference reference_type;
42 for (T
p1 = __begin;
p1 != __end &&
distance(__begin, out) < N; ) {
46 for (T i =
p1; i != __end; ++i) {
47 if (getValue(*i) > getValue(*q1)) {
58 auto compare = [q1,
getDistance](
const reference_type first,
59 const reference_type second)
64 sort(
p1, __end, compare);
66 double y = getValue(*q1);
68 for (T p2 = next(
p1); p2 != __end &&
69 (getValue(*
p1) <= y + Y ||
T watershed(T __begin, T __end, const JFunction_t &getValue, const JDistance_t &getDistance, double Y, int N=std::numeric_limits< int >::max())
Watershed algorithm.
double getDistance(const JFirst_t &first, const JSecond_t &second)
Get distance between objects.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).