60 lines
1.9 KiB
C++
60 lines
1.9 KiB
C++
#ifndef _OTB_TRISKELE_WEIGHT_ATTRIBUTES_TPP
|
|
#define _OTB_TRISKELE_WEIGHT_ATTRIBUTES_TPP
|
|
|
|
using namespace boost::chrono;
|
|
|
|
template<typename WeightT>
|
|
inline
|
|
WeightAttributes<WeightT>::WeightAttributes (const Tree &tree, const bool &decr)
|
|
: CompAttribute<WeightT> (tree, decr) {
|
|
}
|
|
|
|
template<typename WeightT>
|
|
inline
|
|
WeightAttributes<WeightT>::~WeightAttributes () {
|
|
}
|
|
|
|
template<typename WeightT>
|
|
inline void
|
|
WeightAttributes<WeightT>::setWeightBounds (Tree &tree) {
|
|
vector<DimImg> &weightBounds (tree.getWeightBounds ());
|
|
DimImg rootId = tree.getCompRoot ();
|
|
|
|
DimImg stepsCard = 0;
|
|
WeightT curLevel = CompAttribute<WeightT>::values [0];
|
|
for (DimImg compId = 1; compId <= rootId; ++compId) {
|
|
if (CompAttribute<WeightT>::values [compId] == curLevel)
|
|
continue;
|
|
++stepsCard;
|
|
curLevel = CompAttribute<WeightT>::values [compId];
|
|
}
|
|
weightBounds.clear ();
|
|
weightBounds.reserve (stepsCard+1);
|
|
weightBounds.push_back (0);
|
|
curLevel = CompAttribute<WeightT>::values [0];
|
|
for (DimImg compId = 1; compId <= rootId; ++compId) {
|
|
if (CompAttribute<WeightT>::values [compId] == curLevel)
|
|
continue;
|
|
weightBounds.push_back (compId);
|
|
curLevel = CompAttribute<WeightT>::values [compId];
|
|
}
|
|
weightBounds.push_back (rootId+1);
|
|
}
|
|
|
|
|
|
template<typename WeightT>
|
|
template<typename PixelT>
|
|
inline void
|
|
WeightAttributes<WeightT>::cut (vector<vector<PixelT> > &allBands, const AttributeProfiles<PixelT> &attributeProfiles,
|
|
const vector<WeightT> &thresholds) const {
|
|
auto start = high_resolution_clock::now ();
|
|
vector<WeightT> orderedThresholds (thresholds);
|
|
if (CompAttribute<WeightT>::decr)
|
|
reverse (orderedThresholds.begin (), orderedThresholds.end ());
|
|
CompAttribute<WeightT>::cut (allBands, attributeProfiles, 0., orderedThresholds);
|
|
globalTreeStats.addTime (filteringStats, duration_cast<duration<double> > (high_resolution_clock::now ()-start).count ());
|
|
}
|
|
|
|
|
|
#endif // _OTB_TRISKELE_WEIGHT_ATTRIBUTES_TPP
|