modifié : include/ArrayTree/ArrayTreeBuilder.tpp
modifié : include/ArrayTree/Weight.hpp modifié : include/ArrayTree/Weight.tpp modifié : include/triskeleDealThreads.tpp
This commit is contained in:
parent
0711237034
commit
4814ea4a8e
@ -43,10 +43,10 @@ ArrayTreeBuilder<WeightT, PixelT>::buildTree (Tree &tree, WeightAttributes<Weigh
|
||||
auto start = high_resolution_clock::now ();
|
||||
switch (treeType) {
|
||||
case MIN:
|
||||
buildTree (tree, MinWeight<PixelT, WeightT> (raster.getPixels (), raster.getSize ()));
|
||||
buildTree (tree, MaxWeight<PixelT, WeightT> (raster.getPixels (), raster.getSize ()));
|
||||
break;
|
||||
case MAX:
|
||||
buildTree (tree, MaxWeight<PixelT, WeightT> (raster.getPixels (), raster.getSize ()));
|
||||
buildTree (tree, MinWeight<PixelT, WeightT> (raster.getPixels (), raster.getSize ()));
|
||||
break;
|
||||
case TOS:
|
||||
buildTree (tree, MedianWeight<PixelT, WeightT> (raster.getPixels (), graphWalker));
|
||||
@ -84,10 +84,10 @@ ArrayTreeBuilder<WeightT, PixelT>::setAttributProfiles (AttributeProfiles<PixelT
|
||||
attributeProfiles.updateTranscient ();
|
||||
switch (treeType) {
|
||||
case MIN:
|
||||
setAttributProfiles (attributeProfiles, MinWeight<PixelT, WeightT> (raster.getPixels (), raster.getSize ()));
|
||||
setAttributProfiles (attributeProfiles, MaxWeight<PixelT, WeightT> (raster.getPixels (), raster.getSize ()));
|
||||
break;
|
||||
case MAX:
|
||||
setAttributProfiles (attributeProfiles, MaxWeight<PixelT, WeightT> (raster.getPixels (), raster.getSize ()));
|
||||
setAttributProfiles (attributeProfiles, MinWeight<PixelT, WeightT> (raster.getPixels (), raster.getSize ()));
|
||||
break;
|
||||
case TOS:
|
||||
setAttributProfiles (attributeProfiles, MedianWeight<PixelT, WeightT> (raster.getPixels (), graphWalker));
|
||||
|
@ -45,7 +45,7 @@ namespace otb {
|
||||
};
|
||||
|
||||
/*! Structure intégrant la façon dont est géré un poids pour un MinTree */
|
||||
template <typename PixelT, typename WeightT> struct MinWeight : public WeightBase<PixelT, WeightT> {
|
||||
template <typename PixelT, typename WeightT> struct MaxWeight : public WeightBase<PixelT, WeightT> {
|
||||
typedef WeightBase<PixelT, WeightT> WB;
|
||||
|
||||
inline bool getDecr () const;
|
||||
@ -53,9 +53,9 @@ namespace otb {
|
||||
static inline bool isEdgeInf (const Edge<WeightT> &a, const Edge<WeightT> &b);
|
||||
static inline void sort (Edge<WeightT> *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 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;
|
||||
@ -63,12 +63,12 @@ namespace otb {
|
||||
|
||||
// ========================================
|
||||
/*! Structure intégrant la façon dont est géré un poids pour un MaxTree */
|
||||
template <typename PixelT, typename WeightT> struct MaxWeight : public WeightBase<PixelT, WeightT> {
|
||||
template <typename PixelT, typename WeightT> struct MinWeight : public WeightBase<PixelT, WeightT> {
|
||||
typedef WeightBase<PixelT, WeightT> WB;
|
||||
|
||||
inline MaxWeight ();
|
||||
inline MaxWeight (const PixelT *pixels, const Size &size);
|
||||
inline MaxWeight (const MaxWeight &model, const PixelT *pixels, const Size &size);
|
||||
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;
|
||||
|
@ -101,60 +101,28 @@ WeightBase<PixelT, WeightT>::weight2valueBound (PixelT *compAPTree, const Weight
|
||||
// ========================================
|
||||
template <typename PixelT, typename WeightT>
|
||||
inline bool
|
||||
MinWeight<PixelT, WeightT>::getDecr () const {
|
||||
MaxWeight<PixelT, WeightT>::getDecr () const {
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename PixelT, typename WeightT>
|
||||
inline bool
|
||||
MinWeight<PixelT, WeightT>::isWeightInf (const WeightT &a, const WeightT &b) {
|
||||
MaxWeight<PixelT, WeightT>::isWeightInf (const WeightT &a, const WeightT &b) {
|
||||
return a > b;
|
||||
}
|
||||
|
||||
template <typename PixelT, typename WeightT>
|
||||
inline bool
|
||||
MinWeight<PixelT, WeightT>::isEdgeInf (const Edge<WeightT> &a, const Edge<WeightT> &b) {
|
||||
MaxWeight<PixelT, WeightT>::isEdgeInf (const Edge<WeightT> &a, const Edge<WeightT> &b) {
|
||||
return isWeightInf (a.weight, b.weight);
|
||||
}
|
||||
|
||||
template <typename PixelT, typename WeightT>
|
||||
inline void
|
||||
MinWeight<PixelT, WeightT>::sort (Edge<WeightT> *edges, DimEdge count) {
|
||||
MaxWeight<PixelT, WeightT>::sort (Edge<WeightT> *edges, DimEdge count) {
|
||||
std::sort (edges, edges+count, isEdgeInf);
|
||||
}
|
||||
|
||||
template <typename PixelT, typename WeightT>
|
||||
inline
|
||||
MinWeight<PixelT, WeightT>::MinWeight ()
|
||||
: WB (nullptr, NullSize) {
|
||||
}
|
||||
|
||||
template <typename PixelT, typename WeightT>
|
||||
inline
|
||||
MinWeight<PixelT, WeightT>::MinWeight (const PixelT *pixels, const Size &size)
|
||||
: WB (pixels, size) {
|
||||
}
|
||||
|
||||
template <typename PixelT, typename WeightT>
|
||||
inline
|
||||
MinWeight<PixelT, WeightT>::MinWeight (const MinWeight &model, const PixelT *pixels, const Size &size)
|
||||
: WB (pixels, size) {
|
||||
}
|
||||
|
||||
template <typename PixelT, typename WeightT>
|
||||
inline WeightT
|
||||
MinWeight<PixelT, WeightT>::getWeight (const DimImg &idx) const {
|
||||
return WB::getValue (idx);
|
||||
}
|
||||
|
||||
template <typename PixelT, typename WeightT>
|
||||
inline WeightT
|
||||
MinWeight<PixelT, WeightT>::getWeight (const Point &a, const Point &b) const {
|
||||
return std::min (getWeight (WB::pointIdx (a)),
|
||||
getWeight (WB::pointIdx (b)));
|
||||
}
|
||||
|
||||
// ========================================
|
||||
template <typename PixelT, typename WeightT>
|
||||
inline
|
||||
MaxWeight<PixelT, WeightT>::MaxWeight ()
|
||||
@ -182,6 +150,38 @@ MaxWeight<PixelT, WeightT>::getWeight (const DimImg &idx) const {
|
||||
template <typename PixelT, typename WeightT>
|
||||
inline WeightT
|
||||
MaxWeight<PixelT, WeightT>::getWeight (const Point &a, const Point &b) const {
|
||||
return std::min (getWeight (WB::pointIdx (a)),
|
||||
getWeight (WB::pointIdx (b)));
|
||||
}
|
||||
|
||||
// ========================================
|
||||
template <typename PixelT, typename WeightT>
|
||||
inline
|
||||
MinWeight<PixelT, WeightT>::MinWeight ()
|
||||
: WB (nullptr, NullSize) {
|
||||
}
|
||||
|
||||
template <typename PixelT, typename WeightT>
|
||||
inline
|
||||
MinWeight<PixelT, WeightT>::MinWeight (const PixelT *pixels, const Size &size)
|
||||
: WB (pixels, size) {
|
||||
}
|
||||
|
||||
template <typename PixelT, typename WeightT>
|
||||
inline
|
||||
MinWeight<PixelT, WeightT>::MinWeight (const MinWeight &model, const PixelT *pixels, const Size &size)
|
||||
: WB (pixels, size) {
|
||||
}
|
||||
|
||||
template <typename PixelT, typename WeightT>
|
||||
inline WeightT
|
||||
MinWeight<PixelT, WeightT>::getWeight (const DimImg &idx) const {
|
||||
return WB::getValue (idx);
|
||||
}
|
||||
|
||||
template <typename PixelT, typename WeightT>
|
||||
inline WeightT
|
||||
MinWeight<PixelT, WeightT>::getWeight (const Point &a, const Point &b) const {
|
||||
return std::max (getWeight (WB::pointIdx (a)),
|
||||
getWeight (WB::pointIdx (b)));
|
||||
}
|
||||
|
@ -106,37 +106,37 @@ callOnSortedSets (const std::vector<DimImg> &sizes,
|
||||
// get min
|
||||
bool found = false;
|
||||
DimImg minVectIdx = 0;
|
||||
WeightT minWeight = 0;
|
||||
WeightT maxWeight = 0;
|
||||
for (DimImg vectId = 0; vectId < size; ++vectId) {
|
||||
if (!vectCounts [vectId])
|
||||
continue;
|
||||
WeightT tmpWeight = getWeight (vectId, 0);
|
||||
if (found && !isWeightInf (tmpWeight, minWeight))
|
||||
if (found && !isWeightInf (tmpWeight, maxWeight))
|
||||
continue;
|
||||
minVectIdx = vectId;
|
||||
minWeight = tmpWeight;
|
||||
maxWeight = tmpWeight;
|
||||
found = true;
|
||||
}
|
||||
LOG ("found:" << found << " minVectIdx:" << minVectIdx << " minWeight:" << minWeight);
|
||||
LOG ("found:" << found << " minVectIdx:" << minVectIdx << " maxWeight:" << maxWeight);
|
||||
// loop
|
||||
for ( ; found; ) {
|
||||
// get next min
|
||||
found = false;
|
||||
DimImg nextMinVectIdx = 0;
|
||||
WeightT nextMinWeight = 0;
|
||||
WeightT nextMaxWeight = 0;
|
||||
for (DimImg vectId = minVectIdx; ; ) {
|
||||
if (vectCounts [vectId]) {
|
||||
WeightT tmpWeight = getWeight (vectId, vectIds [vectId]);
|
||||
if (!isWeightInf (minWeight, tmpWeight)) {
|
||||
// minWeight == tmpWeight
|
||||
if (!isWeightInf (maxWeight, tmpWeight)) {
|
||||
// maxWeight == tmpWeight
|
||||
callIdId (vectId, vectIds [vectId]);
|
||||
++vectIds [vectId];
|
||||
--vectCounts [vectId];
|
||||
continue;
|
||||
}
|
||||
if (!found || isWeightInf (tmpWeight, nextMinWeight)) {
|
||||
if (!found || isWeightInf (tmpWeight, nextMaxWeight)) {
|
||||
nextMinVectIdx = vectId;
|
||||
nextMinWeight = tmpWeight;
|
||||
nextMaxWeight = tmpWeight;
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
@ -145,7 +145,7 @@ callOnSortedSets (const std::vector<DimImg> &sizes,
|
||||
break;
|
||||
}
|
||||
minVectIdx = nextMinVectIdx;
|
||||
minWeight = nextMinWeight;
|
||||
maxWeight = nextMaxWeight;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user