modifié : include/Appli/Option.hpp modifié : include/ArrayTree/GraphWalker.hpp modifié : include/Attributes/MoIAttributes.tpp modifié : include/Attributes/SDAttributes.tpp modifié : src/Appli/Option.cpp modifié : src/testMain.cpp
44 lines
1.5 KiB
C++
44 lines
1.5 KiB
C++
#ifndef _OTB_TRISKELE_SD_ATTRIBUTES_TPP
|
|
#define _OTB_TRISKELE_SD_ATTRIBUTES_TPP
|
|
|
|
inline
|
|
SDAttributes::SDAttributes (const Tree &tree, const AreaAttributes &areaAttributes)
|
|
: CompAttributeC<double> (tree) {
|
|
compute (areaAttributes);
|
|
}
|
|
|
|
inline
|
|
SDAttributes::~SDAttributes () {
|
|
}
|
|
|
|
template<typename PixelT>
|
|
inline void
|
|
SDAttributes::cut (vector<vector<PixelT> > &allBands, const AttributeProfiles<PixelT> &attributeProfiles,
|
|
const vector<double> &thresholds) const {
|
|
DEF_LOG ("SDAttributes::cut", "thresholds:" << thresholds.size ());
|
|
double maxValue = CompAttribute<double>::getMaxValue ();
|
|
cerr << "sd max value:" << maxValue << endl;
|
|
CompAttributeC<double>::cut (allBands, attributeProfiles, 0,
|
|
CompAttributeC<double>::getScaledThresholds (thresholds, maxValue));
|
|
}
|
|
|
|
inline void
|
|
SDAttributes::compute (const AreaAttributes &areaAttributes) {
|
|
const DimImg *areas = areaAttributes.getValues ();
|
|
computeSameCompLevel ([this, &areas] (const DimImg &parentId) {
|
|
double tmpSD = 0.;
|
|
tree.forEachChildTI (parentId, [this, &tmpSD, &areas, &parentId] (const bool &isLeaf, const DimImg &childId) {
|
|
if (isLeaf)
|
|
return;
|
|
double diff = areas [childId]-areas [parentId];
|
|
tmpSD += (diff * diff)*areas[childId];
|
|
});
|
|
CompAttribute<double>::values[parentId] = tmpSD / areas[parentId];
|
|
|
|
// XXX on peut virer pour gagner du temps et calculer SD*SD
|
|
CompAttribute<double>::values[parentId] = sqrt (CompAttribute<double>::values[parentId]);
|
|
});
|
|
}
|
|
|
|
#endif // _OTB_TRISKELE_SD_ATTRIBUTES_TPP
|