triskele/include/AttributeProfiles.tpp
Git Merciol 7722357a1b nouveau fichier : data/levelThresholds.txt
modifié :         include/Appli/Option.hpp
	modifié :         include/AttributeProfiles.hpp
	modifié :         include/AttributeProfiles.tpp
	modifié :         include/Attributes/AverageAttributes.hpp
	modifié :         src/Appli/Option.cpp
	modifié :         src/apGenerator.cpp
2018-04-20 16:27:52 +02:00

83 lines
2.2 KiB
C++

#ifndef _OTB_TRISKELE_ATTRIBUTE_PROFILES_TPP
#define _OTB_TRISKELE_ATTRIBUTE_PROFILES_TPP
// ========================================
template<typename PixelT>
inline
AttributeProfiles<PixelT>::AttributeProfiles (const Tree &tree)
: tree (tree),
leafCount (0),
values () {
updateTranscient ();
}
template<typename PixelT>
inline
AttributeProfiles<PixelT>::~AttributeProfiles () {
free ();
}
template<typename PixelT>
inline void
AttributeProfiles<PixelT>::updateTranscient () {
book (tree.getLeafCount ());
}
template<typename PixelT>
inline PixelT *
AttributeProfiles<PixelT>::getValues () {
return &values[0];
}
template<typename PixelT>
inline const PixelT *
AttributeProfiles<PixelT>::getValues () const {
return &values[0];
}
// ========================================
template<typename PixelT>
template<typename WeightT>
inline void
AttributeProfiles<PixelT>::setValues (const PixelT *pixels, const WeightT *weights) {
updateTranscient ();
PixelT *leafAP = &values[0];
dealThreadBound (tree.getLeafCount (), tree.getCoreCount (), [&leafAP, &pixels] (const DimImg &minVal, const DimImg &maxVal) {
for (DimImg i = minVal; i < maxVal; ++i)
leafAP[i] = pixels [i];
});
PixelT *compAP = leafAP+tree.getLeafCount ();
dealThreadBound (tree.getCompCount (), tree.getCoreCount (), [&compAP, &weights] (const DimImg &minVal, const DimImg &maxVal) {
for (DimImg compIdx = minVal; compIdx < maxVal; ++compIdx)
compAP[compIdx] = weights[compIdx];
});
}
template<typename PixelT>
inline void
AttributeProfiles<PixelT>::free () {
values = vector<PixelT> ();
}
template<typename PixelT>
inline void
AttributeProfiles<PixelT>::book (const DimImg &leafCount) {
this->leafCount = leafCount;
// XXX max : leafCount*2-1
values.resize (leafCount*2);
}
// ========================================
template<typename PixelT>
ostream &
AttributeProfiles<PixelT>::print (ostream &out) const {
const Size doubleSize (tree.getSize().width, 2*tree.getSize ().height);
out << "AP" << endl
<< printMap (&values[0], doubleSize, tree.getNodeCount ()) << endl << endl;
return out;
}
// ========================================
#endif // _OTB_TRISKELE_ATTRIBUTE_PROFILES_TPP