
modifié : include/Attributes/AreaAttributes.hpp modifié : include/Attributes/AreaAttributes.tpp modifié : include/Attributes/AverageAttributes.hpp modifié : include/Attributes/AverageAttributes.tpp modifié : include/Attributes/MoIAttributes.hpp modifié : include/Attributes/MoIAttributes.tpp modifié : include/Attributes/SDAttributes.hpp modifié : include/Attributes/SDAttributes.tpp modifié : include/Attributes/WeightAttributes.hpp modifié : include/Attributes/WeightAttributes.tpp modifié : include/Attributes/XYAttributes.hpp modifié : include/Attributes/XYAttributes.tpp modifié : include/CompAttribute.hpp modifié : include/CompAttribute.tpp modifié : include/triskeleDealThreads.tpp modifié : src/Appli/Option.cpp modifié : src/IImage.cpp modifié : src/apGenerator.cpp
54 lines
2.1 KiB
C++
54 lines
2.1 KiB
C++
#ifndef _OTB_TRISKELE_MOI_ATTRIBUTES_TPP
|
|
#define _OTB_TRISKELE_MOI_ATTRIBUTES_TPP
|
|
|
|
using namespace boost::chrono;
|
|
|
|
inline
|
|
MoIAttributes::MoIAttributes (const Tree &tree, const AreaAttributes &areaAttributes, const XYAttributes &xyAttributes)
|
|
: CompAttribute<double> (tree) {
|
|
compute (areaAttributes, xyAttributes);
|
|
}
|
|
|
|
inline
|
|
MoIAttributes::~MoIAttributes () {
|
|
}
|
|
|
|
template<typename PixelT>
|
|
inline void
|
|
MoIAttributes::cut (vector<vector<PixelT> > &allBands, const AttributeProfiles<PixelT> &attributeProfiles,
|
|
const vector<double> &thresholds) const {
|
|
DEF_LOG ("MoIAttributes::cut", "thresholds:" << thresholds.size ());
|
|
if (!thresholds.size ())
|
|
return;
|
|
auto start = high_resolution_clock::now ();
|
|
double maxValue = CompAttribute<double>::getMaxValue ();
|
|
cerr << "moi max value:" << maxValue << endl;
|
|
CompAttribute<double>::cut (allBands, attributeProfiles, 0,
|
|
CompAttribute<double>::getScaledThresholds (thresholds, maxValue));
|
|
globalTreeStats.addTime (filteringStats, duration_cast<duration<double> > (high_resolution_clock::now ()-start).count ());
|
|
}
|
|
|
|
inline void
|
|
MoIAttributes::compute (const AreaAttributes &areaAttributes, const XYAttributes &xyAttributes) {
|
|
auto start = high_resolution_clock::now ();
|
|
const AverageXY *xy = xyAttributes.getValues ();
|
|
const DimImg *areas = areaAttributes.getValues ();
|
|
computeSameCompLevel ([this, &xy, &areas] (const DimImg &parentId) {
|
|
double tmpMoI = 0.;
|
|
const double xa = xy[parentId].x;
|
|
const double ya = xy[parentId].y;
|
|
tree.forEachChildTI (parentId, [this, &tmpMoI, &xa, &ya, &xy, &areas, &parentId] (const bool &isLeaf, const DimImg &childId) {
|
|
if (isLeaf)
|
|
return;
|
|
const double dx = xy[childId].x - xa;
|
|
const double dy = xy[childId].y - ya;
|
|
tmpMoI += (dx*dx+dy*dy)*areas[childId];
|
|
});
|
|
const double card = areas[parentId];
|
|
CompAttribute<double>::values[parentId] = tmpMoI/(card*card);
|
|
});
|
|
globalTreeStats.addTime (moiStats, duration_cast<duration<double> > (high_resolution_clock::now ()-start).count ());
|
|
}
|
|
|
|
#endif // _OTB_TRISKELE_MOI_ATTRIBUTES_TPP
|