triskele/include/ArrayTree/Weight.hpp
Git Merciol ed9141d5c5 modifié : include/ArrayTree/ArrayTreeBuilder.hpp
modifié :         include/ArrayTree/ArrayTreeBuilder.tpp
	modifié :         include/ArrayTree/Border.hpp
	modifié :         include/ArrayTree/GraphWalker.tpp
	modifié :         include/ArrayTree/Leader.hpp
	modifié :         include/ArrayTree/Leader.tpp
	modifié :         include/ArrayTree/Weight.hpp
	modifié :         include/ArrayTree/Weight.tpp
	modifié :         include/ArrayTree/triskeleArrayTreeBase.hpp
	modifié :         include/ArrayTree/triskeleArrayTreeBase.tpp
	modifié :         include/IImage.hpp
	modifié :         include/IImage.tpp
	modifié :         include/Tree.hpp
	modifié :         include/Tree.tpp
	modifié :         include/TreeBuilder.hpp
	modifié :         include/XMLTree/XMLTreeBuilder.hpp
	modifié :         include/triskeleBase.hpp
	modifié :         include/triskeleDealThreads.hpp
	modifié :         include/triskeleDealThreads.tpp
	modifié :         include/triskeleDebug.hpp
	modifié :         include/triskeleGdalGetType.hpp
	nouveau fichier : src/IImage.cpp
	modifié :         src/QuadTree/QuadTreeBuilder.cpp
	modifié :         src/Tree.cpp
	modifié :         src/testMain.cpp
	modifié :         src/triskeleDebug.cpp
2018-02-18 08:24:25 +01:00

132 lines
4.7 KiB
C++

#ifndef _OTB_TRISKELE_ARRAY_TREE_WEIGHT_HPP
#define _OTB_TRISKELE_ARRAY_TREE_WEIGHT_HPP
#include <iostream>
#include <typeinfo>
#include "triskeleBase.hpp"
#include "triskeleArrayTreeBase.hpp"
namespace otb {
namespace triskele {
namespace arrayTree {
class GraphWalker;
/*! Structure définissant la base d'un poids entre les pixels */
template <typename PixelT> struct WeightBase {
protected:
const PixelT *pixels;
const Size size;
inline DimNodeId pointIdx (const Point &p) const;
PixelT halfPixel, maxPixel;
public:
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 PixelT *allocAP (const DimNodeId &nodeCapacity) const;
inline WeightBase (const PixelT *pixels, const Size &size);
};
template <typename PixelT, typename WeightT> struct WeightBase2 : public WeightBase<PixelT> {
typedef WeightBase<PixelT> WB;
inline WeightBase2 (const PixelT *pixels, const Size &size);
static inline bool isWeightInf (const WeightT &a, const WeightT &b);
static inline bool isEdgeInf (const Edge<WeightT> &a, const Edge<WeightT> &b);
static inline void sort (Edge<WeightT> *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 MinTree */
template <typename PixelT, typename WeightT> struct MinWeight : public WeightBase2<PixelT, WeightT> {
typedef WeightBase2<PixelT, WeightT> WB;
inline bool getDecr () const;
static inline bool isWeightInf (const WeightT &a, const WeightT &b);
static inline bool isEdgeInf (const Edge<WeightT> &a, const Edge<WeightT> &b);
static inline void sort (Edge<WeightT> *edges, DimEdge count);
inline MinWeight (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 MaxTree */
template <typename PixelT, typename WeightT> struct MaxWeight : public WeightBase2<PixelT, WeightT> {
typedef WeightBase2<PixelT, WeightT> WB;
inline MaxWeight (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 */
template <typename PixelT, typename WeightT> struct DiffWeight : public WeightBase2<PixelT, WeightT> {
typedef WeightBase2<PixelT, WeightT> WB;
inline DiffWeight (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 */
template <typename PixelT, typename WeightT> struct MedianWeight : public WeightBase2<PixelT, WeightT> {
typedef WeightBase2<PixelT, WeightT> 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<WeightT> &a, const Edge<WeightT> &b);
static inline void sort (Edge<WeightT> *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 (const PixelT *pixels, const GraphWalker &graphWalker);
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