#ifndef _OTB_TRISKELE_SD_ATTRIBUTES_TPP #define _OTB_TRISKELE_SD_ATTRIBUTES_TPP inline SDAttributes::SDAttributes (const Tree &tree, const AreaAttributes &areaAttributes) : CompAttributeC (tree) { compute (areaAttributes); } inline SDAttributes::~SDAttributes () { } template inline void SDAttributes::cut (vector > &allBands, const AttributeProfiles &attributeProfiles, const vector &thresholds) const { DEF_LOG ("SDAttributes::cut", "thresholds:" << thresholds.size ()); if (!thresholds.size ()) return; double maxValue = CompAttribute::getMaxValue (); cerr << "sd max value:" << maxValue << endl; CompAttributeC::cut (allBands, attributeProfiles, 0, CompAttributeC::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::values[parentId] = tmpSD / areas[parentId]; // XXX on peut virer pour gagner du temps et calculer SD*SD CompAttribute::values[parentId] = sqrt (CompAttribute::values[parentId]); }); } #endif // _OTB_TRISKELE_SD_ATTRIBUTES_TPP