Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

ConnectedComponentsImpl.H

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------+
00002  | Library QgarLib, graphics analysis and recognition                  |
00003  | Copyright (C) 2002  Qgar Project, LORIA                             |
00004  |                                                                     |
00005  | This library is free software; you can redistribute it and/or       |
00006  | modify it under the terms of the GNU Lesser General Public          |
00007  | License version 2.1, as published by the Free Software Foundation.  |
00008  |                                                                     |
00009  | This library is distributed in the hope that it will be useful,     |
00010  | but WITHOUT ANY WARRANTY; without even the implied warranty of      |
00011  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                |
00012  | See the GNU Lesser General Public License for more details.         |
00013  |                                                                     |
00014  | The GNU Lesser General Public License is included in the file       |
00015  | LICENSE.LGPL, in the root directory of the Qgar packaging. See      |
00016  | http://www.gnu.org/licenses/lgpl.html for the terms of the licence. |
00017  | To receive a paper copy, write to the Free Software Foundation,     |
00018  | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.       |
00019  |                                                                     |
00020  | Contact Project Qgar for any information:                           |
00021  |   LORIA - équipe Qgar                                               |
00022  |   B.P. 239, 54506 Vandoeuvre-lès-Nancy Cedex, France                |
00023  |   email: qgar-contact@loria.fr                                      |
00024  |   http://www.qgar.org/                                              |
00025  *---------------------------------------------------------------------*/
00026 
00027 
00028 #ifndef __CONNECTEDCOMPONENTSIMPL_H_INCLUDED__
00029 #define __CONNECTEDCOMPONENTSIMPL_H_INCLUDED__
00030 
00031 /**
00032  * @file    ConnectedComponentsImpl.H
00033  * @brief   Header file of class qgar::ConnectedComponentsImpl.
00034  *
00035  * @author <a href="mailto:qgar-develop@loria.fr?subject=Qgar fwd Gérald Masini">Gérald Masini</a>
00036  * @date   May 28, 2004  15:41
00037  * @since  Qgar 2.1.1
00038  */
00039 
00040 
00041 // For RCS/CVS use: Do not delete
00042 /* $Id: ConnectedComponentsImpl.H,v 1.14 2005/10/14 17:05:45 masini Exp $ */
00043 
00044 
00045 // STL
00046 #include <list>
00047 #include <vector>
00048 // QGAR
00049 #include <qgarlib/Component.H>
00050 #include <qgarlib/ConnectedComponents.H>
00051 #include <qgarlib/GenImage.H>
00052 #include <qgarlib/GenTree.H>
00053 #include <qgarlib/QgarErrorAlgorithm.H>
00054 
00055 
00056 
00057 namespace qgar
00058 {
00059 
00060 /**
00061  * @ingroup GRAPHPROC_CC
00062  *
00063  * @class ConnectedComponentsImpl
00064  *   ConnectedComponentsImpl.H "qgarlib/ConnectedComponentsImpl.H"
00065  *
00066  * @brief Implementation of the construction of connected components
00067  *        of a binary image.
00068  *
00069  * A (connected) component is a region defined by a set of connected
00070  * pixels having the same color:
00071 @verbatim
00072       B B B                    w W w
00073       B * B                    W * W
00074       B B B                    w W w
00075 
00076    8-connexity              4-connexity
00077     for BLACK                for WHITE
00078 @endverbatim
00079  * <ul>
00080  * <li>
00081  * Black components are constructed using 8-connexity: When black,
00082  * the central point ('*' on the figure) is connex to its 8 black
00083  * neighbors marked <b>B</b>.
00084  * </li>
00085  * <li>
00086  * White components are constructed using 4-connexity: When white,
00087  * the central point ('*' on the figure) is connex to its 4 white
00088  * neighbors marked <b>W</b> and is not connex to the 4 white
00089  * neighbors marked <b>w</b>.
00090  * </li>
00091  * </ul>
00092  *
00093  * See class qgar::Component for the way a component is represented.
00094  *
00095 @verbatim
00096                      aRCompTree
00097                   ________________
00098                  |                |    0     j     k
00099   +----------+   |      +--+      |   +--+--+--+--+--+- -+--+
00100   |COMPONENT |<----------C0|<----------- |  |  |  |  |   |  |  aRCompTab
00101   |LABELLED 0|   |      +--+      |   +--+--+|-+--+|-+- -+--+
00102   +----------+   |       /\       |          |     |
00103                  |      /  \      |          |     |
00104   +----------+   |  +--+    +--+  |          |     |
00105   |COMPONENT |<------Ci|    |Cj|<------------+     |
00106   |LABELLED i|   |  +--+    +--+  |                |
00107   +----------+   |    |     /||\  |                |
00108   +----------+   |  +--+          |                |
00109   |COMPONENT |<------Ck|<--------------------------+
00110   |LABELLED k|   |  +--+          |
00111   +----------+   |________________|
00112 @endverbatim
00113  *
00114  * Each component is associated with a label (a number of type
00115  * <b>qgar::Component::label_type</b>).
00116  *
00117  * The set of components is hierarchically organized as a tree,
00118  * the so-called <i>component tree</i> (given by argument
00119  * <b>aRCompTree</b> of function qgar::ConnectedComponentsImpl::run).
00120  * Each node represents a component (in fact, the data associated with
00121  * the node is a pointer to the component, <b>Ci</b> on the figure above),
00122  * and its children represent the components which are directly included
00123  * into (i.e. has a common border with) the component.
00124  *
00125  * The root of the tree is always a <b>white</b> component,
00126  * labelled <b>0</b>. It represents the background of the initial
00127  * binary image, in which all the other components are
00128  * (transitively) included.
00129  *
00130  * To be sure to get a component representing the background,
00131  * the first and last rows of the given binary image, as well as
00132  * its first and last columns, are considered as being <b>white</b>.
00133  *
00134  * The so-called <i>component table</i>
00135  * (given by argument <b>aRCompTab</b> of function
00136  * qgar::ConnectedComponentsImpl::run) provides a direct
00137  * access to the nodes representing the components, using their labels
00138  * to index the table. In other words, an element of this table is
00139  * a pointer to the node of the tree representing the component
00140  * having the same label as the element index.
00141  *
00142  * The location of the components is given by the so-called
00143  * <i>component image</i> (given by argument <b>aRCompImg</b>
00144  * of function qgar::ConnectedComponentsImpl::ConnectedComponentsImpl):
00145  * The value of a pixel is the label of the component to which
00146  * the pixel belongs.
00147  *
00148  * @warning
00149 @verbatim
00150       B B B                    w W w
00151       B * B                    W * W
00152       B B B                    w W w
00153 
00154    8-connexity              4-connexity
00155     for BLACK                for WHITE
00156 @endverbatim
00157  * <ul>
00158  * <li>
00159  * Black components are constructed using 8-connexity: When
00160  * black, the central point ('*' on the figure) is connex to its
00161  * 8 black neighbors marked <b>B</b>.
00162  * </li>
00163  * <li>
00164  * White components are constructed using 4-connexity: When
00165  * white, the central point ('*' on the figure) is connex to its
00166  * 4 white neighbors marked <b>W</b> and is <i>not connex</i> to the
00167  * 4 white neighbors marked <b>w</b>.
00168  * </li>
00169  * </ul>
00170  *
00171  * @todo
00172  * Give the user the choice between implementing components as
00173  * labelled regions in an image (like now) and implementing
00174  * components through tables of runs and labels (these tables are
00175  * presently deleted once components are constructed)
00176  *
00177  * @author <a href="mailto:qgar-develop@loria.fr?subject=Qgar fwd Gérald Masini">Gérald Masini</a>
00178  * @date   May 28, 2004  15:41
00179  * @since  Qgar 2.1.1
00180  */
00181 class ConnectedComponentsImpl
00182 {
00183 // -------------------------------------------------------------------
00184 // P U B L I C    M E M B E R S
00185 // -------------------------------------------------------------------
00186 public:
00187 
00188   /** @name Constructors */
00189   //        ============
00190   //@{
00191 
00192   /**
00193    * @brief Initialize data
00194    *        in order to run the construction of components.
00195    *
00196    * @param aBinImg      binary image from which components are extracted
00197    * @param aPCompImg    pointer to component image
00198    * @param aRCompTree   reference to the component tree
00199    *                     (see class qgar::ConnectedComponents)
00200    * @param aRCompTab    reference to the component table
00201    *                     (see class qgar::ConnectedComponents)
00202    */
00203   ConnectedComponentsImpl(const BinaryImage& aBinImg,
00204                           ConnectedComponents::image_type* aPCompImg,
00205                           ConnectedComponents::tree_type& aRCompTree,
00206                           std::vector<ConnectedComponents::node_type*>&
00207                           aRCompTab);
00208 
00209   //@}
00210 
00211 
00212   /** @name Destructor */
00213   //        ==========
00214   //@{
00215 
00216   /**
00217    * @brief Non-virtual destructor.
00218    */
00219   ~ConnectedComponentsImpl();
00220 
00221   //@}
00222 
00223 
00224   /** @name Construction of connected components */
00225   //        ====================================
00226   //@{
00227 
00228   /**
00229    * @brief Run the construction of connected components.
00230    *
00231    * @exception qgar::QgarErrorAlgorithm (maximum label exceeded)
00232    */
00233   void run() throw(QgarErrorAlgorithm);
00234 
00235   //@}
00236 
00237 
00238 // -------------------------------------------------------------------
00239 // P R O T E C T E D    M E M B E R S
00240 // -------------------------------------------------------------------
00241 protected:
00242 
00243   /** @name (I) The initial binary image */
00244   //        ============================
00245   //@{
00246 
00247   /**
00248    * @brief Width of the initial binary image
00249    * (and of the component image).
00250    */
00251   int _width;
00252 
00253   /**
00254    * @brief Height of the initial binary image
00255    * (and of the component image).
00256    */
00257   int _height;
00258 
00259   /**
00260    * @brief Index of the last column of the initial binary image
00261    * (and of the component image).
00262    */
00263   int _colEndIdx;
00264 
00265   /**
00266    * @brief Index of the last row of the initial binary image
00267    * (and of the component image).
00268    */
00269   int _rowEndIdx;
00270 
00271   //@}
00272 
00273 
00274   // =================================================================
00275   /** @name (II) Runs in the given binary image
00276 
00277   For each row (of the given image), whose index is <b>_rowIdx</b>:
00278 
00279 @verbatim
00280                           0 1 2 3 4 5 6 7 8 9  <- column numbers
00281 row #_rowIdx             +-+-+-+-+-+-+-+-+-+-+
00282 of the given image       |b|w|b|b|b|w|w|b|b|b| <- pixels
00283                          +-+-+-+-+-+-+-+-+-+-+
00284                           ^                 ^
00285                           |_  considered   _|
00286                                as WHITE
00287 
00288                            0  1  2  3  4   <- run numbers
00289                           +--+--+--+--+--+
00290 _runRowsTab[_rowIdx]      |2 |3 |2 |2 |1 | <- run lengths
00291                           +--+--+--+--+--+
00292                           +--+--+--+--+--+
00293 _labelRowsTab[_rowIdx]    |L0|L1|L2|L3|L4| <- run labels
00294                           +--+--+--+--+--+
00295 
00296 => Even indexes in a run/label row correspond to <b>white</b> runs
00297    Odd  indexes in a run/label row correspond to <b>black</b> runs
00298 @endverbatim
00299 
00300   - The run row, stored in <b>runRowsTab[_rowIdx]</b>, gives the lengths
00301     of the runs of same-colored consecutive pixels in the row.
00302     First and last rows are considered as completely <b>white</b>.
00303     First and last pixels of a given row are considered as <b>white</b>.
00304 
00305   - The label row, stored in <b>_labelRowsTab[_rowIdx]</b>, gives the labels
00306     of the corresponding runs: <b>_labelRowsTab[_rowIdx][rdx]</b> gives
00307     the label of the run whose length is <b>runRowsTab[_rowIdx][rdx]</b>.
00308   */
00309   // =================================================================
00310   //@{
00311 
00312   /**
00313    * @brief Table of run rows:
00314    *        1 run row for each row of the given binary image.
00315    */
00316   std::vector< std::vector<int> > _runRowsTab;
00317 
00318   /**
00319    * @brief Table of label rows:
00320    *        1 label row for each row of the given binary image.
00321    */
00322   std::vector< std::vector<Component::label_type> > _labelRowsTab;
00323 
00324   /**
00325    * @brief True while all runs in a row are not processed.
00326    */
00327   bool _moreCurrentRuns;
00328 
00329   //@}
00330 
00331 
00332   /** @name (III) Previous row of the given binary image */
00333   //        ============================================
00334   //@{
00335 
00336   /**
00337    * @brief Index of the previous row in the given image,
00338    * and in the tables of run/label rows.
00339    *
00340    * See qgar::ConnectedComponentsImpl::_runRowsTab
00341    * and qgar::ConnectedComponentsImpl::_labelRowsTab,
00342    * in section II about runs.
00343    */
00344   int _prevRowIdx;
00345 
00346   /**
00347    * @brief Considering the current run in the (previous) row,
00348    * index of this run in the run/label row.
00349    */
00350   int _prevRunIdx;
00351 
00352   /**
00353    * @brief Considering the current run in the (previous) row,
00354    * number of runs (starting from <b>0</b>) in the run row.
00355    */
00356   int _prevRunCnt;
00357 
00358   /**
00359    * @brief Considering the current run in the (previous) row,
00360    * label number of this run.
00361    */
00362   Component::label_type _prevLabel;
00363 
00364   /**
00365    * @brief Considering the current run in the (previous) row,
00366    * color of this run.
00367    */
00368   QGEbw _prevColor;
00369 
00370   /**
00371    * @brief Considering the current run in the (previous) row,
00372    * index  (in image row) of the beginning of this run.
00373    */
00374   int _prevRunBeginX;
00375 
00376   /**
00377    * @brief Considering the current run in the (previous) row,
00378    * index  (in image row) of the end of this run.
00379    */
00380   int _prevRunEndX;
00381 
00382   //@}
00383 
00384 
00385   /** @name (IV) Current row of the given binary image */
00386   //        ===========================================
00387   //@{
00388 
00389   /**
00390    * @brief Pointer to the current row in the pixel map
00391    *        of the given binary image.
00392    */
00393   BinaryImage::value_type* _ptRow;
00394 
00395   /**
00396    * @brief Pointer to the end of the current row in the pixel map
00397    *        of the given binary image.
00398    */
00399   BinaryImage::value_type* _ptRowEnd;
00400 
00401   /**
00402    * @brief Index of the current row in the given binary image,
00403    * and in the tables of run/label rows.
00404    *
00405    * See qgar::ConnectedComponentsImpl::_runRowsTab
00406    * and qgar::ConnectedComponentsImpl::_labelRowsTab,
00407    * in section II about runs.
00408    */
00409   int _rowIdx;
00410 
00411   /**
00412    * @brief Considering the current run in the (current) row,
00413    * index of this run in the run/label row.
00414    */
00415   int _currRunIdx;
00416 
00417   /**
00418    * @brief Considering the current run in the (current) row,
00419    * label number of this run.
00420    */
00421   Component::label_type _currLabel;
00422 
00423   /**
00424    * @brief Considering the current run in the (current) row,
00425    * color of this run.
00426    */
00427   QGEbw _currColor;
00428 
00429   /**
00430    * @brief Considering the current run in the (current) row,
00431    * index (in image row) of the beginning of this run.
00432    */
00433   int _currRunBeginX;
00434 
00435   /**
00436    * @brief Considering the current run in the (current) row,
00437    * index (in image row) of the end of the run.
00438    */
00439   int _currRunEndX;
00440 
00441   //@}
00442 
00443 
00444   // =================================================================
00445   /** @name (V) Labels
00446 
00447   Each created component is associated with a label, that is used
00448   as an index to store/access information about the component in
00449   the different tables representing the components
00450   (see section VI about component features).
00451   */
00452   // =================================================================
00453   //@{
00454 
00455   /**
00456    * @brief Current label count.
00457    */
00458   Component::label_type _labelCnt;
00459 
00460   /**
00461    * @brief Table of equivalent labels.
00462    *
00463 @verbatim
00464                                  _labelCnt
00465                                      |
00466                   0  1  2  3  4  ... v     <- labels
00467                  +--+--+--+--+--+- -+--+
00468  _equivLabelTab  |NO|E1|NO|NO|E4|   |  |   <- equivalent labels
00469                  +--+--+--+--+--+- -+--+
00470 @endverbatim
00471    *
00472    * - When a component is created, it is associated with a label
00473    *   <b>Li</b> and <b>_equivLabelTab[Li]</b> is set to <i>NO LABEL</i>
00474    *   which means that the component is a <i>valid</i> one.
00475    *
00476    * - When components labelled <b>Lj</b> and <b>Lk (Lj < Lk)</b> have
00477    *   to be merged, the component with the greatest label (<b>Lk</b>)
00478    *   is merged into the component with the smallest label (<b>Lj</b>).
00479    *   <b>_equivLabelTab[Lk]</b> is set to <b>Lj</b>, to indicate that
00480    *   labels <b>Lj</b> and <b>Lk</b> are <i>equivalent</i>,
00481    *   i.e. are associated with the same component.
00482    *
00483    *   <b>NOTES</b>
00484    *
00485    *   - The smallest label of a set of equivalent labels is called
00486    *     the <i>valid label</i>, and the component corresponding to a
00487    *     valid label is called the <i>valid component</i>.
00488    *   - By construction, component labelled <b>0</b> is always valid
00489    *     and represents the background.
00490    */
00491   std::vector<Component::label_type> _equivLabelTab;
00492 
00493   /**
00494    * @brief Table giving the final label numbering.
00495    *
00496 @verbatim
00497                               _labelCnt
00498                                   |
00499                   0  1  2  3  ... v    <- initial label numbers
00500                  +--+--+--+--+- -+--+
00501  _finalLabelTab  |0 |F1|F2|F3|   |  |  final labels
00502                  +--+--+--+--+- -+--+  0 <= Fi <= _finalLabelCnt
00503 @endverbatim
00504    *
00505    * <b>_finalLabelTab[Li]</b> gives the final valid label, equivalent
00506    * to initial label <b>Li</b>. Final label numbers are computed
00507    * so as to get a consecutive final numbering.
00508    *
00509    * <b>NOTE</b>
00510    *
00511    * By construction, the final label of component <b>0</b>
00512    * (background) is always <b>0</b>.
00513    */
00514   std::vector<Component::label_type> _finalLabelTab;
00515 
00516   /**
00517    * @brief Final label count.
00518    */
00519   Component::label_type _finalLabelCnt;
00520 
00521   /**
00522    * @brief List recording the indexes of valid components
00523    * in the table of equivalent labels, <b>_equivLabelTab</b>
00524    * (see above).
00525    *
00526 @verbatim
00527        +---+---+---
00528        | | | | |...  _validCompIdxList
00529        +-|-+-|-+---
00530          |   |
00531          |   |    _labelCnt
00532          v   v        |
00533    0  1  2   3  4 ... v
00534   +--+--+--+--+--+- -+--+
00535   |NO|E1|NO|NO|E4|   |  |  _equivLabelTab
00536   +--+--+--+--+--+- -+--+
00537 @endverbatim
00538    * This list is constructed once all the rows of the given binary
00539    * image are processed, and it is used to construct the final
00540    * component tree. Component labelled <b>0</b> (which always
00541    * represents the background) is not recorded in the list.
00542    */
00543   std::list<int> _validCompIdxList;
00544 
00545   //@}
00546 
00547  
00548   // =================================================================
00549   /** @name (VI) Tables to store component features
00550 
00551   The component in which a given component is directly included
00552   (i.e. has a common border) is called the <i>comprising component</i>.
00553 
00554 @verbatim
00555    0  1  2  3  4...  <- component labels (<= _labelCnt)
00556   +--+--+--+--+--+-                                                 --+  C
00557   |i0|i1|i2|i3|i4|   _inLabel     : label of the comprising component |  O
00558   +--+--+--+--+--+-                                                   |  M
00559   |c0|c1|c2|c3|c4|   _color       : color                             |  P
00560   +--+--+--+--+--+-                                                   |  O
00561   |p0|p1|p2|p3|p4|   _xTopLeftPix : X of top left pixel               |  N
00562   +--+--+--+--+--+-                                                   |  E
00563   |P0|P1|P2|P3|P4|   _yTopLeftPix : Y of top left pixel               |  N
00564   +--+--+--+--+--+-                                                   |  T
00565   |t0|t1|t2|t3|t4|   _xTopLeft    : X of top left corner              >
00566   +--+--+--+--+--+-                                                   |
00567   |T0|T1|T2|T3|T4|   _yTopLeft    : Y of top left corner              |  F
00568   +--+--+--+--+--+-                                                   |  E
00569   |b0|b1|b2|b3|b4|   _xBottomRight: X of bottom right corner          |  A
00570   +--+--+--+--+--+-                                                   |  T
00571   |B0|B1|B2|B3|B4|   _yBottomRight: Y of bottom right corner          |  U
00572   +--+--+--+--+--+-                                                   |  R
00573   |a0|a1|a2|a3|a4|   _areaPixels  : area                              |  E
00574   +--+--+--+--+--+-                                                 --+  S
00575 @endverbatim
00576 
00577    For component labelled <b>Li</b>, <b>_inLabel[Li]</b> gives
00578    the label of its comprising component, <b>color[Li]</b> gives
00579    its color, etc.
00580   */
00581   // =================================================================
00582   //@{
00583 
00584   /**
00585    * @brief Label of the comprising component of each component.
00586    */
00587   std::vector<Component::label_type> _inLabel;
00588 
00589   /**
00590    * @brief Color of each component.
00591    */
00592   std::vector<QGEbw> _color;
00593 
00594   /**
00595    * @brief X coordinate of the top left pixel of each component.
00596    */
00597   std::vector<int> _xTopLeftPix;
00598 
00599   /**
00600    * @brief Y coordinate of the top left pixel of each component.
00601    */
00602   std::vector<int> _yTopLeftPix;
00603 
00604   /**
00605    * @brief X coordinate of the top left corner of the bounding box
00606    *        of each component.
00607    */
00608   std::vector<int> _xTopLeft;
00609 
00610   /**
00611    * @brief Y coordinate of the top left corner of the bounding box
00612    *        of each component.
00613    */
00614   std::vector<int> _yTopLeft;
00615 
00616   /**
00617    * @brief X coordinate of the bottom right corner of the bounding
00618    *        box of each component.
00619    */
00620   std::vector<int> _xBottomRight;
00621 
00622   /**
00623    * @brief Y coordinate of the bottom right corner of the bounding
00624    *        box of each component.
00625    */
00626   std::vector<int> _yBottomRight;
00627 
00628   /**
00629    * @brief Area (in pixels) of each component.
00630    */
00631   std::vector<int> _areaPixels;
00632 
00633   //@}
00634 
00635 
00636   /** @name (VII) The connected components */
00637   //        ==============================
00638   //@{
00639 
00640   /**
00641    * @brief Pointer to the component image.
00642    */
00643   ConnectedComponents::image_type* _pCompImg;
00644 
00645   /**
00646    * @brief Pointer to the pixel map of the component image.
00647    */
00648   Component::label_type* _pMapCCImg;
00649 
00650   /**
00651    * @brief Reference to the component tree.
00652    *
00653    * See class qgar::ConnectedComponents.
00654    */
00655   ConnectedComponents::tree_type& _rCompTree;
00656 
00657   /**
00658    * @brief Reference to the component table.
00659    *
00660    * See class qgar::ConnectedComponents.
00661    */
00662   std::vector<ConnectedComponents::node_type*>& _rCompTab;
00663 
00664   //@}
00665 
00666 
00667 // -------------------------------------------------------------------
00668 // P R I V A T E    M E M B E R S
00669 // -------------------------------------------------------------------
00670 private:
00671 
00672   /** @name Functions working on labels */
00673   //        ===========================
00674   //@{
00675 
00676   /**
00677    * @brief Get the <i>valid label</i> of (i.e. equivalent to)
00678    *        a given label.
00679    * @param aLabel  a label
00680    */
00681   int validLabel(Component::label_type aLabel);
00682 
00683   //@}
00684 
00685 
00686   /** @name Functions working on components */
00687   //        ===============================
00688   //@{
00689 
00690   /**
00691    * @brief merge component including previous run
00692    *        and component including current run.
00693    *
00694    * @warning By construction, component with the greatest label
00695    * must be merged into component with the smallest label.
00696    */
00697   void mergePrevAndCurrComponents();
00698 
00699   //@}
00700 
00701 
00702   /** @name Functions working on runs */
00703   //        =========================
00704   //@{
00705 
00706   /**
00707    * @brief Move to next run in previous row
00708    * (see section (III) about previous row).
00709    */
00710   void nextPrevRun();
00711 
00712   /**
00713    * @brief Move to next run in current row
00714    * (see section (IV) about current row).
00715    */
00716   void nextCurrRun();
00717 
00718   /**
00719    * @brief Perform moves according to black- and white-connexity
00720    * when end of previous run and end of current run coincide.
00721    *
00722    * @warning
00723    * End of current row must be tested before calling this function.
00724    */
00725   void prevAndCurrRunsCoincide();
00726 
00727   //@}
00728 
00729 
00730   /** @name Functions working on the component tree */
00731   //        =======================================
00732   //@{
00733 
00734   /**
00735    * @brief Construction the component tree.
00736    *
00737    * @param aTree    reference to the tree being constructed
00738    * @param aPNode   pointer to a node representing a component
00739    *                 which has not yet children
00740    * @param aCCTab   reference to the table of pointers to nodes
00741    *                 representing components: <b>aCCTab[lab]</b>
00742    *                 gives a pointer to the node representing
00743    *                 the component labelled <b>lab</b>
00744    *                 (<b>lab</b> is a <i>valid</i> label)
00745    */
00746   void constructComponentTree
00747     (ConnectedComponents::tree_type&               aTree,
00748      ConnectedComponents::node_type*               aPNode,
00749      std::vector<ConnectedComponents::node_type*>& aCCTab);
00750 
00751   //@}
00752 
00753 
00754 // -------------------------------------------------------------------
00755 }; // class ConnectedComponentsImpl
00756 
00757 
00758 } // namespace qgar
00759 
00760 
00761 #endif /* __CONNECTEDCOMPONENTSIMPL_H_INCLUDED__ */