From aff93d54672feaea4fa0cd0cecb1bcedd8df782c Mon Sep 17 00:00:00 2001 From: Git Merciol Date: Fri, 20 Apr 2018 09:49:46 +0200 Subject: [PATCH] =?UTF-8?q?=09modifi=C3=A9=C2=A0:=20=20=20=20=20=20=20=20?= =?UTF-8?q?=20include/Appli/Option.hpp=20=09modifi=C3=A9=C2=A0:=20=20=20?= =?UTF-8?q?=20=20=20=20=20=20include/Attributes/AreaAttributes.hpp=20=09mo?= =?UTF-8?q?difi=C3=A9=C2=A0:=20=20=20=20=20=20=20=20=20include/Attributes/?= =?UTF-8?q?AreaAttributes.tpp=20=09modifi=C3=A9=C2=A0:=20=20=20=20=20=20?= =?UTF-8?q?=20=20=20include/Attributes/AverageAttributes.hpp=20=09modifi?= =?UTF-8?q?=C3=A9=C2=A0:=20=20=20=20=20=20=20=20=20include/Attributes/Aver?= =?UTF-8?q?ageAttributes.tpp=20=09modifi=C3=A9=C2=A0:=20=20=20=20=20=20=20?= =?UTF-8?q?=20=20include/Attributes/MoIAttributes.hpp=20=09modifi=C3=A9?= =?UTF-8?q?=C2=A0:=20=20=20=20=20=20=20=20=20include/Attributes/MoIAttribu?= =?UTF-8?q?tes.tpp=20=09modifi=C3=A9=C2=A0:=20=20=20=20=20=20=20=20=20incl?= =?UTF-8?q?ude/Attributes/SDAttributes.hpp=20=09modifi=C3=A9=C2=A0:=20=20?= =?UTF-8?q?=20=20=20=20=20=20=20include/Attributes/SDAttributes.tpp=20=09m?= =?UTF-8?q?odifi=C3=A9=C2=A0:=20=20=20=20=20=20=20=20=20include/Attributes?= =?UTF-8?q?/WeightAttributes.hpp=20=09modifi=C3=A9=C2=A0:=20=20=20=20=20?= =?UTF-8?q?=20=20=20=20include/Attributes/WeightAttributes.tpp=20=09modifi?= =?UTF-8?q?=C3=A9=C2=A0:=20=20=20=20=20=20=20=20=20include/Attributes/XYAt?= =?UTF-8?q?tributes.hpp=20=09modifi=C3=A9=C2=A0:=20=20=20=20=20=20=20=20?= =?UTF-8?q?=20include/Attributes/XYAttributes.tpp=20=09modifi=C3=A9=C2=A0:?= =?UTF-8?q?=20=20=20=20=20=20=20=20=20include/CompAttribute.hpp=20=09modif?= =?UTF-8?q?i=C3=A9=C2=A0:=20=20=20=20=20=20=20=20=20include/CompAttribute.?= =?UTF-8?q?tpp=20=09modifi=C3=A9=C2=A0:=20=20=20=20=20=20=20=20=20include/?= =?UTF-8?q?triskeleDealThreads.tpp=20=09modifi=C3=A9=C2=A0:=20=20=20=20=20?= =?UTF-8?q?=20=20=20=20src/Appli/Option.cpp=20=09modifi=C3=A9=C2=A0:=20=20?= =?UTF-8?q?=20=20=20=20=20=20=20src/IImage.cpp=20=09modifi=C3=A9=C2=A0:=20?= =?UTF-8?q?=20=20=20=20=20=20=20=20src/apGenerator.cpp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/Appli/Option.hpp | 2 +- include/Attributes/AreaAttributes.hpp | 2 +- include/Attributes/AreaAttributes.tpp | 4 +- include/Attributes/AverageAttributes.hpp | 2 +- include/Attributes/AverageAttributes.tpp | 2 +- include/Attributes/MoIAttributes.hpp | 2 +- include/Attributes/MoIAttributes.tpp | 6 +- include/Attributes/SDAttributes.hpp | 2 +- include/Attributes/SDAttributes.tpp | 6 +- include/Attributes/WeightAttributes.hpp | 5 + include/Attributes/WeightAttributes.tpp | 14 +++ include/Attributes/XYAttributes.hpp | 2 +- include/Attributes/XYAttributes.tpp | 2 +- include/CompAttribute.hpp | 41 +++---- include/CompAttribute.tpp | 142 ++++++++++++----------- include/triskeleDealThreads.tpp | 2 +- src/Appli/Option.cpp | 4 +- src/IImage.cpp | 2 +- src/apGenerator.cpp | 10 +- 19 files changed, 137 insertions(+), 115 deletions(-) diff --git a/include/Appli/Option.hpp b/include/Appli/Option.hpp index 58bcbfa..b65603f 100644 --- a/include/Appli/Option.hpp +++ b/include/Appli/Option.hpp @@ -25,7 +25,7 @@ namespace otb { Selected selectedBand; size_t countingSortCeil = 2; vector areaThresholds; - vector sdThresholds, moiThresholds; + vector levelThresholds, sdThresholds, moiThresholds; unsigned int coreCount = boost::thread::hardware_concurrency (); bool maxTreeFlag = false, minTreeFlag = false, tosTreeFlag = false, alphaTreeFlag = false; bool oneBand = false; diff --git a/include/Attributes/AreaAttributes.hpp b/include/Attributes/AreaAttributes.hpp index e843e0e..71bf19b 100644 --- a/include/Attributes/AreaAttributes.hpp +++ b/include/Attributes/AreaAttributes.hpp @@ -9,7 +9,7 @@ namespace otb { namespace triskele { - class AreaAttributes : public CompAttributeC { + class AreaAttributes : public CompAttribute { public: inline AreaAttributes (const Tree &tree); inline ~AreaAttributes (); diff --git a/include/Attributes/AreaAttributes.tpp b/include/Attributes/AreaAttributes.tpp index c7b41cd..eb800ff 100644 --- a/include/Attributes/AreaAttributes.tpp +++ b/include/Attributes/AreaAttributes.tpp @@ -5,7 +5,7 @@ using namespace boost::chrono; inline AreaAttributes::AreaAttributes (const Tree &tree) - : CompAttributeC (tree) { + : CompAttribute (tree) { compute (); } @@ -18,7 +18,7 @@ inline void AreaAttributes::cut (vector > &allBands, const AttributeProfiles &attributeProfiles, const vector &thresholds) const { auto start = high_resolution_clock::now (); - CompAttributeC::cut (allBands, attributeProfiles, 1, thresholds); + CompAttribute::cut (allBands, attributeProfiles, 1, thresholds); globalTreeStats.addTime (filteringStats, duration_cast > (high_resolution_clock::now ()-start).count ()); } diff --git a/include/Attributes/AverageAttributes.hpp b/include/Attributes/AverageAttributes.hpp index 07cc6b7..c21ad91 100644 --- a/include/Attributes/AverageAttributes.hpp +++ b/include/Attributes/AverageAttributes.hpp @@ -11,7 +11,7 @@ namespace otb { namespace triskele { - class AverageAttributes : public CompAttributeC { + class AverageAttributes : public CompAttribute { public: template inline AverageAttributes (const Tree &tree, const Raster &raster, const AreaAttributes &areaAttributes); diff --git a/include/Attributes/AverageAttributes.tpp b/include/Attributes/AverageAttributes.tpp index 7a174f8..2fdcd23 100644 --- a/include/Attributes/AverageAttributes.tpp +++ b/include/Attributes/AverageAttributes.tpp @@ -6,7 +6,7 @@ using namespace boost::chrono; template inline AverageAttributes::AverageAttributes (const Tree &tree, const Raster &raster, const AreaAttributes &areaAttributes) - : CompAttributeC (tree) { + : CompAttribute (tree) { compute (raster, areaAttributes); } diff --git a/include/Attributes/MoIAttributes.hpp b/include/Attributes/MoIAttributes.hpp index 9041a5e..4834d5a 100644 --- a/include/Attributes/MoIAttributes.hpp +++ b/include/Attributes/MoIAttributes.hpp @@ -9,7 +9,7 @@ namespace otb { namespace triskele { - class MoIAttributes : public CompAttributeC { + class MoIAttributes : public CompAttribute { public: inline MoIAttributes (const Tree &tree, const AreaAttributes &areaAttributes, const XYAttributes &xyAttributes); inline ~MoIAttributes (); diff --git a/include/Attributes/MoIAttributes.tpp b/include/Attributes/MoIAttributes.tpp index ba197ef..089ecd8 100644 --- a/include/Attributes/MoIAttributes.tpp +++ b/include/Attributes/MoIAttributes.tpp @@ -5,7 +5,7 @@ using namespace boost::chrono; inline MoIAttributes::MoIAttributes (const Tree &tree, const AreaAttributes &areaAttributes, const XYAttributes &xyAttributes) - : CompAttributeC (tree) { + : CompAttribute (tree) { compute (areaAttributes, xyAttributes); } @@ -23,8 +23,8 @@ MoIAttributes::cut (vector > &allBands, const AttributeProfiles

::getMaxValue (); cerr << "moi max value:" << maxValue << endl; - CompAttributeC::cut (allBands, attributeProfiles, 0, - CompAttributeC::getScaledThresholds (thresholds, maxValue)); + CompAttribute::cut (allBands, attributeProfiles, 0, + CompAttribute::getScaledThresholds (thresholds, maxValue)); globalTreeStats.addTime (filteringStats, duration_cast > (high_resolution_clock::now ()-start).count ()); } diff --git a/include/Attributes/SDAttributes.hpp b/include/Attributes/SDAttributes.hpp index 1521c95..8c19336 100644 --- a/include/Attributes/SDAttributes.hpp +++ b/include/Attributes/SDAttributes.hpp @@ -11,7 +11,7 @@ namespace otb { namespace triskele { - class SDAttributes : public CompAttributeC { + class SDAttributes : public CompAttribute { public: inline SDAttributes (const Tree &tree, const AreaAttributes &areaAttributes); inline ~SDAttributes (); diff --git a/include/Attributes/SDAttributes.tpp b/include/Attributes/SDAttributes.tpp index 9d2fcf8..66f127d 100644 --- a/include/Attributes/SDAttributes.tpp +++ b/include/Attributes/SDAttributes.tpp @@ -5,7 +5,7 @@ using namespace boost::chrono; inline SDAttributes::SDAttributes (const Tree &tree, const AreaAttributes &areaAttributes) - : CompAttributeC (tree) { + : CompAttribute (tree) { compute (areaAttributes); } @@ -23,8 +23,8 @@ SDAttributes::cut (vector > &allBands, const AttributeProfiles::getMaxValue (); cerr << "sd max value:" << maxValue << endl; - CompAttributeC::cut (allBands, attributeProfiles, 0, - CompAttributeC::getScaledThresholds (thresholds, maxValue)); + CompAttribute::cut (allBands, attributeProfiles, 0, + CompAttribute::getScaledThresholds (thresholds, maxValue)); globalTreeStats.addTime (filteringStats, duration_cast > (high_resolution_clock::now ()-start).count ()); } diff --git a/include/Attributes/WeightAttributes.hpp b/include/Attributes/WeightAttributes.hpp index 1fee457..f7614c9 100644 --- a/include/Attributes/WeightAttributes.hpp +++ b/include/Attributes/WeightAttributes.hpp @@ -2,6 +2,8 @@ #ifndef _OTB_TRISKELE_WEIGHT_ATTRIBUTES_HPP #define _OTB_TRISKELE_WEIGHT_ATTRIBUTES_HPP +#include + #include "triskeleBase.hpp" namespace otb { @@ -15,6 +17,9 @@ namespace otb { inline ~WeightAttributes (); inline void setWeightBounds (Tree &tree); + template + inline void cut (vector > &allBands, const AttributeProfiles &attributeProfiles, + const vector &thresholds) const; virtual inline ostream &print (ostream &out) const { CompAttribute::print (out, "weight"); return out; } }; diff --git a/include/Attributes/WeightAttributes.tpp b/include/Attributes/WeightAttributes.tpp index f7bfd96..76406a4 100644 --- a/include/Attributes/WeightAttributes.tpp +++ b/include/Attributes/WeightAttributes.tpp @@ -1,6 +1,8 @@ #ifndef _OTB_TRISKELE_WEIGHT_ATTRIBUTES_TPP #define _OTB_TRISKELE_WEIGHT_ATTRIBUTES_TPP +using namespace boost::chrono; + template inline WeightAttributes::WeightAttributes (const Tree &tree) @@ -39,4 +41,16 @@ WeightAttributes::setWeightBounds (Tree &tree) { weightBounds.push_back (rootId+1); } + +template +template +inline void +WeightAttributes::cut (vector > &allBands, const AttributeProfiles &attributeProfiles, + const vector &thresholds) const { + auto start = high_resolution_clock::now (); + CompAttribute::cut (allBands, attributeProfiles, 0., thresholds); + globalTreeStats.addTime (filteringStats, duration_cast > (high_resolution_clock::now ()-start).count ()); +} + + #endif // _OTB_TRISKELE_WEIGHT_ATTRIBUTES_TPP diff --git a/include/Attributes/XYAttributes.hpp b/include/Attributes/XYAttributes.hpp index bc14297..d69bf3e 100644 --- a/include/Attributes/XYAttributes.hpp +++ b/include/Attributes/XYAttributes.hpp @@ -18,7 +18,7 @@ namespace otb { operator DimImg () const { return (DimImg) (x*y); } }; - class XYAttributes : public CompAttributeC { + class XYAttributes : public CompAttribute { public: inline XYAttributes (const Tree &tree, const AreaAttributes &areaAttributes); inline ~XYAttributes (); diff --git a/include/Attributes/XYAttributes.tpp b/include/Attributes/XYAttributes.tpp index c26cfa5..92d7bc2 100644 --- a/include/Attributes/XYAttributes.tpp +++ b/include/Attributes/XYAttributes.tpp @@ -5,7 +5,7 @@ using namespace boost::chrono; inline XYAttributes::XYAttributes (const Tree &tree, const AreaAttributes &areaAttributes) - : CompAttributeC (tree) { + : CompAttribute (tree) { compute (areaAttributes); } diff --git a/include/CompAttribute.hpp b/include/CompAttribute.hpp index 69d822a..b98fee6 100644 --- a/include/CompAttribute.hpp +++ b/include/CompAttribute.hpp @@ -14,6 +14,9 @@ namespace otb { template class CompAttribute { public: + static inline vector getScaledThresholds (const vector &thresholds, const AttrT &maxValue); + static inline vector getConvertedThresholds (const vector &thresholds); + inline CompAttribute (const Tree &tree); inline ~CompAttribute (); @@ -22,6 +25,14 @@ namespace otb { inline AttrT *getValues (); inline AttrT getMaxValue () const; + template + inline void cut (vector > &allBands, const AttributeProfiles &attributeProfiles, + const AttrT &pixelAttrValue, const vector &thresholds) const; + + template + inline void cutOnPos (vector > &allBands, const AttributeProfiles &attributeProfiles, + const DimImg &pixelId, const AttrT &pixelAttrValue, const vector &thresholds) const; + virtual inline ostream &print (ostream &out) const { print (out, ""); return out; } protected: @@ -32,39 +43,19 @@ namespace otb { inline void free (); inline void book (const DimImg &leafCount); + template + inline void computeSameCompLevel (const CumpFunctPSE &cumpFunctPSE /* cumpFunctPSE (DimImg parentId)*/) 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 } // otb - #include "Attributes/WeightAttributes.hpp" - namespace otb { namespace triskele { - - template - class CompAttributeC : public CompAttribute { - public: - inline CompAttributeC (const Tree &tree); - inline ~CompAttributeC (); - - static inline vector getScaledThresholds (const vector &thresholds, const AttrT &maxValue); - - template - inline void cut (vector > &allBands, const AttributeProfiles &attributeProfiles, - const AttrT &pixelAttrValue, const vector &thresholds) const; - - template - inline void cutOnPos (vector > &allBands, const AttributeProfiles &attributeProfiles, - const DimImg &pixelId, const AttrT &pixelAttrValue, const vector &thresholds) const; - - protected: - template - inline void computeSameCompLevel (const CumpFunctPSE &cumpFunctPSE /* cumpFunctPSE (DimImg parentId)*/) const; - }; - #include "CompAttribute.tpp" } // triskele } // otb diff --git a/include/CompAttribute.tpp b/include/CompAttribute.tpp index d7f0b25..cf44c5c 100644 --- a/include/CompAttribute.tpp +++ b/include/CompAttribute.tpp @@ -1,6 +1,26 @@ #ifndef _OTB_TRISKELE_COMP_ATTRIBUTE_TPP #define _OTB_TRISKELE_COMP_ATTRIBUTE_TPP +// ======================================== +template +inline vector +CompAttribute::getScaledThresholds (const vector &thresholds, const AttrT &maxValue) { + vector result; + for (double percent : thresholds) + result.push_back (percent*maxValue); + return result; +} + +template +inline vector +CompAttribute::getConvertedThresholds (const vector &thresholds) { + vector result; + for (double value : thresholds) + result.push_back ((AttrT) value); + return result; +} + +// ======================================== template inline CompAttribute::CompAttribute (const Tree &tree) @@ -47,78 +67,13 @@ CompAttribute::getMaxValue () const { return max; } -template -inline ostream & -CompAttribute::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 -inline void -CompAttribute::free () { - values = vector (); -} - -template -inline void -CompAttribute::book (const DimImg &leafCount) { - this->leafCount = leafCount; - values.resize (leafCount); -} - // ======================================== -template -inline -CompAttributeC::CompAttributeC (const Tree &tree) - : CompAttribute (tree) { -} - -template -inline -CompAttributeC::~CompAttributeC () { -} - -template -inline vector -CompAttributeC::getScaledThresholds (const vector &thresholds, const AttrT &maxValue) { - vector result; - for (AttrT percent : thresholds) - result.push_back (percent*maxValue); - return result; -} - - -template -template -inline void -CompAttributeC::computeSameCompLevel (const CumpFunctPSE &cumpFunctPSE) const { - const vector &weightBounds (CompAttribute::tree.getWeightBounds ()); - unsigned int coreCount = CompAttribute::tree.getCoreCount (); - DEF_LOG ("CompAttributeC::computeSameCompLevel", "coreCount:" << coreCount); - if (!weightBounds.size () || CompAttribute::tree.getCompCount ()/weightBounds.size () < coreCount) { - LOG ("CompAttributeC::computeSameCompLevel: no thread"); - CompAttribute::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 template inline void -CompAttributeC::cut (vector > &allBands, const AttributeProfiles &attributeProfiles, +CompAttribute::cut (vector > &allBands, const AttributeProfiles &attributeProfiles, const AttrT &pixelAttrValue, const vector &thresholds) const { - DEF_LOG ("CompAttributeC::cut", "coreCount:" << CompAttribute::tree.getCoreCount () << " thresholds:" << thresholds.size ()); + DEF_LOG ("CompAttribute::cut", "coreCount:" << CompAttribute::tree.getCoreCount () << " thresholds:" << thresholds.size ()); dealThreadRange (CompAttribute::leafCount, CompAttribute::tree.getCoreCount (), [this, &allBands, &attributeProfiles, &pixelAttrValue, &thresholds] (const DimImg &leafId) { cutOnPos (allBands, attributeProfiles, leafId, pixelAttrValue, thresholds); }); @@ -127,7 +82,7 @@ CompAttributeC::cut (vector > &allBands, const AttributePr template template inline void -CompAttributeC::cutOnPos (vector > &allBands, const AttributeProfiles &attributeProfiles, +CompAttribute::cutOnPos (vector > &allBands, const AttributeProfiles &attributeProfiles, const DimImg &leafId, const AttrT &pixelAttrValue, const vector &thresholds) const { // no debug (to many pixels) DimImg parentId = CompAttribute::tree.getLeafParent (leafId); @@ -152,7 +107,7 @@ CompAttributeC::cutOnPos (vector > &allBands, const Attrib AttrT ceil = thresholds[chanel]; for ( ; curValue < ceil && curId < rootId; ) { 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) allBands[chanel][leafId] = curValue; return; @@ -167,4 +122,53 @@ CompAttributeC::cutOnPos (vector > &allBands, const Attrib } } +// ======================================== +template +inline ostream & +CompAttribute::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 +inline void +CompAttribute::free () { + values = vector (); +} + +template +inline void +CompAttribute::book (const DimImg &leafCount) { + this->leafCount = leafCount; + values.resize (leafCount); +} + +// ======================================== +template +template +inline void +CompAttribute::computeSameCompLevel (const CumpFunctPSE &cumpFunctPSE) const { + const vector &weightBounds (CompAttribute::tree.getWeightBounds ()); + unsigned int coreCount = CompAttribute::tree.getCoreCount (); + DEF_LOG ("CompAttribute::computeSameCompLevel", "coreCount:" << coreCount); + if (!weightBounds.size () || CompAttribute::tree.getCompCount ()/weightBounds.size () < coreCount) { + LOG ("CompAttribute::computeSameCompLevel: no thread"); + CompAttribute::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 diff --git a/include/triskeleDealThreads.tpp b/include/triskeleDealThreads.tpp index 9bafaac..23ad948 100644 --- a/include/triskeleDealThreads.tpp +++ b/include/triskeleDealThreads.tpp @@ -71,7 +71,7 @@ dealThread (const DimImg &maxId, unsigned int coreCount, const FunctThreadMinMax functThreadMinMax (idCopyValInThread, maxIds[idCopyValInThread], maxIds[idCopyValInThread+1]); }); #else /* BOOST thread */ - boost::thread tasks [coreCount]; + std::vector tasks; for (unsigned int idCopyValInThread = 0; idCopyValInThread < coreCount; ++idCopyValInThread) { tasks.push_back (boost::thread ([/*no ref!!!*/idCopyValInThread, &maxIds, &functThreadMinMax] () { functThreadMinMax (idCopyValInThread, maxIds[idCopyValInThread], maxIds[idCopyValInThread+1]); diff --git a/src/Appli/Option.cpp b/src/Appli/Option.cpp index 329fde5..806b4c0 100644 --- a/src/Appli/Option.cpp +++ b/src/Appli/Option.cpp @@ -97,7 +97,7 @@ Option::parse (int argc, char** argv) { bool helpFlag = false, versionFlag = false, useTheForceLuke = false; string inputFileName, outputFileName, bandsRange; long left = -1, top = -1, width = -1, height = -1; - string areaThresholdsName, sdThresholdsName, moiThresholdsName; + string areaThresholdsName, levelThresholdsName, sdThresholdsName, moiThresholdsName; try { desc.add_options () ("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") ("alpha-tree", po::bool_switch (&alphaTreeFlag), "build alpha-tree") ("area,A", po::value (&areaThresholdsName), "produce area attributs") + ("level,L", po::value (&levelThresholdsName), "produce level attributs") ("standard-deviation,S", po::value (&sdThresholdsName), "produce standard deviation attributs") ("moment-of-inertia,M", po::value (&moiThresholdsName), "produce moment of inertia attributs") ; @@ -186,6 +187,7 @@ Option::parse (int argc, char** argv) { usage ("Bad options"); } areaThresholds = readThresholds (areaThresholdsName); + levelThresholds = readThresholds (levelThresholdsName); sdThresholds = readThresholds (sdThresholdsName); moiThresholds = readThresholds (moiThresholdsName); diff --git a/src/IImage.cpp b/src/IImage.cpp index 3860f09..9779d7e 100644 --- a/src/IImage.cpp +++ b/src/IImage.cpp @@ -24,7 +24,7 @@ IImage::~IImage () { void 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 (gdalOutputDataset == nullptr); close (); diff --git a/src/apGenerator.cpp b/src/apGenerator.cpp index 7a6f104..23a5c37 100644 --- a/src/apGenerator.cpp +++ b/src/apGenerator.cpp @@ -69,10 +69,10 @@ void apGenerator (Option &option) { Border border (option.size, false); // default = no border GraphWalker graphWalker (border); 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 > allBands (maxThresholds, vector (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) 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) writeBand (option, &allBands[c][0], chanel); } + if (option.levelThresholds.size ()) { + vector 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 ()) { SDAttributes sdAttributes (tree, areaAttributes); sdAttributes.cut (allBands, attributeProfiles, option.sdThresholds);