36 #if defined(BasicFunctors_RECURSES) 37 #error Recursive header files inclusion detected in BasicFunctors.h 38 #else // defined(BasicFunctors_RECURSES) 40 #define BasicFunctors_RECURSES 42 #if !defined BasicFunctors_h 44 #define BasicFunctors_h 51 #include "DGtal/base/Common.h" 52 #include "DGtal/base/BasicBoolFunctors.h" 63 struct Min : std::binary_function <T,T,T>
67 {
return std::min(a,b); }
71 struct Max : std::binary_function <T,T,T>
82 struct Minus : std::binary_function <T,T,T>
92 struct Abs : std::unary_function<T,T>
161 template <
typename T >
176 template <
typename TValue>
196 template <
typename TInput>
219 template <
typename TQuantity,
typename TCell>
231 :myQuantity(aQuantity) {}
259 template <
typename TOutput >
267 template<
typename TInput>
271 return static_cast<TOutput
>(aInput);
284 template <
typename TFunctor1,
typename TFunctor2,
typename ReturnType >
300 Composer(
const TFunctor1& aF1,
const TFunctor2& aF2): myF1(&aF1), myF2(&aF2) {}
334 template<
typename TInput>
340 return myF2->operator()( myF1->operator()( aInput ) );
367 template <
typename T,
bool isLower = true,
bool isEqual = true >
369 :
public std::unary_function <T,bool>
388 std::less_equal<Input> c;
399 template <
typename T>
401 :
public std::unary_function <T,bool>
413 std::greater<Input> c;
420 template <
typename T>
422 :
public std::unary_function <T,bool>
432 std::greater_equal<Input> c;
440 template <
typename T>
442 :
public std::unary_function <T,bool>
461 template <
typename T>
463 :
public std::unary_function <T,bool>
474 std::less_equal<Input> c;
493 template <
typename TPredicate1,
typename TPredicate2,
508 const Predicate2 & pred2,
509 const TBinaryFunctor & boolFunctor )
510 : myPred1( &pred1 ), myPred2( &pred2 ), myBoolFunctor( &boolFunctor )
519 : myPred1( other.pred1 ), myPred2( other.pred2 ), myBoolFunctor( other.boolFunctor )
553 return myBoolFunctor->operator()( myPred1->operator()( t ),
554 myPred2->operator()( t ) );
572 template <
typename T>
574 :
public std::unary_function <T,bool>
594 : myTlow( low), myTup ( up ),
629 template <
typename ReturnType>
642 template <
typename TPair>
658 template <
typename ReturnType>
671 template <
typename TPair>
688 template <
typename ReturnType>
701 template <
typename TPair>
716 template <
typename TPair>
733 template <
typename ReturnType>
746 template <
typename TPair>
761 template <
typename TPair>
778 template<
typename TInputType,
typename TOutputType>
797 Rescaling(
const TInputType &initMin,
const TInputType &initMax,
const TOutputType &newMin,
const TOutputType &newMax ) :
798 myInitMin(initMin), myInitMax(initMax), myInitRange(initMax-initMin), myNewMin(newMin), myNewMax(newMax), myNewRange(newMax-newMin) {}
809 {
return anInitVal<myInitMin ? myNewMin : anInitVal > myInitMax ? myNewMax : (anInitVal-myInitMin)*myNewRange/myInitRange + myNewMin; }
829 myCoef = 1.0/(mySigma * sqrt(2.0*M_PI));
830 myCoef2 = 1.0/(2.0*M_PI);
840 ASSERT((aVal <= 1) && (aVal>=0));
841 return myCoef*exp(-aVal*aVal*myCoef2);
858 #endif // !defined BasicFunctors_h 860 #undef BasicFunctors_RECURSES 861 #endif // else defined(BasicFunctors_RECURSES) Aim: defines a functor on double numbers which corresponds to a Gaussian convolution kernel...
Aim: Define a simple functor that returns a constant value (0 by default).
Rescaling(const TInputType &initMin, const TInputType &initMax, const TOutputType &newMin, const TOutputType &newMax)
bool operator()(const Input &aI) const
PredicateCombiner & operator=(const PredicateCombiner &other)
double operator()(const double aVal) const
const ReturnType & operator()(const TPair &aPair) const
bool operator()(const Input &aI) const
PredicateCombiner(const Predicate1 &pred1, const Predicate2 &pred2, const TBinaryFunctor &boolFunctor)
Go to http://www.sgi.com/tech/stl/LessThanComparable.html.
GaussianKernel(const double aSigma)
Aim: Define a simple unary functor that returns a reference on the first member of a pair in order to...
MultiplicationByScalar(const T &aValue)
Aim: Define a simple functor that returns the second member of a pair.
bool operator()(const Input &aI) const
Aim: Define a simple functor using the static cast operator.
Value operator()(const TInput &) const
PredicateCombiner< Tlow, Tup, AndBoolFct2 > CombinedPredicate
Composer(const TFunctor1 &aF1, const TFunctor2 &aF2)
Composer & operator=(const Composer &other)
Thresholder< T, true, true > Tup
bool operator()(const Input &aI) const
Aim: Define a simple unary functor that returns a reference on the first member of a pair in order to...
Go to http://www.sgi.com/tech/stl/EqualityComparable.html.
Composer(const Composer &other)
ConstValue(const Value &aValue=0)
boost::function2< bool, bool, bool > BoolFunctor2
Aim: Define a simple default functor that just returns its argument.
Aim: Define a new Functor from the composition of two other functors.
Thresholder(const Input &aT=0)
Thresholder(const Input &aT=0)
ReturnType operator()(const TInput &aInput) const
ReturnType operator()(const TPair &aPair) const
const ReturnType & operator()(const TPair &aPair) const
Aim: A small functor with an operator () that compares one value to a threshold value according to tw...
bool operator()(const Input &aI) const
Aim: A small functor with an operator () that compares one value to an interval.
Thresholder< T, false, true > Tlow
predicates type
TOutput operator()(const TInput &aInput) const
PredicateCombiner(const PredicateCombiner &other)
Quantity operator()(const Cell &) const
double mySigma
Sigma parameter.
bool operator()(const T &t) const
Aim: Functor allowing to rescale a value. Values of the initial scale [initMin,initMax] are rescaled ...
const Predicate2 * myPred2
aliasing pointer to the right predicate.
double myCoef
Temporary variable.
Thresholder(const Input &aT=0)
const TBinaryFunctor * myBoolFunctor
aliasing pointer to the binary functor.
ReturnType & operator()(TPair &aPair) const
DGtal is the top-level namespace which contains all DGtal functions and types.
Thresholder(const Input &aT=0)
IntervalThresholder(const Input &low, const Input &up)
Aim: The predicate returns true when the given binary functor returns true for the two Predicates giv...
bool operator()(const Input &aI) const
T operator()(const T &a, const T &b) const
ConstValueCell(const Quantity &aQuantity=0)
const Predicate1 * myPred1
aliasing pointer to the left predicate.
ReturnType Value
Necessary for DistanceVisitor.
Aim: Define a simple functor that returns a constant quantity (0 by default).
Aim: Define a simple functor that returns the first member of a pair.
T operator()(const T &aT) const
double myCoef2
Temporary variable.
Thresholder(const Input &aT=0)
ReturnType operator()(const TPair &aPair) const
ReturnType & operator()(TPair &aPair) const