src/qvdta/qvcomponenttree.h

Go to the documentation of this file.
00001 /*
00002  *      Copyright (C) 2007. PARP Research Group.
00003  *      <http://perception.inf.um.es>
00004  *      University of Murcia, Spain.
00005  *
00006  *      This file is part of the QVision library.
00007  *
00008  *      QVision is free software: you can redistribute it and/or modify
00009  *      it under the terms of the GNU Lesser General Public License as
00010  *      published by the Free Software Foundation, version 3 of the License.
00011  *
00012  *      QVision is distributed in the hope that it will be useful,
00013  *      but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  *      GNU Lesser General Public License for more details.
00016  *
00017  *      You should have received a copy of the GNU Lesser General Public
00018  *      License along with QVision. If not, see <http://www.gnu.org/licenses/>.
00019  */
00020 
00024 
00025 #include <qvdta/qvdta.h>
00026 
00027 #define  NULL_NODE      256*256*256
00028 
00029 namespace qvdta
00030 {
00071 class QVComponentTree
00072         {
00073         public:
00074 
00080                 QVComponentTree(const QVImage<uChar,1> &image, bool inverseTree= false);
00081 
00082                 ~QVComponentTree();
00083 
00084                 bool isInverseTree()    const           { return inverseTree; }
00085                 uInt rootNode() const                   { return rootNodeID; }
00086                 uInt seedX(uInt node) const             { return nodes[node].seedX; }
00087                 uInt seedY(uInt node) const             { return nodes[node].seedY; }
00088                 uChar firstThreshold(uInt node) const   { return nodes[node].firstThreshold; }
00089                 uChar lastThreshold(uInt node) const    { return nodes[node].lastThreshold; }
00090                 uInt numChilds(uInt node) const         { return nodes[node].numChilds; }
00091                 uInt firstChild(uInt node) const        { return nodes[node].child; }
00092                 uInt nextSibling(uInt node) const       { return nodes[node].sibling; }
00093                 uInt *area(uInt node) const             { return nodes[node].area; }
00094                 bool validNode(uInt node) const         { return nodes[node].inited; }
00095 
00096                 uInt & rootNode()                       { return rootNodeID; }
00097                 uInt & seedX(uInt node)                 { return nodes[node].seedX; }
00098                 uInt & seedY(uInt node)                 { return nodes[node].seedY; }
00099                 uChar & firstThreshold(uInt node)       { return nodes[node].firstThreshold; }
00100                 uChar & lastThreshold(uInt node)        { return nodes[node].lastThreshold; }
00101                 uInt & numChilds(uInt node)             { return nodes[node].numChilds; }
00102                 uInt & firstChild(uInt node)            { return nodes[node].child; }
00103                 uInt & nextSibling(uInt node)           { return nodes[node].sibling; }
00104                 uInt *area(uInt node)                   { return nodes[node].area; }
00105                 bool & validNode(uInt node)             { return nodes[node].inited; }
00106 
00107                 uInt getNumNodes() const        { return numNodes; }
00108                 uInt getTotalPoints() const     { return totalPoints; }
00109                 uInt getLeafNodes() const       { return leafNodes; }
00110 
00111         private:
00112                 void getComponentTree(const QVImage<uChar> &image);
00113                 uInt numNodes, freePoints, totalPoints, leafNodes, rootNodeID, maxNodes;
00114                 bool inverseTree;
00115 
00116                 uInt newNode(uInt SeedX, uInt SeedY, uChar Threshold)
00117                         {
00118                         uInt newNodeID = this->numNodes++;
00119                         seedX(newNodeID) = SeedX;
00120                         seedY(newNodeID) = SeedY;
00121                         firstThreshold(newNodeID) = lastThreshold(newNodeID) = Threshold;
00122                         firstChild(newNodeID) =  nextSibling(newNodeID) = NULL_NODE;
00123                         numChilds(newNodeID) = 0;
00124                         area(newNodeID)[Threshold] = 0;
00125                         validNode(newNodeID) = false;
00126 
00127                         return newNodeID;
00128                         }
00129 
00130                 void addChild(uInt ParentNodeID, uInt ChildNodeID)
00131                         {
00132                         nextSibling(ChildNodeID) = firstChild(ParentNodeID);
00133                         firstChild(ParentNodeID) = ChildNodeID;
00134                         numChilds(ParentNodeID)++;
00135                         }
00136 
00137                 class QVComponentTreeNode
00138                         {
00139                         public:
00140                                 uInt seedX, seedY;
00141                                 uInt child, sibling, numChilds;
00142                                 uChar firstThreshold, lastThreshold;
00143                                 uInt area[256];
00144                                 bool inited;
00145                         } *nodes;
00146         };
00147 
00148 //uInt debug_print_componentTree(QVComponentTree &componentTree);
00149 void FilterComponentTreeSmallRegions(QVImage<uChar> &image, QVComponentTree &componentTree, uInt area);
00150 
00151 }

Generated on Thu Dec 13 13:06:25 2007 for QVision by  doxygen 1.5.3