#ifndef _OTB_TRISKELE_SD_ATTRIBUTES_TPP #define _OTB_TRISKELE_SD_ATTRIBUTES_TPP using namespace boost::chrono; inline SDAttributes::SDAttributes (const Tree &tree, const AreaAttributes &areaAttributes) : CompAttribute (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; auto start = high_resolution_clock::now (); double maxValue = CompAttribute::getMaxValue (); cerr << "sd max value:" << maxValue << endl; CompAttribute::cut (allBands, attributeProfiles, 0, CompAttribute::getScaledThresholds (thresholds, maxValue)); globalTreeStats.addTime (filteringStats, duration_cast > (high_resolution_clock::now ()-start).count ()); } inline void SDAttributes::compute (const AreaAttributes &areaAttributes) { auto start = high_resolution_clock::now (); 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]); }); globalTreeStats.addTime (sdStats, duration_cast > (high_resolution_clock::now ()-start).count ()); } #endif // _OTB_TRISKELE_SD_ATTRIBUTES_TPP