#ifndef _OTB_TRISKELE_ARRAY_TREE_WEIGHT_HPP #define _OTB_TRISKELE_ARRAY_TREE_WEIGHT_HPP #include #include #include "triskeleBase.hpp" #include "IImage.hpp" #include "triskeleArrayTreeBase.hpp" namespace otb { namespace triskele { namespace arrayTree { class GraphWalker; /*! Structure définissant la base d'un poids entre les pixels */ template struct WeightBase { protected: const PixelT *pixels; Size size; inline DimNodeId pointIdx (const Point &p) const; PixelT halfPixel, maxPixel; inline void reset (const PixelT *pixels, const Size &size); public: const PixelT *getPixels () const { return pixels; } inline const Size &getSize () const; inline const PixelT &getValue (const DimImg &idx) const; inline const PixelT &getValue (const Point &p) const; inline bool getDecr () const; inline const PixelT &getMaxPixel () const; inline const PixelT &getHalfPixel () const; inline WeightBase (const PixelT *pixels, const Size &size); static inline bool isWeightInf (const WeightT &a, const WeightT &b); static inline bool isEdgeInf (const Edge &a, const Edge &b); static inline void sort (Edge *edges, DimEdge count); inline void copyPixelsBound (PixelT *leafAPTree, const DimImg &minVal, const DimImg &maxVal) const; inline void weight2valueBound (PixelT *compAPTree, const WeightT *compWeights, const DimImg &minVal, const DimImg &maxVal) const; }; // ======================================== /*! Structure intégrant la façon dont est géré un poids pour un MaxTree car la fonction calcul le poids minimum */ template struct MinWeight : public WeightBase { typedef WeightBase WB; inline bool getDecr () const; static inline bool isWeightInf (const WeightT &a, const WeightT &b); static inline bool isEdgeInf (const Edge &a, const Edge &b); static inline void sort (Edge *edges, DimEdge count); inline MinWeight (); inline MinWeight (const PixelT *pixels, const Size &size); inline MinWeight (const MinWeight &model, const PixelT *pixels, const Size &size); inline WeightT getWeight (const DimImg &idx) const; inline WeightT getWeight (const Point &a, const Point &b) const; }; // ======================================== /*! Structure intégrant la façon dont est géré un poids pour un MinTree car la fonction calcul le poids maximum. */ template struct MaxWeight : public WeightBase { typedef WeightBase WB; inline MaxWeight(); inline MaxWeight (const PixelT *pixels, const Size &size); inline MaxWeight (const MaxWeight &model, const PixelT *pixels, const Size &size); inline WeightT getWeight (const DimImg &idx) const; inline WeightT getWeight (const Point &a, const Point &b) const; }; // ======================================== /*! Structure intégrant la façon dont est géré un poids pour un AlphaTree car la fonction calcul la distance minimum (0 dans les feuilles comme MinTree donc comme MaxWeight) */ template struct DiffWeight : public WeightBase { typedef WeightBase WB; inline DiffWeight (); inline DiffWeight (const PixelT *pixels, const Size &size); inline DiffWeight (const DiffWeight &model, const PixelT *pixels, const Size &size); inline WeightT getWeight (const DimImg &idx) const; inline WeightT getWeight (const Point &a, const Point &b) const; }; // ======================================== /*! Structure intégrant la façon dont est géré un poids pour un TreeOfShape car la fonction calcul la distance à la médiane (distance maximum dans les feuilles donc comme MaxTree donc comme MinWeight) */ template struct MedianWeight : public WeightBase { typedef WeightBase WB; protected: PixelT median, thresholdPixel; WeightT thresholdWeight; public: inline bool getDecr () const; static inline bool isWeightInf (const WeightT &a, const WeightT &b); static inline bool isEdgeInf (const Edge &a, const Edge &b); static inline void sort (Edge *edges, DimEdge count); inline const PixelT &getMedian () const; inline const PixelT &getThresholdPixel () const; inline const WeightT &getThresholdWeight () const; inline WeightT value2weight (const PixelT &val) const; inline PixelT weight2value (const WeightT &weight) const; inline MedianWeight (); inline MedianWeight (const PixelT *pixels, const GraphWalker &graphWalker); inline MedianWeight (const MedianWeight &model, const PixelT *pixels, const Size &size); inline WeightT getWeight (const DimImg &idx) const; inline WeightT getWeight (const Point &a, const Point &b) const; inline void weight2valueBound (PixelT *compAPTree, const WeightT *compWeights, const DimImg &minVal, const DimImg &maxVal) const; }; } // arrayTree } // triskele } // otb #include "GraphWalker.hpp" namespace otb { namespace triskele { namespace arrayTree { #include "Weight.tpp" } // arrayTree } // triskele } // otb #endif // _OTB_TRISKELE_ARRAY_TREE_WEIGHT_HPP