#ifndef _OTB_TRISKELE_AVERAGE_ATTRIBUTES_TPP #define _OTB_TRISKELE_AVERAGE_ATTRIBUTES_TPP using namespace boost::chrono; template inline AverageAttributes::AverageAttributes (const Tree &tree, const Raster &raster, const AreaAttributes &areaAttributes) : CompAttribute (tree) { compute (raster, areaAttributes); } inline AverageAttributes::~AverageAttributes () { } template inline void AverageAttributes::compute (const Raster &raster, const AreaAttributes &areaAttributes) { auto start = high_resolution_clock::now (); const PixelT *pixels = raster.getPixels (); const DimImg *areas = areaAttributes.getValues (); computeSameCompLevel ([this, &pixels, &areas] (const DimImg &parentId) { double tmpAverage = 0.; tree.forEachChildTI (parentId, [this, &tmpAverage, &pixels, &areas] (const bool &isLeaf, const DimImg &childId) { tmpAverage += isLeaf ? pixels[childId] : (CompAttribute::values [childId] * areas[childId]); }); CompAttribute::values [parentId] = tmpAverage/areas[parentId]; }); globalTreeStats.addTime (averageStats, duration_cast > (high_resolution_clock::now ()-start).count ()); } #endif // _OTB_TRISKELE_AVERAGE_ATTRIBUTES_TPP