triskele/include/Attributes/SDAttributes.tpp
Git Merciol e09d2793e2 nouveau fichier : MakefileNoOTB
nouveau fichier : include/Attributes/AverageAttributes.hpp
	nouveau fichier : include/Attributes/AverageAttributes.tpp
	nouveau fichier : include/Attributes/SDAttributes.hpp
	nouveau fichier : include/Attributes/SDAttributes.tpp
	nouveau fichier : include/Attributes/XYAttributes.hpp
	nouveau fichier : include/Attributes/XYAttributes.tpp
	nouveau fichier : include/CompAttribute.hpp
	nouveau fichier : include/CompAttribute.tpp
2018-02-19 16:58:11 +01:00

33 lines
1.1 KiB
C++

#ifndef _OTB_TRISKELE_SD_ATTRIBUTES_TPP
#define _OTB_TRISKELE_SD_ATTRIBUTES_TPP
inline
SDAttributes::SDAttributes (const Tree &tree, const AreaAttributes &areaAttributes, const unsigned int &treeCoreCount)
: CompAttributeC<double> (tree, treeCoreCount) {
compute (areaAttributes);
}
inline
SDAttributes::~SDAttributes () {
}
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