triskele/include/Attributes/WeightAttributes.tpp
Git Merciol aff93d5467 modifié : include/Appli/Option.hpp
modifié :         include/Attributes/AreaAttributes.hpp
	modifié :         include/Attributes/AreaAttributes.tpp
	modifié :         include/Attributes/AverageAttributes.hpp
	modifié :         include/Attributes/AverageAttributes.tpp
	modifié :         include/Attributes/MoIAttributes.hpp
	modifié :         include/Attributes/MoIAttributes.tpp
	modifié :         include/Attributes/SDAttributes.hpp
	modifié :         include/Attributes/SDAttributes.tpp
	modifié :         include/Attributes/WeightAttributes.hpp
	modifié :         include/Attributes/WeightAttributes.tpp
	modifié :         include/Attributes/XYAttributes.hpp
	modifié :         include/Attributes/XYAttributes.tpp
	modifié :         include/CompAttribute.hpp
	modifié :         include/CompAttribute.tpp
	modifié :         include/triskeleDealThreads.tpp
	modifié :         src/Appli/Option.cpp
	modifié :         src/IImage.cpp
	modifié :         src/apGenerator.cpp
2018-04-20 09:49:46 +02:00

57 lines
1.7 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)
: CompAttribute<WeightT> (tree) {
}
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 ();
CompAttribute<WeightT>::cut (allBands, attributeProfiles, 0., thresholds);
globalTreeStats.addTime (filteringStats, duration_cast<duration<double> > (high_resolution_clock::now ()-start).count ());
}
#endif // _OTB_TRISKELE_WEIGHT_ATTRIBUTES_TPP