modifié : include/Appli/Option.hpp
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
This commit is contained in:
parent
f687310939
commit
aff93d5467
@ -25,7 +25,7 @@ namespace otb {
|
|||||||
Selected selectedBand;
|
Selected selectedBand;
|
||||||
size_t countingSortCeil = 2;
|
size_t countingSortCeil = 2;
|
||||||
vector<DimImg> areaThresholds;
|
vector<DimImg> areaThresholds;
|
||||||
vector<double> sdThresholds, moiThresholds;
|
vector<double> levelThresholds, sdThresholds, moiThresholds;
|
||||||
unsigned int coreCount = boost::thread::hardware_concurrency ();
|
unsigned int coreCount = boost::thread::hardware_concurrency ();
|
||||||
bool maxTreeFlag = false, minTreeFlag = false, tosTreeFlag = false, alphaTreeFlag = false;
|
bool maxTreeFlag = false, minTreeFlag = false, tosTreeFlag = false, alphaTreeFlag = false;
|
||||||
bool oneBand = false;
|
bool oneBand = false;
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
namespace otb {
|
namespace otb {
|
||||||
namespace triskele {
|
namespace triskele {
|
||||||
|
|
||||||
class AreaAttributes : public CompAttributeC<DimImg> {
|
class AreaAttributes : public CompAttribute<DimImg> {
|
||||||
public:
|
public:
|
||||||
inline AreaAttributes (const Tree &tree);
|
inline AreaAttributes (const Tree &tree);
|
||||||
inline ~AreaAttributes ();
|
inline ~AreaAttributes ();
|
||||||
|
@ -5,7 +5,7 @@ using namespace boost::chrono;
|
|||||||
|
|
||||||
inline
|
inline
|
||||||
AreaAttributes::AreaAttributes (const Tree &tree)
|
AreaAttributes::AreaAttributes (const Tree &tree)
|
||||||
: CompAttributeC<DimImg> (tree) {
|
: CompAttribute<DimImg> (tree) {
|
||||||
compute ();
|
compute ();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -18,7 +18,7 @@ inline void
|
|||||||
AreaAttributes::cut (vector<vector<PixelT> > &allBands, const AttributeProfiles<PixelT> &attributeProfiles,
|
AreaAttributes::cut (vector<vector<PixelT> > &allBands, const AttributeProfiles<PixelT> &attributeProfiles,
|
||||||
const vector<DimImg> &thresholds) const {
|
const vector<DimImg> &thresholds) const {
|
||||||
auto start = high_resolution_clock::now ();
|
auto start = high_resolution_clock::now ();
|
||||||
CompAttributeC<DimImg>::cut (allBands, attributeProfiles, 1, thresholds);
|
CompAttribute<DimImg>::cut (allBands, attributeProfiles, 1, thresholds);
|
||||||
globalTreeStats.addTime (filteringStats, duration_cast<duration<double> > (high_resolution_clock::now ()-start).count ());
|
globalTreeStats.addTime (filteringStats, duration_cast<duration<double> > (high_resolution_clock::now ()-start).count ());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
namespace otb {
|
namespace otb {
|
||||||
namespace triskele {
|
namespace triskele {
|
||||||
|
|
||||||
class AverageAttributes : public CompAttributeC<double> {
|
class AverageAttributes : public CompAttribute<double> {
|
||||||
public:
|
public:
|
||||||
template<typename PixelT>
|
template<typename PixelT>
|
||||||
inline AverageAttributes (const Tree &tree, const Raster<PixelT> &raster, const AreaAttributes &areaAttributes);
|
inline AverageAttributes (const Tree &tree, const Raster<PixelT> &raster, const AreaAttributes &areaAttributes);
|
||||||
|
@ -6,7 +6,7 @@ using namespace boost::chrono;
|
|||||||
template<typename PixelT>
|
template<typename PixelT>
|
||||||
inline
|
inline
|
||||||
AverageAttributes::AverageAttributes (const Tree &tree, const Raster<PixelT> &raster, const AreaAttributes &areaAttributes)
|
AverageAttributes::AverageAttributes (const Tree &tree, const Raster<PixelT> &raster, const AreaAttributes &areaAttributes)
|
||||||
: CompAttributeC<double> (tree) {
|
: CompAttribute<double> (tree) {
|
||||||
compute (raster, areaAttributes);
|
compute (raster, areaAttributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
namespace otb {
|
namespace otb {
|
||||||
namespace triskele {
|
namespace triskele {
|
||||||
|
|
||||||
class MoIAttributes : public CompAttributeC<double> {
|
class MoIAttributes : public CompAttribute<double> {
|
||||||
public:
|
public:
|
||||||
inline MoIAttributes (const Tree &tree, const AreaAttributes &areaAttributes, const XYAttributes &xyAttributes);
|
inline MoIAttributes (const Tree &tree, const AreaAttributes &areaAttributes, const XYAttributes &xyAttributes);
|
||||||
inline ~MoIAttributes ();
|
inline ~MoIAttributes ();
|
||||||
|
@ -5,7 +5,7 @@ using namespace boost::chrono;
|
|||||||
|
|
||||||
inline
|
inline
|
||||||
MoIAttributes::MoIAttributes (const Tree &tree, const AreaAttributes &areaAttributes, const XYAttributes &xyAttributes)
|
MoIAttributes::MoIAttributes (const Tree &tree, const AreaAttributes &areaAttributes, const XYAttributes &xyAttributes)
|
||||||
: CompAttributeC<double> (tree) {
|
: CompAttribute<double> (tree) {
|
||||||
compute (areaAttributes, xyAttributes);
|
compute (areaAttributes, xyAttributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -23,8 +23,8 @@ MoIAttributes::cut (vector<vector<PixelT> > &allBands, const AttributeProfiles<P
|
|||||||
auto start = high_resolution_clock::now ();
|
auto start = high_resolution_clock::now ();
|
||||||
double maxValue = CompAttribute<double>::getMaxValue ();
|
double maxValue = CompAttribute<double>::getMaxValue ();
|
||||||
cerr << "moi max value:" << maxValue << endl;
|
cerr << "moi max value:" << maxValue << endl;
|
||||||
CompAttributeC<double>::cut (allBands, attributeProfiles, 0,
|
CompAttribute<double>::cut (allBands, attributeProfiles, 0,
|
||||||
CompAttributeC<double>::getScaledThresholds (thresholds, maxValue));
|
CompAttribute<double>::getScaledThresholds (thresholds, maxValue));
|
||||||
globalTreeStats.addTime (filteringStats, duration_cast<duration<double> > (high_resolution_clock::now ()-start).count ());
|
globalTreeStats.addTime (filteringStats, duration_cast<duration<double> > (high_resolution_clock::now ()-start).count ());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
namespace otb {
|
namespace otb {
|
||||||
namespace triskele {
|
namespace triskele {
|
||||||
|
|
||||||
class SDAttributes : public CompAttributeC<double> {
|
class SDAttributes : public CompAttribute<double> {
|
||||||
public:
|
public:
|
||||||
inline SDAttributes (const Tree &tree, const AreaAttributes &areaAttributes);
|
inline SDAttributes (const Tree &tree, const AreaAttributes &areaAttributes);
|
||||||
inline ~SDAttributes ();
|
inline ~SDAttributes ();
|
||||||
|
@ -5,7 +5,7 @@ using namespace boost::chrono;
|
|||||||
|
|
||||||
inline
|
inline
|
||||||
SDAttributes::SDAttributes (const Tree &tree, const AreaAttributes &areaAttributes)
|
SDAttributes::SDAttributes (const Tree &tree, const AreaAttributes &areaAttributes)
|
||||||
: CompAttributeC<double> (tree) {
|
: CompAttribute<double> (tree) {
|
||||||
compute (areaAttributes);
|
compute (areaAttributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -23,8 +23,8 @@ SDAttributes::cut (vector<vector<PixelT> > &allBands, const AttributeProfiles<Pi
|
|||||||
auto start = high_resolution_clock::now ();
|
auto start = high_resolution_clock::now ();
|
||||||
double maxValue = CompAttribute<double>::getMaxValue ();
|
double maxValue = CompAttribute<double>::getMaxValue ();
|
||||||
cerr << "sd max value:" << maxValue << endl;
|
cerr << "sd max value:" << maxValue << endl;
|
||||||
CompAttributeC<double>::cut (allBands, attributeProfiles, 0,
|
CompAttribute<double>::cut (allBands, attributeProfiles, 0,
|
||||||
CompAttributeC<double>::getScaledThresholds (thresholds, maxValue));
|
CompAttribute<double>::getScaledThresholds (thresholds, maxValue));
|
||||||
globalTreeStats.addTime (filteringStats, duration_cast<duration<double> > (high_resolution_clock::now ()-start).count ());
|
globalTreeStats.addTime (filteringStats, duration_cast<duration<double> > (high_resolution_clock::now ()-start).count ());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
#ifndef _OTB_TRISKELE_WEIGHT_ATTRIBUTES_HPP
|
#ifndef _OTB_TRISKELE_WEIGHT_ATTRIBUTES_HPP
|
||||||
#define _OTB_TRISKELE_WEIGHT_ATTRIBUTES_HPP
|
#define _OTB_TRISKELE_WEIGHT_ATTRIBUTES_HPP
|
||||||
|
|
||||||
|
#include <boost/chrono.hpp>
|
||||||
|
|
||||||
#include "triskeleBase.hpp"
|
#include "triskeleBase.hpp"
|
||||||
|
|
||||||
namespace otb {
|
namespace otb {
|
||||||
@ -15,6 +17,9 @@ namespace otb {
|
|||||||
inline ~WeightAttributes ();
|
inline ~WeightAttributes ();
|
||||||
|
|
||||||
inline void setWeightBounds (Tree &tree);
|
inline void setWeightBounds (Tree &tree);
|
||||||
|
template<typename PixelT>
|
||||||
|
inline void cut (vector<vector<PixelT> > &allBands, const AttributeProfiles<PixelT> &attributeProfiles,
|
||||||
|
const vector<WeightT> &thresholds) const;
|
||||||
|
|
||||||
virtual inline ostream &print (ostream &out) const { CompAttribute<WeightT>::print (out, "weight"); return out; }
|
virtual inline ostream &print (ostream &out) const { CompAttribute<WeightT>::print (out, "weight"); return out; }
|
||||||
};
|
};
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
#ifndef _OTB_TRISKELE_WEIGHT_ATTRIBUTES_TPP
|
#ifndef _OTB_TRISKELE_WEIGHT_ATTRIBUTES_TPP
|
||||||
#define _OTB_TRISKELE_WEIGHT_ATTRIBUTES_TPP
|
#define _OTB_TRISKELE_WEIGHT_ATTRIBUTES_TPP
|
||||||
|
|
||||||
|
using namespace boost::chrono;
|
||||||
|
|
||||||
template<typename WeightT>
|
template<typename WeightT>
|
||||||
inline
|
inline
|
||||||
WeightAttributes<WeightT>::WeightAttributes (const Tree &tree)
|
WeightAttributes<WeightT>::WeightAttributes (const Tree &tree)
|
||||||
@ -39,4 +41,16 @@ WeightAttributes<WeightT>::setWeightBounds (Tree &tree) {
|
|||||||
weightBounds.push_back (rootId+1);
|
weightBounds.push_back (rootId+1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<typename WeightT>
|
||||||
|
template<typename PixelT>
|
||||||
|
inline void
|
||||||
|
WeightAttributes<WeightT>::cut (vector<vector<PixelT> > &allBands, const AttributeProfiles<PixelT> &attributeProfiles,
|
||||||
|
const vector<WeightT> &thresholds) const {
|
||||||
|
auto start = high_resolution_clock::now ();
|
||||||
|
CompAttribute<WeightT>::cut (allBands, attributeProfiles, 0., thresholds);
|
||||||
|
globalTreeStats.addTime (filteringStats, duration_cast<duration<double> > (high_resolution_clock::now ()-start).count ());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // _OTB_TRISKELE_WEIGHT_ATTRIBUTES_TPP
|
#endif // _OTB_TRISKELE_WEIGHT_ATTRIBUTES_TPP
|
||||||
|
@ -18,7 +18,7 @@ namespace otb {
|
|||||||
operator DimImg () const { return (DimImg) (x*y); }
|
operator DimImg () const { return (DimImg) (x*y); }
|
||||||
};
|
};
|
||||||
|
|
||||||
class XYAttributes : public CompAttributeC<AverageXY> {
|
class XYAttributes : public CompAttribute<AverageXY> {
|
||||||
public:
|
public:
|
||||||
inline XYAttributes (const Tree &tree, const AreaAttributes &areaAttributes);
|
inline XYAttributes (const Tree &tree, const AreaAttributes &areaAttributes);
|
||||||
inline ~XYAttributes ();
|
inline ~XYAttributes ();
|
||||||
|
@ -5,7 +5,7 @@ using namespace boost::chrono;
|
|||||||
|
|
||||||
inline
|
inline
|
||||||
XYAttributes::XYAttributes (const Tree &tree, const AreaAttributes &areaAttributes)
|
XYAttributes::XYAttributes (const Tree &tree, const AreaAttributes &areaAttributes)
|
||||||
: CompAttributeC<AverageXY> (tree) {
|
: CompAttribute<AverageXY> (tree) {
|
||||||
compute (areaAttributes);
|
compute (areaAttributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,6 +14,9 @@ namespace otb {
|
|||||||
template<typename AttrT>
|
template<typename AttrT>
|
||||||
class CompAttribute {
|
class CompAttribute {
|
||||||
public:
|
public:
|
||||||
|
static inline vector<AttrT> getScaledThresholds (const vector<double> &thresholds, const AttrT &maxValue);
|
||||||
|
static inline vector<AttrT> getConvertedThresholds (const vector<double> &thresholds);
|
||||||
|
|
||||||
inline CompAttribute (const Tree &tree);
|
inline CompAttribute (const Tree &tree);
|
||||||
inline ~CompAttribute ();
|
inline ~CompAttribute ();
|
||||||
|
|
||||||
@ -22,6 +25,14 @@ namespace otb {
|
|||||||
inline AttrT *getValues ();
|
inline AttrT *getValues ();
|
||||||
inline AttrT getMaxValue () const;
|
inline AttrT getMaxValue () const;
|
||||||
|
|
||||||
|
template<typename PixelT>
|
||||||
|
inline void cut (vector<vector<PixelT> > &allBands, const AttributeProfiles<PixelT> &attributeProfiles,
|
||||||
|
const AttrT &pixelAttrValue, const vector<AttrT> &thresholds) const;
|
||||||
|
|
||||||
|
template<typename PixelT>
|
||||||
|
inline void cutOnPos (vector<vector<PixelT> > &allBands, const AttributeProfiles<PixelT> &attributeProfiles,
|
||||||
|
const DimImg &pixelId, const AttrT &pixelAttrValue, const vector<AttrT> &thresholds) const;
|
||||||
|
|
||||||
virtual inline ostream &print (ostream &out) const { print (out, ""); return out; }
|
virtual inline ostream &print (ostream &out) const { print (out, ""); return out; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -32,39 +43,19 @@ namespace otb {
|
|||||||
inline void free ();
|
inline void free ();
|
||||||
inline void book (const DimImg &leafCount);
|
inline void book (const DimImg &leafCount);
|
||||||
|
|
||||||
|
template<typename CumpFunctPSE>
|
||||||
|
inline void computeSameCompLevel (const CumpFunctPSE &cumpFunctPSE /* cumpFunctPSE (DimImg parentId)*/) const;
|
||||||
|
|
||||||
ostream &print (ostream &out, const string &msg) const;
|
ostream &print (ostream &out, const string &msg) const;
|
||||||
friend ostream &operator << (ostream& out, const CompAttribute &ca) { return ca.print (out); }
|
friend ostream &operator << (ostream& out, const CompAttribute &ca) { return ca.print (out); return out; }
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // triskele
|
} // triskele
|
||||||
} // otb
|
} // otb
|
||||||
|
|
||||||
#include "Attributes/WeightAttributes.hpp"
|
#include "Attributes/WeightAttributes.hpp"
|
||||||
|
|
||||||
namespace otb {
|
namespace otb {
|
||||||
namespace triskele {
|
namespace triskele {
|
||||||
|
|
||||||
template<typename AttrT>
|
|
||||||
class CompAttributeC : public CompAttribute<AttrT> {
|
|
||||||
public:
|
|
||||||
inline CompAttributeC (const Tree &tree);
|
|
||||||
inline ~CompAttributeC ();
|
|
||||||
|
|
||||||
static inline vector<AttrT> getScaledThresholds (const vector<double> &thresholds, const AttrT &maxValue);
|
|
||||||
|
|
||||||
template<typename PixelT>
|
|
||||||
inline void cut (vector<vector<PixelT> > &allBands, const AttributeProfiles<PixelT> &attributeProfiles,
|
|
||||||
const AttrT &pixelAttrValue, const vector<AttrT> &thresholds) const;
|
|
||||||
|
|
||||||
template<typename PixelT>
|
|
||||||
inline void cutOnPos (vector<vector<PixelT> > &allBands, const AttributeProfiles<PixelT> &attributeProfiles,
|
|
||||||
const DimImg &pixelId, const AttrT &pixelAttrValue, const vector<AttrT> &thresholds) const;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
template<typename CumpFunctPSE>
|
|
||||||
inline void computeSameCompLevel (const CumpFunctPSE &cumpFunctPSE /* cumpFunctPSE (DimImg parentId)*/) const;
|
|
||||||
};
|
|
||||||
|
|
||||||
#include "CompAttribute.tpp"
|
#include "CompAttribute.tpp"
|
||||||
} // triskele
|
} // triskele
|
||||||
} // otb
|
} // otb
|
||||||
|
@ -1,6 +1,26 @@
|
|||||||
#ifndef _OTB_TRISKELE_COMP_ATTRIBUTE_TPP
|
#ifndef _OTB_TRISKELE_COMP_ATTRIBUTE_TPP
|
||||||
#define _OTB_TRISKELE_COMP_ATTRIBUTE_TPP
|
#define _OTB_TRISKELE_COMP_ATTRIBUTE_TPP
|
||||||
|
|
||||||
|
// ========================================
|
||||||
|
template<typename AttrT>
|
||||||
|
inline vector<AttrT>
|
||||||
|
CompAttribute<AttrT>::getScaledThresholds (const vector<double> &thresholds, const AttrT &maxValue) {
|
||||||
|
vector<AttrT> result;
|
||||||
|
for (double percent : thresholds)
|
||||||
|
result.push_back (percent*maxValue);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename AttrT>
|
||||||
|
inline vector<AttrT>
|
||||||
|
CompAttribute<AttrT>::getConvertedThresholds (const vector<double> &thresholds) {
|
||||||
|
vector<AttrT> result;
|
||||||
|
for (double value : thresholds)
|
||||||
|
result.push_back ((AttrT) value);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ========================================
|
||||||
template<typename AttrT>
|
template<typename AttrT>
|
||||||
inline
|
inline
|
||||||
CompAttribute<AttrT>::CompAttribute (const Tree &tree)
|
CompAttribute<AttrT>::CompAttribute (const Tree &tree)
|
||||||
@ -47,78 +67,13 @@ CompAttribute<AttrT>::getMaxValue () const {
|
|||||||
return max;
|
return max;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename AttrT>
|
|
||||||
inline ostream &
|
|
||||||
CompAttribute<AttrT>::print (ostream &out, const string &msg) const {
|
|
||||||
cout << "values: " << msg << endl;
|
|
||||||
const Size doubleSize (tree.getSize().width, 2*tree.getSize ().height);
|
|
||||||
return cout << printMap (&values[0], doubleSize, tree.getCompCount ()) << endl << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename AttrT>
|
|
||||||
inline void
|
|
||||||
CompAttribute<AttrT>::free () {
|
|
||||||
values = vector<AttrT> ();
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename AttrT>
|
|
||||||
inline void
|
|
||||||
CompAttribute<AttrT>::book (const DimImg &leafCount) {
|
|
||||||
this->leafCount = leafCount;
|
|
||||||
values.resize (leafCount);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ========================================
|
// ========================================
|
||||||
template<typename AttrT>
|
|
||||||
inline
|
|
||||||
CompAttributeC<AttrT>::CompAttributeC (const Tree &tree)
|
|
||||||
: CompAttribute<AttrT> (tree) {
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename AttrT>
|
|
||||||
inline
|
|
||||||
CompAttributeC<AttrT>::~CompAttributeC () {
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename AttrT>
|
|
||||||
inline vector<AttrT>
|
|
||||||
CompAttributeC<AttrT>::getScaledThresholds (const vector<double> &thresholds, const AttrT &maxValue) {
|
|
||||||
vector<AttrT> result;
|
|
||||||
for (AttrT percent : thresholds)
|
|
||||||
result.push_back (percent*maxValue);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<typename AttrT>
|
|
||||||
template<typename CumpFunctPSE>
|
|
||||||
inline void
|
|
||||||
CompAttributeC<AttrT>::computeSameCompLevel (const CumpFunctPSE &cumpFunctPSE) const {
|
|
||||||
const vector<DimImg> &weightBounds (CompAttribute<AttrT>::tree.getWeightBounds ());
|
|
||||||
unsigned int coreCount = CompAttribute<AttrT>::tree.getCoreCount ();
|
|
||||||
DEF_LOG ("CompAttributeC::computeSameCompLevel", "coreCount:" << coreCount);
|
|
||||||
if (!weightBounds.size () || CompAttribute<AttrT>::tree.getCompCount ()/weightBounds.size () < coreCount) {
|
|
||||||
LOG ("CompAttributeC::computeSameCompLevel: no thread");
|
|
||||||
CompAttribute<AttrT>::tree.forEachComp (cumpFunctPSE);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
DimImg first = weightBounds [0];
|
|
||||||
for (DimImg curBound = 1; curBound < weightBounds.size (); curBound++) {
|
|
||||||
DimImg next = weightBounds [curBound];
|
|
||||||
dealThreadRange (next-first, coreCount, [this, &first, &cumpFunctPSE] (const DimImg &id) {
|
|
||||||
const DimImg parentId = id+first;
|
|
||||||
cumpFunctPSE (parentId);
|
|
||||||
});
|
|
||||||
first = next;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename AttrT>
|
template<typename AttrT>
|
||||||
template<typename PixelT>
|
template<typename PixelT>
|
||||||
inline void
|
inline void
|
||||||
CompAttributeC<AttrT>::cut (vector<vector<PixelT> > &allBands, const AttributeProfiles<PixelT> &attributeProfiles,
|
CompAttribute<AttrT>::cut (vector<vector<PixelT> > &allBands, const AttributeProfiles<PixelT> &attributeProfiles,
|
||||||
const AttrT &pixelAttrValue, const vector<AttrT> &thresholds) const {
|
const AttrT &pixelAttrValue, const vector<AttrT> &thresholds) const {
|
||||||
DEF_LOG ("CompAttributeC::cut", "coreCount:" << CompAttribute<AttrT>::tree.getCoreCount () << " thresholds:" << thresholds.size ());
|
DEF_LOG ("CompAttribute::cut", "coreCount:" << CompAttribute<AttrT>::tree.getCoreCount () << " thresholds:" << thresholds.size ());
|
||||||
dealThreadRange (CompAttribute<AttrT>::leafCount, CompAttribute<AttrT>::tree.getCoreCount (), [this, &allBands, &attributeProfiles, &pixelAttrValue, &thresholds] (const DimImg &leafId) {
|
dealThreadRange (CompAttribute<AttrT>::leafCount, CompAttribute<AttrT>::tree.getCoreCount (), [this, &allBands, &attributeProfiles, &pixelAttrValue, &thresholds] (const DimImg &leafId) {
|
||||||
cutOnPos (allBands, attributeProfiles, leafId, pixelAttrValue, thresholds);
|
cutOnPos (allBands, attributeProfiles, leafId, pixelAttrValue, thresholds);
|
||||||
});
|
});
|
||||||
@ -127,7 +82,7 @@ CompAttributeC<AttrT>::cut (vector<vector<PixelT> > &allBands, const AttributePr
|
|||||||
template<typename AttrT>
|
template<typename AttrT>
|
||||||
template<typename PixelT>
|
template<typename PixelT>
|
||||||
inline void
|
inline void
|
||||||
CompAttributeC<AttrT>::cutOnPos (vector<vector<PixelT> > &allBands, const AttributeProfiles<PixelT> &attributeProfiles,
|
CompAttribute<AttrT>::cutOnPos (vector<vector<PixelT> > &allBands, const AttributeProfiles<PixelT> &attributeProfiles,
|
||||||
const DimImg &leafId, const AttrT &pixelAttrValue, const vector<AttrT> &thresholds) const {
|
const DimImg &leafId, const AttrT &pixelAttrValue, const vector<AttrT> &thresholds) const {
|
||||||
// no debug (to many pixels)
|
// no debug (to many pixels)
|
||||||
DimImg parentId = CompAttribute<AttrT>::tree.getLeafParent (leafId);
|
DimImg parentId = CompAttribute<AttrT>::tree.getLeafParent (leafId);
|
||||||
@ -152,7 +107,7 @@ CompAttributeC<AttrT>::cutOnPos (vector<vector<PixelT> > &allBands, const Attrib
|
|||||||
AttrT ceil = thresholds[chanel];
|
AttrT ceil = thresholds[chanel];
|
||||||
for ( ; curValue < ceil && curId < rootId; ) {
|
for ( ; curValue < ceil && curId < rootId; ) {
|
||||||
if (parentId == DimImg_MAX || curId >= parentId) {
|
if (parentId == DimImg_MAX || curId >= parentId) {
|
||||||
// cerr << "CompAttributeC::cutOnPos find sub-root:" << rootId << " rootId:" << rootId << endl;
|
// cerr << "CompAttribute::cutOnPos find sub-root:" << rootId << " rootId:" << rootId << endl;
|
||||||
for (; chanel < thresholdsSize; ++chanel)
|
for (; chanel < thresholdsSize; ++chanel)
|
||||||
allBands[chanel][leafId] = curValue;
|
allBands[chanel][leafId] = curValue;
|
||||||
return;
|
return;
|
||||||
@ -167,4 +122,53 @@ CompAttributeC<AttrT>::cutOnPos (vector<vector<PixelT> > &allBands, const Attrib
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ========================================
|
||||||
|
template<typename AttrT>
|
||||||
|
inline ostream &
|
||||||
|
CompAttribute<AttrT>::print (ostream &out, const string &msg) const {
|
||||||
|
cout << "values: " << msg << endl;
|
||||||
|
const Size doubleSize (tree.getSize().width, 2*tree.getSize ().height);
|
||||||
|
cout << printMap (&values[0], doubleSize, tree.getCompCount ()) << endl << endl;
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ========================================
|
||||||
|
template<typename AttrT>
|
||||||
|
inline void
|
||||||
|
CompAttribute<AttrT>::free () {
|
||||||
|
values = vector<AttrT> ();
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename AttrT>
|
||||||
|
inline void
|
||||||
|
CompAttribute<AttrT>::book (const DimImg &leafCount) {
|
||||||
|
this->leafCount = leafCount;
|
||||||
|
values.resize (leafCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ========================================
|
||||||
|
template<typename AttrT>
|
||||||
|
template<typename CumpFunctPSE>
|
||||||
|
inline void
|
||||||
|
CompAttribute<AttrT>::computeSameCompLevel (const CumpFunctPSE &cumpFunctPSE) const {
|
||||||
|
const vector<DimImg> &weightBounds (CompAttribute<AttrT>::tree.getWeightBounds ());
|
||||||
|
unsigned int coreCount = CompAttribute<AttrT>::tree.getCoreCount ();
|
||||||
|
DEF_LOG ("CompAttribute::computeSameCompLevel", "coreCount:" << coreCount);
|
||||||
|
if (!weightBounds.size () || CompAttribute<AttrT>::tree.getCompCount ()/weightBounds.size () < coreCount) {
|
||||||
|
LOG ("CompAttribute::computeSameCompLevel: no thread");
|
||||||
|
CompAttribute<AttrT>::tree.forEachComp (cumpFunctPSE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
DimImg first = weightBounds [0];
|
||||||
|
for (DimImg curBound = 1; curBound < weightBounds.size (); curBound++) {
|
||||||
|
DimImg next = weightBounds [curBound];
|
||||||
|
dealThreadRange (next-first, coreCount, [this, &first, &cumpFunctPSE] (const DimImg &id) {
|
||||||
|
const DimImg parentId = id+first;
|
||||||
|
cumpFunctPSE (parentId);
|
||||||
|
});
|
||||||
|
first = next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ========================================
|
||||||
#endif // _OTB_TRISKELE_COMP_ATTRIBUTE_TPP
|
#endif // _OTB_TRISKELE_COMP_ATTRIBUTE_TPP
|
||||||
|
@ -71,7 +71,7 @@ dealThread (const DimImg &maxId, unsigned int coreCount, const FunctThreadMinMax
|
|||||||
functThreadMinMax (idCopyValInThread, maxIds[idCopyValInThread], maxIds[idCopyValInThread+1]);
|
functThreadMinMax (idCopyValInThread, maxIds[idCopyValInThread], maxIds[idCopyValInThread+1]);
|
||||||
});
|
});
|
||||||
#else /* BOOST thread */
|
#else /* BOOST thread */
|
||||||
boost::thread tasks [coreCount];
|
std::vector<boost::thread> tasks;
|
||||||
for (unsigned int idCopyValInThread = 0; idCopyValInThread < coreCount; ++idCopyValInThread) {
|
for (unsigned int idCopyValInThread = 0; idCopyValInThread < coreCount; ++idCopyValInThread) {
|
||||||
tasks.push_back (boost::thread ([/*no ref!!!*/idCopyValInThread, &maxIds, &functThreadMinMax] () {
|
tasks.push_back (boost::thread ([/*no ref!!!*/idCopyValInThread, &maxIds, &functThreadMinMax] () {
|
||||||
functThreadMinMax (idCopyValInThread, maxIds[idCopyValInThread], maxIds[idCopyValInThread+1]);
|
functThreadMinMax (idCopyValInThread, maxIds[idCopyValInThread], maxIds[idCopyValInThread+1]);
|
||||||
|
@ -97,7 +97,7 @@ Option::parse (int argc, char** argv) {
|
|||||||
bool helpFlag = false, versionFlag = false, useTheForceLuke = false;
|
bool helpFlag = false, versionFlag = false, useTheForceLuke = false;
|
||||||
string inputFileName, outputFileName, bandsRange;
|
string inputFileName, outputFileName, bandsRange;
|
||||||
long left = -1, top = -1, width = -1, height = -1;
|
long left = -1, top = -1, width = -1, height = -1;
|
||||||
string areaThresholdsName, sdThresholdsName, moiThresholdsName;
|
string areaThresholdsName, levelThresholdsName, sdThresholdsName, moiThresholdsName;
|
||||||
try {
|
try {
|
||||||
desc.add_options ()
|
desc.add_options ()
|
||||||
("help", po::bool_switch (&helpFlag), "produce this help message")
|
("help", po::bool_switch (&helpFlag), "produce this help message")
|
||||||
@ -115,6 +115,7 @@ Option::parse (int argc, char** argv) {
|
|||||||
("tos-tree", po::bool_switch (&tosTreeFlag), "build tree-of-shape")
|
("tos-tree", po::bool_switch (&tosTreeFlag), "build tree-of-shape")
|
||||||
("alpha-tree", po::bool_switch (&alphaTreeFlag), "build alpha-tree")
|
("alpha-tree", po::bool_switch (&alphaTreeFlag), "build alpha-tree")
|
||||||
("area,A", po::value<string> (&areaThresholdsName), "produce area attributs")
|
("area,A", po::value<string> (&areaThresholdsName), "produce area attributs")
|
||||||
|
("level,L", po::value<string> (&levelThresholdsName), "produce level attributs")
|
||||||
("standard-deviation,S", po::value<string> (&sdThresholdsName), "produce standard deviation attributs")
|
("standard-deviation,S", po::value<string> (&sdThresholdsName), "produce standard deviation attributs")
|
||||||
("moment-of-inertia,M", po::value<string> (&moiThresholdsName), "produce moment of inertia attributs")
|
("moment-of-inertia,M", po::value<string> (&moiThresholdsName), "produce moment of inertia attributs")
|
||||||
;
|
;
|
||||||
@ -186,6 +187,7 @@ Option::parse (int argc, char** argv) {
|
|||||||
usage ("Bad options");
|
usage ("Bad options");
|
||||||
}
|
}
|
||||||
areaThresholds = readThresholds<DimImg> (areaThresholdsName);
|
areaThresholds = readThresholds<DimImg> (areaThresholdsName);
|
||||||
|
levelThresholds = readThresholds<double> (levelThresholdsName);
|
||||||
sdThresholds = readThresholds<double> (sdThresholdsName);
|
sdThresholds = readThresholds<double> (sdThresholdsName);
|
||||||
moiThresholds = readThresholds<double> (moiThresholdsName);
|
moiThresholds = readThresholds<double> (moiThresholdsName);
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ IImage::~IImage () {
|
|||||||
|
|
||||||
void
|
void
|
||||||
IImage::readImage () {
|
IImage::readImage () {
|
||||||
DEF_LOG ("IImage::readImage", "fileName: " << fileName);
|
DEF_LOG ("IImage::readImage", "fileName: " << fileName << " c_str:" << fileName.c_str ());
|
||||||
BOOST_ASSERT (gdalInputDataset == nullptr);
|
BOOST_ASSERT (gdalInputDataset == nullptr);
|
||||||
BOOST_ASSERT (gdalOutputDataset == nullptr);
|
BOOST_ASSERT (gdalOutputDataset == nullptr);
|
||||||
close ();
|
close ();
|
||||||
|
@ -69,10 +69,10 @@ void apGenerator (Option &option) {
|
|||||||
Border border (option.size, false); // default = no border
|
Border border (option.size, false); // default = no border
|
||||||
GraphWalker graphWalker (border);
|
GraphWalker graphWalker (border);
|
||||||
DimImg leafCount = graphWalker.vertexMaxCount ();
|
DimImg leafCount = graphWalker.vertexMaxCount ();
|
||||||
DimChanel maxThresholds = max (max (option.areaThresholds.size (), option.sdThresholds.size ()), option.moiThresholds.size ());
|
DimChanel maxThresholds = max (max (max (option.areaThresholds.size (), option.levelThresholds.size ()), option.sdThresholds.size ()), option.moiThresholds.size ());
|
||||||
vector <vector <PixelT> > allBands (maxThresholds, vector<PixelT> (leafCount, 0));
|
vector <vector <PixelT> > allBands (maxThresholds, vector<PixelT> (leafCount, 0));
|
||||||
|
|
||||||
DimChanel outputBandsCard = option.selectedBand.getSet ().size ()*(1+treeTypesCard*(option.areaThresholds.size ()+option.sdThresholds.size ()+option.moiThresholds.size ()));
|
DimChanel outputBandsCard = option.selectedBand.getSet ().size ()*(1+treeTypesCard*(option.areaThresholds.size ()+option.levelThresholds.size ()+option.sdThresholds.size ()+option.moiThresholds.size ()));
|
||||||
if (!option.oneBand)
|
if (!option.oneBand)
|
||||||
option.outputImage.createImage (option.size, option.inputImage.getDataType (), outputBandsCard);
|
option.outputImage.createImage (option.size, option.inputImage.getDataType (), outputBandsCard);
|
||||||
|
|
||||||
@ -96,6 +96,12 @@ void apGenerator (Option &option) {
|
|||||||
for (DimChanel c = 0; c < option.areaThresholds.size (); ++c, ++chanel)
|
for (DimChanel c = 0; c < option.areaThresholds.size (); ++c, ++chanel)
|
||||||
writeBand (option, &allBands[c][0], chanel);
|
writeBand (option, &allBands[c][0], chanel);
|
||||||
}
|
}
|
||||||
|
if (option.levelThresholds.size ()) {
|
||||||
|
vector<PixelT> thresholds (weightAttributes.getConvertedThresholds (option.levelThresholds));
|
||||||
|
weightAttributes.cut (allBands, attributeProfiles, thresholds);
|
||||||
|
for (DimChanel c = 0; c < option.levelThresholds.size (); ++c, ++chanel)
|
||||||
|
writeBand (option, &allBands[c][0], chanel);
|
||||||
|
}
|
||||||
if (option.sdThresholds.size ()) {
|
if (option.sdThresholds.size ()) {
|
||||||
SDAttributes sdAttributes (tree, areaAttributes);
|
SDAttributes sdAttributes (tree, areaAttributes);
|
||||||
sdAttributes.cut (allBands, attributeProfiles, option.sdThresholds);
|
sdAttributes.cut (allBands, attributeProfiles, option.sdThresholds);
|
||||||
|
Loading…
Reference in New Issue
Block a user