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

LinkedChainList.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 __LINKEDCHAINLIST_H_INCLUDED__
00029 #define __LINKEDCHAINLIST_H_INCLUDED__
00030 
00031 
00032 /**
00033  * @file     LinkedChainList.H
00034  * @brief    Header file of class qgar::LinkedChainList.
00035  *
00036  * @author   <a href="mailto:qgar-develop@loria.fr?subject=Qgar fwd Karl Tombre">Karl Tombre</a>
00037  * @date     July 3,  2001  16:14
00038  * @since    Qgar 1.0
00039  */
00040 
00041 
00042 // For RCS/CVS use: Do not delete
00043 /* $Id: LinkedChainList.H,v 1.15 2005/09/14 10:53:18 masini Exp $ */
00044 
00045 
00046 
00047 // STL
00048 #include <list>
00049 // QGAR
00050 #include <qgarlib/GenImage.H>
00051 #include <qgarlib/GenPointChain.H>
00052 #include <qgarlib/QgarErrorDeveloper.H>
00053 namespace qgar
00054 {
00055   // Avoid #include's when not necessary
00056   class LabeledSkeletonImage;
00057 }
00058 
00059 
00060 
00061 namespace qgar
00062 {
00063 
00064 
00065 /**
00066  * @class LinkedChainList LinkedChainList.H "qgarlib/LinkedChainList.H"
00067  * @ingroup DS_POINT
00068  * @brief List of linked chains of <b>integer</b> points.
00069  *
00070  * @todo This class should not derive from STL class <b>list</b>,
00071  * but should be its client!
00072  * The current implementation may be/is the cause of memory losses
00073  * due to the use of dynamically allocated objects by the function
00074  * members...
00075  *
00076  * @author   <a href="mailto:qgar-develop@loria.fr?subject=Qgar fwd Karl Tombre">Karl Tombre</a>
00077  * @date     July 3,  2001  16:14
00078  * @since    Qgar 1.0
00079  */
00080 class LinkedChainList
00081 
00082   : public std::list< GenPointChain<int> >
00083 
00084 {
00085 // -------------------------------------------------------------------
00086 // P U B L I C    M E M B E R S
00087 // -------------------------------------------------------------------
00088 public:
00089 
00090   /** @name Constructors */
00091   //        ============
00092   //@{
00093 
00094   /**
00095    * @brief Build from given binary image.
00096    *
00097    * Build chains of points from a binary image, using an algorithm
00098    * designed by Salvatore Tabbone, and slightly improved by Karl
00099    * Tombre.
00100    *
00101    * - Chains of length smaller than threshold <b>minChainlength</b>
00102    *   are removed.
00103    * - Cycles of length smaller than threshold <b>minCycleLength</b>
00104    *   are not taken into account.
00105    */
00106   LinkedChainList(const BinaryImage& img, 
00107                   unsigned int minChainLength = 3,
00108                   unsigned int minCycleLength = 4);
00109 
00110   /**
00111    * @brief Build from a labeled skeleton.
00112    *
00113    * This function builds chains of points from a labeled skeleton image.
00114    * The algorithm used here takes advantage of the properties of a
00115    * labeled skeleton to construct chains taking junctions into account.
00116    *
00117    * @exception qgar::QgarErrorDeveloper (strange things happen!)
00118    */
00119   LinkedChainList(const LabeledSkeletonImage& skel)
00120     throw(QgarErrorDeveloper);
00121 
00122   /**
00123    * @brief Build with given minimal length parameters.
00124    * 
00125    * For temporary use...
00126    *
00127    * @todo
00128    * - Karl's note: For temporary use.
00129    * - G!'s note: Make it actually temporary!
00130    */
00131   LinkedChainList(unsigned int minChainLength = 0,
00132                   unsigned int minCycleLength = 0);
00133 
00134   //@}
00135 
00136 
00137   /** @name Destructor */
00138   //        ==========
00139   //@{
00140 
00141   /**
00142    * @brief Virtual destructor.
00143    */
00144   virtual ~LinkedChainList();
00145 
00146   //@}
00147 
00148 // -------------------------------------------------------------------
00149 // P R I V A T E    M E M B E R S
00150 // -------------------------------------------------------------------
00151 private:
00152 
00153   /** @name Auxiliary data */
00154   //        ==============
00155   //@{
00156 
00157   /**
00158    * @brief Minimum length of a valid chain.
00159    */
00160   int _minChainLength;
00161 
00162   /**
00163    * @brief Minimum length of a valid cycle.
00164    */
00165   int _minCycleLength;
00166 
00167   //@}
00168 
00169 
00170   /** @name Auxiliary functions */
00171   //       ====================
00172   //@{
00173 
00174   /**
00175    * @brief Recursive function for chaining.
00176    */
00177   PointChain* aChain(PointChain* ch,
00178                      int l,
00179                      int c,
00180                      GreyLevelImage& wkImg);
00181 
00182   //@}
00183 
00184 // -------------------------------------------------------------------
00185 }; // class LinkedChainList
00186 
00187 
00188 } // namespace qgar
00189 
00190 
00191 #endif /* __LINKEDCHAINLIST_H_INCLUDED__ */