From 68491d83ec2d0bd153d41c7b61a27416b80a8673 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Merciol?= Date: Mon, 27 Aug 2018 13:46:51 +0200 Subject: [PATCH] Correction de ToS et monotonie des poids --- MakefileNoOTB | 3 ++- documentation/GitInfos.org | 11 +++++---- include/ArrayTree/Weight.hpp | 18 +++++++------- include/ArrayTree/Weight.tpp | 48 ++++++++++++++++++------------------ src/PerfArrayTreeBuilder.cpp | 2 +- src/TestArrayTreeBuilder.cpp | 2 +- test/TestDeal.cpp | 3 ++- 7 files changed, 45 insertions(+), 42 deletions(-) diff --git a/MakefileNoOTB b/MakefileNoOTB index 0c78900..f508653 100644 --- a/MakefileNoOTB +++ b/MakefileNoOTB @@ -73,7 +73,8 @@ testB: init $(APG_OUT) perf: perfA perfA: init $(PRF_OUT) - $(PRF_OUT) MIN 32 20 1000000 +# $(PRF_OUT) MIN 32 20 1000000 + $(PRF_OUT) MIN 4 20 100000 init: mkdir -p $(OUT_DIR) $(OBJ_DIR) $(LIB_DIR) diff --git a/documentation/GitInfos.org b/documentation/GitInfos.org index 7a24547..f840646 100644 --- a/documentation/GitInfos.org +++ b/documentation/GitInfos.org @@ -10,11 +10,12 @@ ** Fonctions intégré depuis la dernière version *** depuis version 1.0 - - copier les valeurs de géolocalisation (de input vers output) - - vérifier coupure (avec sens de la monotonie) - - faire coupures suivant (A>, W<>, SD>, MOI>) - - sort W thresholds - - faire les features-profiles (L, mean, SD, A, MOI) + - copie des valeurs de géolocalisation (de input vers output) + - vérification des coupures (avec sens de la monotonie) + - coupures suivant (A>, W<>, SD>, MOI>) + - tride W thresholds + - features-profiles (L, mean, SD, A, MOI) + - correction de la monotonie des ToS ** Infos concernant le pattern de git de Triskele diff --git a/include/ArrayTree/Weight.hpp b/include/ArrayTree/Weight.hpp index a3c4cf5..3c66027 100644 --- a/include/ArrayTree/Weight.hpp +++ b/include/ArrayTree/Weight.hpp @@ -45,7 +45,7 @@ namespace otb { }; // ======================================== - /*! Structure intégrant la façon dont est géré un poids pour un MinTree */ + /*! Structure intégrant la façon dont est géré un poids pour un MaxTree car la fonction calcul le poids minimum */ template struct MinWeight : public WeightBase { typedef WeightBase WB; @@ -63,7 +63,7 @@ namespace otb { }; // ======================================== - /*! Structure intégrant la façon dont est géré un poids pour un MaxTree */ + /*! Structure intégrant la façon dont est géré un poids pour un MinTree car la fonction calcul le poids maximum. */ template struct MaxWeight : public WeightBase { typedef WeightBase WB; @@ -76,10 +76,15 @@ namespace otb { }; // ======================================== - /*! Structure intégrant la façon dont est géré un poids pour un AlphaTree */ + /*! Structure intégrant la façon dont est géré un poids pour un AlphaTree car la fonction calcul la distance minimum (0 dans les feuilles) */ template struct DiffWeight : public WeightBase { typedef WeightBase WB; + inline bool getDecr () const; + static inline bool isWeightInf (const WeightT &a, const WeightT &b); + static inline bool isEdgeInf (const Edge &a, const Edge &b); + static inline void sort (Edge *edges, DimEdge count); + inline DiffWeight (); inline DiffWeight (const PixelT *pixels, const Size &size); inline DiffWeight (const DiffWeight &model, const PixelT *pixels, const Size &size); @@ -89,7 +94,7 @@ namespace otb { }; // ======================================== - /*! Structure intégrant la façon dont est géré un poids pour un TreeOfShape */ + /*! Structure intégrant la façon dont est géré un poids pour un TreeOfShape car la fonction calcul la distance à la médiane (distance maximum dans les feuilles) */ template struct MedianWeight : public WeightBase { typedef WeightBase WB; protected: @@ -97,11 +102,6 @@ namespace otb { WeightT thresholdWeight; public: - inline bool getDecr () const; - static inline bool isWeightInf (const WeightT &a, const WeightT &b); - static inline bool isEdgeInf (const Edge &a, const Edge &b); - static inline void sort (Edge *edges, DimEdge count); - inline const PixelT &getMedian () const; inline const PixelT &getThresholdPixel () const; inline const WeightT &getThresholdWeight () const; diff --git a/include/ArrayTree/Weight.tpp b/include/ArrayTree/Weight.tpp index 013f1ec..c85f2b8 100644 --- a/include/ArrayTree/Weight.tpp +++ b/include/ArrayTree/Weight.tpp @@ -187,6 +187,30 @@ MaxWeight::getWeight (const Point &a, const Point &b) const { } // ======================================== +template +inline bool +DiffWeight::getDecr () const { + return true; +} + +template +inline bool +DiffWeight::isWeightInf (const WeightT &a, const WeightT &b) { + return a > b; +} + +template +inline bool +DiffWeight::isEdgeInf (const Edge &a, const Edge &b) { + return isWeightInf (a.weight, b.weight); +} + +template +inline void +DiffWeight::sort (Edge *edges, DimEdge count) { + std::sort (edges, edges+count, isEdgeInf); +} + template inline DiffWeight::DiffWeight () @@ -219,30 +243,6 @@ DiffWeight::getWeight (const Point &a, const Point &b) const { } // ======================================== -template -inline bool -MedianWeight::getDecr () const { - return true; -} - -template -inline bool -MedianWeight::isWeightInf (const WeightT &a, const WeightT &b) { - return a > b; -} - -template -inline bool -MedianWeight::isEdgeInf (const Edge &a, const Edge &b) { - return isWeightInf (a.weight, b.weight); -} - -template -inline void -MedianWeight::sort (Edge *edges, DimEdge count) { - std::sort (edges, edges+count, isEdgeInf); -} - template inline const PixelT & MedianWeight::getMedian () const { diff --git a/src/PerfArrayTreeBuilder.cpp b/src/PerfArrayTreeBuilder.cpp index 597cac3..f20be65 100644 --- a/src/PerfArrayTreeBuilder.cpp +++ b/src/PerfArrayTreeBuilder.cpp @@ -31,7 +31,7 @@ void perf (const Raster &raster, const GraphWalker &graphWalker, const TreeType &treeType, const unsigned int &coreCount) { ArrayTreeBuilder atb (raster, graphWalker, treeType); Tree tree (coreCount); - WeightAttributes weightAttributes (tree); + WeightAttributes weightAttributes (tree, getDecrFromTreetype (treeType)); atb.buildTree (tree, weightAttributes); tree.check (graphWalker.border); } diff --git a/src/TestArrayTreeBuilder.cpp b/src/TestArrayTreeBuilder.cpp index 6d745b7..0fb6ced 100644 --- a/src/TestArrayTreeBuilder.cpp +++ b/src/TestArrayTreeBuilder.cpp @@ -252,7 +252,7 @@ void test () { debug = true; ArrayTreeBuilder atb (raster, graphWalker, treeType); Tree tree (coreCount); - WeightAttributes weightAttributes (tree); + WeightAttributes weightAttributes (tree, getDecrFromTreetype (treeType)); atb.buildTree (tree, weightAttributes); tree.check (border); diff --git a/test/TestDeal.cpp b/test/TestDeal.cpp index 36496a6..a6c1cca 100644 --- a/test/TestDeal.cpp +++ b/test/TestDeal.cpp @@ -28,10 +28,11 @@ fLambda (DimImg &nbItem, const FunctId &functId/* functId (id) */) { template inline void fThread (double &inDuration, const DimImg &nbItem, const FunctId &functId/* functId (id) */) { + // One thread #if INTEL_TBB_THREAD using namespace tbb; #pragma warning(disable: 588) - parallel_for (size_t (0), size_t (1), [&nbItem, &functId] (size_t idCopyValInThread) { + parallel_for (size_t (0), size_t (1), [&nbItem, &functId, &inDuration] (size_t idCopyValInThread) { auto start = high_resolution_clock::now (); for (DimImg x = 0; x < nbItem; ++x) functId (x);