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 ();
|
auto start = high_resolution_clock::now ();
|
||||||
switch (treeType) {
|
switch (treeType) {
|
||||||
case MIN:
|
case MIN:
|
||||||
buildTree (tree, MinWeight<PixelT, WeightT> (raster.getPixels (), raster.getSize ()));
|
buildTree (tree, MaxWeight<PixelT, WeightT> (raster.getPixels (), raster.getSize ()));
|
||||||
break;
|
break;
|
||||||
case MAX:
|
case MAX:
|
||||||
buildTree (tree, MaxWeight<PixelT, WeightT> (raster.getPixels (), raster.getSize ()));
|
buildTree (tree, MinWeight<PixelT, WeightT> (raster.getPixels (), raster.getSize ()));
|
||||||
break;
|
break;
|
||||||
case TOS:
|
case TOS:
|
||||||
buildTree (tree, MedianWeight<PixelT, WeightT> (raster.getPixels (), graphWalker));
|
buildTree (tree, MedianWeight<PixelT, WeightT> (raster.getPixels (), graphWalker));
|
||||||
@ -84,10 +84,10 @@ ArrayTreeBuilder<WeightT, PixelT>::setAttributProfiles (AttributeProfiles<PixelT
|
|||||||
attributeProfiles.updateTranscient ();
|
attributeProfiles.updateTranscient ();
|
||||||
switch (treeType) {
|
switch (treeType) {
|
||||||
case MIN:
|
case MIN:
|
||||||
setAttributProfiles (attributeProfiles, MinWeight<PixelT, WeightT> (raster.getPixels (), raster.getSize ()));
|
setAttributProfiles (attributeProfiles, MaxWeight<PixelT, WeightT> (raster.getPixels (), raster.getSize ()));
|
||||||
break;
|
break;
|
||||||
case MAX:
|
case MAX:
|
||||||
setAttributProfiles (attributeProfiles, MaxWeight<PixelT, WeightT> (raster.getPixels (), raster.getSize ()));
|
setAttributProfiles (attributeProfiles, MinWeight<PixelT, WeightT> (raster.getPixels (), raster.getSize ()));
|
||||||
break;
|
break;
|
||||||
case TOS:
|
case TOS:
|
||||||
setAttributProfiles (attributeProfiles, MedianWeight<PixelT, WeightT> (raster.getPixels (), graphWalker));
|
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 */
|
/*! 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;
|
typedef WeightBase<PixelT, WeightT> WB;
|
||||||
|
|
||||||
inline bool getDecr () const;
|
inline bool getDecr () const;
|
||||||
@ -53,9 +53,9 @@ namespace otb {
|
|||||||
static inline bool isEdgeInf (const Edge<WeightT> &a, const Edge<WeightT> &b);
|
static inline bool isEdgeInf (const Edge<WeightT> &a, const Edge<WeightT> &b);
|
||||||
static inline void sort (Edge<WeightT> *edges, DimEdge count);
|
static inline void sort (Edge<WeightT> *edges, DimEdge count);
|
||||||
|
|
||||||
inline MinWeight ();
|
inline MaxWeight ();
|
||||||
inline MinWeight (const PixelT *pixels, const Size &size);
|
inline MaxWeight (const PixelT *pixels, const Size &size);
|
||||||
inline MinWeight (const MinWeight &model, 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 DimImg &idx) const;
|
||||||
inline WeightT getWeight (const Point &a, const Point &b) 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 */
|
/*! 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;
|
typedef WeightBase<PixelT, WeightT> WB;
|
||||||
|
|
||||||
inline MaxWeight ();
|
inline MinWeight ();
|
||||||
inline MaxWeight (const PixelT *pixels, const Size &size);
|
inline MinWeight (const PixelT *pixels, const Size &size);
|
||||||
inline MaxWeight (const MaxWeight &model, 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 DimImg &idx) const;
|
||||||
inline WeightT getWeight (const Point &a, const Point &b) 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>
|
template <typename PixelT, typename WeightT>
|
||||||
inline bool
|
inline bool
|
||||||
MinWeight<PixelT, WeightT>::getDecr () const {
|
MaxWeight<PixelT, WeightT>::getDecr () const {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename PixelT, typename WeightT>
|
template <typename PixelT, typename WeightT>
|
||||||
inline bool
|
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;
|
return a > b;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename PixelT, typename WeightT>
|
template <typename PixelT, typename WeightT>
|
||||||
inline bool
|
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);
|
return isWeightInf (a.weight, b.weight);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename PixelT, typename WeightT>
|
template <typename PixelT, typename WeightT>
|
||||||
inline void
|
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);
|
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>
|
template <typename PixelT, typename WeightT>
|
||||||
inline
|
inline
|
||||||
MaxWeight<PixelT, WeightT>::MaxWeight ()
|
MaxWeight<PixelT, WeightT>::MaxWeight ()
|
||||||
@ -182,6 +150,38 @@ MaxWeight<PixelT, WeightT>::getWeight (const DimImg &idx) const {
|
|||||||
template <typename PixelT, typename WeightT>
|
template <typename PixelT, typename WeightT>
|
||||||
inline WeightT
|
inline WeightT
|
||||||
MaxWeight<PixelT, WeightT>::getWeight (const Point &a, const Point &b) const {
|
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)),
|
return std::max (getWeight (WB::pointIdx (a)),
|
||||||
getWeight (WB::pointIdx (b)));
|
getWeight (WB::pointIdx (b)));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -106,37 +106,37 @@ callOnSortedSets (const std::vector<DimImg> &sizes,
|
|||||||
// get min
|
// get min
|
||||||
bool found = false;
|
bool found = false;
|
||||||
DimImg minVectIdx = 0;
|
DimImg minVectIdx = 0;
|
||||||
WeightT minWeight = 0;
|
WeightT maxWeight = 0;
|
||||||
for (DimImg vectId = 0; vectId < size; ++vectId) {
|
for (DimImg vectId = 0; vectId < size; ++vectId) {
|
||||||
if (!vectCounts [vectId])
|
if (!vectCounts [vectId])
|
||||||
continue;
|
continue;
|
||||||
WeightT tmpWeight = getWeight (vectId, 0);
|
WeightT tmpWeight = getWeight (vectId, 0);
|
||||||
if (found && !isWeightInf (tmpWeight, minWeight))
|
if (found && !isWeightInf (tmpWeight, maxWeight))
|
||||||
continue;
|
continue;
|
||||||
minVectIdx = vectId;
|
minVectIdx = vectId;
|
||||||
minWeight = tmpWeight;
|
maxWeight = tmpWeight;
|
||||||
found = true;
|
found = true;
|
||||||
}
|
}
|
||||||
LOG ("found:" << found << " minVectIdx:" << minVectIdx << " minWeight:" << minWeight);
|
LOG ("found:" << found << " minVectIdx:" << minVectIdx << " maxWeight:" << maxWeight);
|
||||||
// loop
|
// loop
|
||||||
for ( ; found; ) {
|
for ( ; found; ) {
|
||||||
// get next min
|
// get next min
|
||||||
found = false;
|
found = false;
|
||||||
DimImg nextMinVectIdx = 0;
|
DimImg nextMinVectIdx = 0;
|
||||||
WeightT nextMinWeight = 0;
|
WeightT nextMaxWeight = 0;
|
||||||
for (DimImg vectId = minVectIdx; ; ) {
|
for (DimImg vectId = minVectIdx; ; ) {
|
||||||
if (vectCounts [vectId]) {
|
if (vectCounts [vectId]) {
|
||||||
WeightT tmpWeight = getWeight (vectId, vectIds [vectId]);
|
WeightT tmpWeight = getWeight (vectId, vectIds [vectId]);
|
||||||
if (!isWeightInf (minWeight, tmpWeight)) {
|
if (!isWeightInf (maxWeight, tmpWeight)) {
|
||||||
// minWeight == tmpWeight
|
// maxWeight == tmpWeight
|
||||||
callIdId (vectId, vectIds [vectId]);
|
callIdId (vectId, vectIds [vectId]);
|
||||||
++vectIds [vectId];
|
++vectIds [vectId];
|
||||||
--vectCounts [vectId];
|
--vectCounts [vectId];
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!found || isWeightInf (tmpWeight, nextMinWeight)) {
|
if (!found || isWeightInf (tmpWeight, nextMaxWeight)) {
|
||||||
nextMinVectIdx = vectId;
|
nextMinVectIdx = vectId;
|
||||||
nextMinWeight = tmpWeight;
|
nextMaxWeight = tmpWeight;
|
||||||
found = true;
|
found = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -145,7 +145,7 @@ callOnSortedSets (const std::vector<DimImg> &sizes,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
minVectIdx = nextMinVectIdx;
|
minVectIdx = nextMinVectIdx;
|
||||||
minWeight = nextMinWeight;
|
maxWeight = nextMaxWeight;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user