modifié : include/ArrayTree/ArrayTreeBuilder.tpp
modifié : include/Tree.hpp modifié : include/TreeBuilder.hpp modifié : src/testMain.cpp
This commit is contained in:
parent
e5643b9d54
commit
fd2a2d4421
@ -50,6 +50,7 @@ template<typename WeightT, typename PixelT>
|
|||||||
template<typename WeightFunct>
|
template<typename WeightFunct>
|
||||||
inline void
|
inline void
|
||||||
ArrayTreeBuilder<WeightT, PixelT>::buildTree (Tree &tree, const WeightFunct &weightFunct) {
|
ArrayTreeBuilder<WeightT, PixelT>::buildTree (Tree &tree, const WeightFunct &weightFunct) {
|
||||||
|
DEF_LOG ("ArrayTreeBuilder::buildTree", "");
|
||||||
|
|
||||||
initWeights (graphWalker, weightFunct);
|
initWeights (graphWalker, weightFunct);
|
||||||
vector<Edge<WeightT> > allEdges (graphWalker.edgeMaxCount ());
|
vector<Edge<WeightT> > allEdges (graphWalker.edgeMaxCount ());
|
||||||
@ -131,9 +132,8 @@ ArrayTreeBuilder<WeightT, PixelT>::buildTree (Tree &tree, const WeightFunct &wei
|
|||||||
newCompIdx = NULL;
|
newCompIdx = NULL;
|
||||||
leaders.free ();
|
leaders.free ();
|
||||||
|
|
||||||
// XXX tree.setNode
|
setNodeCount (tree, leafCount+compCount);
|
||||||
nodeCount = leafCount+compCount;
|
LOG ("nodeCount:" << tree.getNodeCount());
|
||||||
LOG ("nodeCount:" << nodeCount);
|
|
||||||
DimEdge root = compCount-1;
|
DimEdge root = compCount-1;
|
||||||
compParents[root] = root;
|
compParents[root] = root;
|
||||||
|
|
||||||
@ -162,10 +162,10 @@ inline void
|
|||||||
ArrayTreeBuilder<WeightT, PixelT>::buildTree (Edge<WeightT> *edges, const WeightFunct &weightFunct,
|
ArrayTreeBuilder<WeightT, PixelT>::buildTree (Edge<WeightT> *edges, const WeightFunct &weightFunct,
|
||||||
const Rect &tile, DimImg &topParent) {
|
const Rect &tile, DimImg &topParent) {
|
||||||
#ifdef SMART_LOG
|
#ifdef SMART_LOG
|
||||||
DEF_LOG ("ArrayTreeBuilder::buildTree", " tile:" << tile << " topParent:" << topParent << " counting:" << countingSortFlag);
|
DEF_LOG ("ArrayTreeBuilder::buildTree", " tile:" << tile << " topParent:" << topParent << " counting:" << countingFlag);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
DimEdge edgeCount = (sizeof (WeightT) < 3 || countingSortFlag) ?
|
DimEdge edgeCount = (sizeof (WeightT) < 3 || countingFlag) ?
|
||||||
graphWalker.getCountingSortedEdges<WeightT, WeightFunct> (tile, Surface, edges, weightFunct) :
|
graphWalker.getCountingSortedEdges<WeightT, WeightFunct> (tile, Surface, edges, weightFunct) :
|
||||||
graphWalker.getSortedEdges (tile, Surface, edges, weightFunct);
|
graphWalker.getSortedEdges (tile, Surface, edges, weightFunct);
|
||||||
|
|
||||||
@ -381,7 +381,7 @@ ArrayTreeBuilder<WeightT, PixelT>::connectLeaf (DimImg a, DimImg b, const Weight
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------
|
// ----------------------------------------
|
||||||
template<typename WeightT, PixelT>
|
template<typename WeightT, typename PixelT>
|
||||||
template<typename WeightFunct>
|
template<typename WeightFunct>
|
||||||
inline void
|
inline void
|
||||||
ArrayTreeBuilder<WeightT, PixelT>::connectComp (DimImg newComp, DimImg topA, DimImg topB, const WeightFunct &weightFunct) {
|
ArrayTreeBuilder<WeightT, PixelT>::connectComp (DimImg newComp, DimImg topA, DimImg topB, const WeightFunct &weightFunct) {
|
||||||
@ -482,7 +482,7 @@ ArrayTreeBuilder<WeightT, PixelT>::updateNewIdx (const vector<DimImg> &compBases
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------
|
// ----------------------------------------
|
||||||
template<typename WeightT, PixelT>
|
template<typename WeightT, typename PixelT>
|
||||||
inline void
|
inline void
|
||||||
ArrayTreeBuilder<WeightT, PixelT>::updateNewIdx (const DimImg curComp, DimImg &compCount) {
|
ArrayTreeBuilder<WeightT, PixelT>::updateNewIdx (const DimImg curComp, DimImg &compCount) {
|
||||||
if (newCompIdx[curComp] != DimImg_MAX)
|
if (newCompIdx[curComp] != DimImg_MAX)
|
||||||
@ -506,7 +506,7 @@ ArrayTreeBuilder<WeightT, PixelT>::updateNewIdx (const DimImg curComp, DimImg &c
|
|||||||
// XXX arbres non-connexe ?
|
// XXX arbres non-connexe ?
|
||||||
cerr << "coucou ptop-max: " << curComp << endl;
|
cerr << "coucou ptop-max: " << curComp << endl;
|
||||||
}
|
}
|
||||||
const DimNodeIdx &newTopChildCountRec = childCountRec[top];
|
const DimNodeId &newTopChildCountRec = childCountRec[top];
|
||||||
const DimImg &newTopCompParent = compParents[top];
|
const DimImg &newTopCompParent = compParents[top];
|
||||||
const WeightT &newTopWeight = compWeights[top]; // only in case of unnecessary comp
|
const WeightT &newTopWeight = compWeights[top]; // only in case of unnecessary comp
|
||||||
for (DimImg sibling = curComp; sibling != top; ) {
|
for (DimImg sibling = curComp; sibling != top; ) {
|
||||||
@ -524,7 +524,7 @@ ArrayTreeBuilder<WeightT, PixelT>::updateNewIdx (const DimImg curComp, DimImg &c
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------
|
// ----------------------------------------
|
||||||
template<typename WeightT, PixelT>
|
template<typename WeightT, typename PixelT>
|
||||||
inline void
|
inline void
|
||||||
ArrayTreeBuilder<WeightT, PixelT>::compress (const DimImg &compTop) {
|
ArrayTreeBuilder<WeightT, PixelT>::compress (const DimImg &compTop) {
|
||||||
|
|
||||||
@ -666,8 +666,8 @@ ArrayTreeBuilder<WeightT, PixelT>::buildChildren () {
|
|||||||
partial_sum (childCountRec, childCountRec+compCount, childCountRec);
|
partial_sum (childCountRec, childCountRec+compCount, childCountRec);
|
||||||
|
|
||||||
// set
|
// set
|
||||||
DimNodeIdx *childGetOrder = childCount+1;
|
DimNodeId *childGetOrder = childCount+1;
|
||||||
for (DimNodeIdx i = 0; i < nodeCount-1; ++i) {
|
for (DimNodeId i = 0; i < nodeCount-1; ++i) {
|
||||||
if (leafParents[i] == DimImg_MAX)
|
if (leafParents[i] == DimImg_MAX)
|
||||||
continue;
|
continue;
|
||||||
BOOST_ASSERT (leafParents[i] < compCount);
|
BOOST_ASSERT (leafParents[i] < compCount);
|
||||||
@ -699,21 +699,21 @@ inline void
|
|||||||
ArrayTreeBuilder<WeightT, PixelT>::printTree (const Size &size, const bool &rec) {
|
ArrayTreeBuilder<WeightT, PixelT>::printTree (const Size &size, const bool &rec) {
|
||||||
cout << "tree weight parent " << (rec ? "countRec" : "count") << endl;
|
cout << "tree weight parent " << (rec ? "countRec" : "count") << endl;
|
||||||
Size doubleSize (size.width, 2*size.height);
|
Size doubleSize (size.width, 2*size.height);
|
||||||
cct::merciol::printMap (cout, compWeights, size) << endl;
|
triskele::printMap (cout, compWeights, size) << endl;
|
||||||
cct::merciol::printMap (cout, leafParents, doubleSize) << endl;
|
triskele::printMap (cout, leafParents, doubleSize) << endl;
|
||||||
cct::merciol::printMap (cout, rec ? childCountRec : childCount, size) << endl;
|
triskele::printMap (cout, rec ? childCountRec : childCount, size) << endl;
|
||||||
}
|
}
|
||||||
template<typename WeightT, typename PixelT>
|
template<typename WeightT, typename PixelT>
|
||||||
inline void
|
inline void
|
||||||
ArrayTreeBuilder<WeightT, PixelT>::printLeaders (const Size &size) {
|
ArrayTreeBuilder<WeightT, PixelT>::printLeaders (const Size &size) {
|
||||||
cout << "leaders" << endl;
|
cout << "leaders" << endl;
|
||||||
cct::merciol::printMap (cout, newCompIdx, size) << endl;
|
triskele::printMap (cout, newCompIdx, size) << endl;
|
||||||
}
|
}
|
||||||
template<typename WeightT, typename PixelT>
|
template<typename WeightT, typename PixelT>
|
||||||
inline void
|
inline void
|
||||||
ArrayTreeBuilder<WeightT, PixelT>::printNewCompIdx (const Size &size) {
|
ArrayTreeBuilder<WeightT, PixelT>::printNewCompIdx (const Size &size) {
|
||||||
cout << "newCompIdx" << endl;
|
cout << "newCompIdx" << endl;
|
||||||
cct::merciol::printMap (cout, newCompIdx, size) << endl;
|
triskele::printMap (cout, newCompIdx, size) << endl;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@ -28,7 +28,7 @@ namespace otb {
|
|||||||
Size size;
|
Size size;
|
||||||
|
|
||||||
/*! Number of pixels / leaf */
|
/*! Number of pixels / leaf */
|
||||||
DimImg leafCount, nodeCount;
|
DimNodeId leafCount, nodeCount;
|
||||||
|
|
||||||
/*! Pointers on the parents of each leafs / nodes */
|
/*! Pointers on the parents of each leafs / nodes */
|
||||||
DimNodeId *leafParents, *compParents;
|
DimNodeId *leafParents, *compParents;
|
||||||
@ -69,7 +69,7 @@ namespace otb {
|
|||||||
// Getters for tree structure
|
// Getters for tree structure
|
||||||
DimNodeId getRoot () const { return nodeCount-1; }
|
DimNodeId getRoot () const { return nodeCount-1; }
|
||||||
DimNodeId getAbsRoot () const { return nodeCount-1+leafCount; }
|
DimNodeId getAbsRoot () const { return nodeCount-1+leafCount; }
|
||||||
DimNodeId getCompCount () const { return nodeCount-leafCount; } // XXX
|
DimNodeId getCompCount () const { return nodeCount-leafCount; }
|
||||||
|
|
||||||
const DimNodeId &getParent (const DimNodeId &idx) const { return leafParents[idx]; }
|
const DimNodeId &getParent (const DimNodeId &idx) const { return leafParents[idx]; }
|
||||||
const DimNodeId &getLeafParent (const DimNodeId &idx) const { return leafParents[idx]; }
|
const DimNodeId &getLeafParent (const DimNodeId &idx) const { return leafParents[idx]; }
|
||||||
|
|||||||
@ -24,16 +24,22 @@ namespace otb {
|
|||||||
|
|
||||||
inline void updateAttributes (Tree &tree) {
|
inline void updateAttributes (Tree &tree) {
|
||||||
leafCount = tree.leafCount;
|
leafCount = tree.leafCount;
|
||||||
|
nodeCount = tree.nodeCount;
|
||||||
leafParents = tree.leafParents;
|
leafParents = tree.leafParents;
|
||||||
compParents = tree.compParents;
|
compParents = tree.compParents;
|
||||||
children = tree.children;
|
children = tree.children;
|
||||||
childCount = tree.childCount;
|
childCount = tree.childCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DimNodeId getCompCount () const { return nodeCount-leafCount; }
|
||||||
|
inline void setNodeCount (Tree &tree, DimNodeId nodeCount) {
|
||||||
|
tree.setNodeCount (nodeCount);
|
||||||
|
this->nodeCount = nodeCount;
|
||||||
|
}
|
||||||
protected:
|
protected:
|
||||||
// Attributes corresponding to the tree, used to make the construction easier
|
// Attributes corresponding to the tree, used to make the construction easier
|
||||||
|
|
||||||
DimImg leafCount;
|
DimImg leafCount, nodeCount;
|
||||||
/*! Pointers on the parents of each leafs / nodes */
|
/*! Pointers on the parents of each leafs / nodes */
|
||||||
DimNodeId *leafParents, *compParents;
|
DimNodeId *leafParents, *compParents;
|
||||||
|
|
||||||
|
|||||||
@ -8,11 +8,16 @@
|
|||||||
#include "QuadTree/QuadTreeBuilder.hpp"
|
#include "QuadTree/QuadTreeBuilder.hpp"
|
||||||
#include "XMLTree/XMLTreeBuilder.hpp"
|
#include "XMLTree/XMLTreeBuilder.hpp"
|
||||||
#include "IImage.hpp"
|
#include "IImage.hpp"
|
||||||
|
#include "Attribute.hpp"
|
||||||
|
|
||||||
|
#include "ArrayTree/triskeleArrayTreeBase.hpp"
|
||||||
|
#include "ArrayTree/triskeleSort.hpp"
|
||||||
#include "ArrayTree/Border.hpp"
|
#include "ArrayTree/Border.hpp"
|
||||||
#include "ArrayTree/GraphWalker.hpp"
|
#include "ArrayTree/GraphWalker.hpp"
|
||||||
#include "ArrayTree/Leader.hpp"
|
#include "ArrayTree/Leader.hpp"
|
||||||
#include "ArrayTree/Weight.hpp"
|
#include "ArrayTree/Weight.hpp"
|
||||||
//#include "ArrayTree/ArrayTreeBuilder.hpp"
|
|
||||||
|
#include "ArrayTree/ArrayTreeBuilder.hpp"
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc, char** argv) {
|
main (int argc, char** argv) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user