modifié : include/ArrayTree/ArrayTreeBuilder.hpp

modifié :         include/ArrayTree/ArrayTreeBuilder.tpp
	supprimé :        include/Attributes/AreaAttribute.hpp
	modifié :         include/TreeBuilder.hpp
	supprimé :        src/Attributes/AreaAttribute.cpp
	modifié :         src/Tree.cpp
	modifié :         src/testMain.cpp
This commit is contained in:
Git Merciol 2018-02-18 18:49:40 +01:00
parent bdd6110787
commit 2933efb9d9
7 changed files with 69 additions and 50 deletions

View File

@ -9,6 +9,8 @@
#include "triskeleSort.hpp" #include "triskeleSort.hpp"
#include "triskeleDealThreads.hpp" #include "triskeleDealThreads.hpp"
#include "TreeBuilder.hpp" #include "TreeBuilder.hpp"
#include "Attributes/WeightAttributes.hpp"
#include "AttributeProfiles.hpp"
#include "IImage.hpp" #include "IImage.hpp"
#include "GraphWalker.hpp" #include "GraphWalker.hpp"
#include "Weight.hpp" #include "Weight.hpp"
@ -27,23 +29,26 @@ namespace otb {
TreeType type; TreeType type;
bool countingFlag; bool countingFlag;
Leader leaders; Leader leaders;
WeightT *compWeights; // [leafCount] XXX dans TreeBuilder ???
// transcient // transcient
DimNodeId *childCountRec; DimNodeId *childCountRec;
DimImg *newCompId; DimImg *newCompId;
WeightT *compWeights;
public: public:
inline ArrayTreeBuilder (const unsigned int &coreCount, inline ArrayTreeBuilder (const unsigned int &coreCount,
Raster<PixelT> &raster, const GraphWalker &graphWalker, Raster<PixelT> &raster, const GraphWalker &graphWalker,
const TreeType &treeType, const bool &countingSort = true); const TreeType &treeType, const bool &countingSort = true);
inline ~ArrayTreeBuilder (); inline ~ArrayTreeBuilder ();
inline void buildTree (Tree &tree); inline void buildTree (Tree &tree, WeightAttributes<WeightT> &weightAttributes);
inline void setAttributProfiles (AttributeProfiles<PixelT> &attributeProfiles, const Raster<PixelT> &raster);
protected: protected:
template<typename WeightFunct> template<typename WeightFunct>
inline void inline void
buildTree (Tree &tree, const WeightFunct &weightFunct); buildTree (Tree &tree, const WeightFunct &weightFunct);
template<typename WeightFunct>
inline void
setAttributProfiles (AttributeProfiles<PixelT> &attributeProfiles, const WeightFunct &weightFunct);
// template<typename WeightFunct> // template<typename WeightFunct>
// inline void // inline void

View File

@ -19,7 +19,6 @@ ArrayTreeBuilder<WeightT, PixelT>::ArrayTreeBuilder (const unsigned int &coreCou
DEF_LOG ("ArrayTreeBuilder::ArrayTreeBuilder", ""); DEF_LOG ("ArrayTreeBuilder::ArrayTreeBuilder", "");
} }
// ========================================
template<typename WeightT, typename PixelT> template<typename WeightT, typename PixelT>
inline inline
ArrayTreeBuilder<WeightT, PixelT>::~ArrayTreeBuilder () { ArrayTreeBuilder<WeightT, PixelT>::~ArrayTreeBuilder () {
@ -28,15 +27,16 @@ ArrayTreeBuilder<WeightT, PixelT>::~ArrayTreeBuilder () {
// ======================================== // ========================================
template<typename WeightT, typename PixelT> template<typename WeightT, typename PixelT>
inline void inline void
ArrayTreeBuilder<WeightT, PixelT>::buildTree (Tree &tree) { ArrayTreeBuilder<WeightT, PixelT>::buildTree (Tree &tree, WeightAttributes<WeightT> &weightAttributes) {
DEF_LOG ("ArrayTreeBuilder::buildTree", "size:" << graphWalker.vertexMaxCount ()); DEF_LOG ("ArrayTreeBuilder::buildTree", "size:" << graphWalker.vertexMaxCount ());
setTreeSize (tree, graphWalker.size); setTreeSize (tree, graphWalker.size);
weightAttributes.updateTranscient ();
if (!leafCount) if (!leafCount)
return; return;
leaders.book (leafCount); leaders.book (leafCount);
childCountRec = childCount+2; childCountRec = childCount+2;
newCompId = leaders.getLeaders (); newCompId = leaders.getLeaders ();
compWeights = new WeightT[leafCount]; compWeights = weightAttributes.getValues ();
switch (type) { switch (type) {
// case MIN: // case MIN:
@ -54,12 +54,29 @@ ArrayTreeBuilder<WeightT, PixelT>::buildTree (Tree &tree) {
newCompId = nullptr; newCompId = nullptr;
buildChildren (); buildChildren ();
childCountRec = nullptr; childCountRec = nullptr;
// XXX
// if (compWeights)
// delete [] compWeights;
// compWeights = nullptr;
} }
// ========================================
template<typename WeightT, typename PixelT>
inline void
ArrayTreeBuilder<WeightT, PixelT>::setAttributProfiles (AttributeProfiles<PixelT> &attributeProfiles, const Raster<PixelT> &raster) {
DEF_LOG ("ArrayTreeBuilder::setAttributProfiles", "");
attributeProfiles.updateTranscient ();
switch (type) {
// case MIN:
// setAttributProfiles (attributeProfiles, MinWeight<PixelT, WeightT> (raster.getPixels (), raster.getSize ()));
break;
case MAX:
setAttributProfiles (attributeProfiles, MaxWeight<PixelT, WeightT> (raster.getPixels (), raster.getSize ()));
break;
// case TOS:
// setAttributProfiles (attributeProfiles, MedianWeight<PixelT, WeightT> (raster.getPixels (), raster.getSize ()));
break;
// XXX msg
}
}
// ========================================
template<typename WeightT, typename PixelT> template<typename WeightT, typename PixelT>
template<typename WeightFunct> template<typename WeightFunct>
inline void inline void
@ -155,6 +172,21 @@ ArrayTreeBuilder<WeightT, PixelT>::buildTree (Tree &tree, const WeightFunct &wei
compParents[root] = root; compParents[root] = root;
} }
// ========================================
template<typename WeightT, typename PixelT>
template<typename WeightFunct>
inline void
ArrayTreeBuilder<WeightT, PixelT>::setAttributProfiles (AttributeProfiles<PixelT> &attributeProfiles, const WeightFunct &weightFunct) {
PixelT *leafAP = attributeProfiles.getValues ();
dealThreadBound (leafCount, coreCount, [&weightFunct, &leafAP] (const DimImg &minVal, const DimImg &maxVal) {
weightFunct.copyPixelsBound (leafAP, minVal, maxVal);
});
PixelT *compAP = leafAP+leafCount;
dealThreadBound (getCompCount (), coreCount, [this, &weightFunct, &compAP] (const DimImg &minVal, const DimImg &maxVal) {
weightFunct.weight2valueBound (compAP, compWeights, minVal, maxVal);
});
}
// ======================================== // ========================================
// template<typename WeightT, typename PixelT> // template<typename WeightT, typename PixelT>
// template<typename WeightFunct> // template<typename WeightFunct>

View File

@ -1,18 +0,0 @@
#ifndef _OTB_TRISKELE_AREA_ATTRIBUTE_HPP
#define _OTB_TRISKELE_AREA_ATTRIBUTE_HPP
#include "Attribute.hpp"
namespace otb {
namespace triskele {
/** AreaAttribute */
class AreaAttribute : Attribute {
public:
void
generate ();
};
} // triskele
} // otb
#endif // _OTB_TRISKELE_AREA_ATTRIBUTE_HPP

View File

@ -1,8 +1,8 @@
#ifndef _OTB_TRISKELE_TREE_BUILDER_HPP #ifndef _OTB_TRISKELE_TREE_BUILDER_HPP
#define _OTB_TRISKELE_TREE_BUILDER_HPP #define _OTB_TRISKELE_TREE_BUILDER_HPP
#include "Tree.hpp"
#include "triskeleBase.hpp" #include "triskeleBase.hpp"
#include "Tree.hpp"
namespace otb { namespace otb {
namespace triskele { namespace triskele {

View File

@ -1,10 +0,0 @@
#include "Attributes/AreaAttribute.hpp"
#include <functional>
using namespace otb::triskele;
void
AreaAttribute::generate () {
//DimNodeId root = tree->getRoot ();
}

View File

@ -4,9 +4,9 @@ using namespace otb::triskele;
using namespace std; using namespace std;
Tree::Tree (const DimSideImg &width, const DimSideImg &height) Tree::Tree (const DimSideImg &width, const DimSideImg &height)
: Tree ((DimImg)width * (DimImg)height) : Tree ()
{ {
size = Size (width, height); resize (width, height);
} }
Tree::Tree () Tree::Tree ()
@ -42,13 +42,7 @@ Tree::clear () {
void void
Tree::resize (const DimSideImg &width, const DimSideImg &height) { Tree::resize (const DimSideImg &width, const DimSideImg &height) {
// resize ((DimImg)width * (DimImg)height);
size = Size (width, height); size = Size (width, height);
// }
// void
// Tree::resize (const DimImg &leafCount) {
// size = NullSize;
book ((DimImg)width * (DimImg)height); book ((DimImg)width * (DimImg)height);
clear (); clear ();
} }

View File

@ -18,6 +18,9 @@
#include "ArrayTree/Weight.hpp" #include "ArrayTree/Weight.hpp"
#include "ArrayTree/ArrayTreeBuilder.hpp" #include "ArrayTree/ArrayTreeBuilder.hpp"
#include "Attributes/WeightAttributes.hpp"
#include "AttributeProfiles.hpp"
#include "Attributes/AreaAttributes.hpp"
//using namespace triskele; //using namespace triskele;
using namespace otb::triskele; using namespace otb::triskele;
@ -33,8 +36,21 @@ void prog (const Option &option) {
GraphWalker graphWalker (raster.getSize (), border); GraphWalker graphWalker (raster.getSize (), border);
ArrayTreeBuilder<PixelT, PixelT> atb (option.treeCoreCount, raster, graphWalker, TreeType::MAX); ArrayTreeBuilder<PixelT, PixelT> atb (option.treeCoreCount, raster, graphWalker, TreeType::MAX);
Tree tree; Tree tree;
atb.buildTree (tree); WeightAttributes<PixelT> weightAttributes (tree);
atb.buildTree (tree, weightAttributes);
// XXX buildAttr // XXX buildAttr
AttributeProfiles<PixelT> attributeProfiles (tree);
atb.setAttributProfiles (attributeProfiles, raster);
AreaAttributes areaAttributes (tree); // XXX <DimImg> option.treeCoreCount
// AverageAttributs<PixelT> averageAttributs (tree, raster);
// SDAttributs sdAttributs (tree, areaAttributs); // XXX<double>
// XYAttributs xyAttributs (tree, areaAttributs); // XXX<double>
// MoIAttributs moiAttributs (tree, xyAttributs); // XXX<double>
// XXX cut
// attribut.cut (out, attributProfiles, threshold)
// XXX write // XXX write