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

LinErodedBinaryImage.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 __LINERODEDBINARYIMAGE_H_INCLUDED__
00029 #define __LINERODEDBINARYIMAGE_H_INCLUDED__
00030 
00031 
00032 /**
00033  * @file   LinErodedBinaryImage.H
00034  * @brief  Header file of class qgar::LinErodedBinaryImage.
00035  *
00036  * @author <a href="mailto:qgar-develop@loria.fr?subject=Qgar fwd Mathieu Baeumler">Mathieu Baeumler</a>
00037  * @date   August 5, 2002  16:08
00038  * @since  Qgar 2.0
00039  */
00040 
00041 
00042 
00043 // For RCS/CVS use: Do not delete
00044 /* $Id: LinErodedBinaryImage.H,v 1.16 2005/10/14 17:05:47 masini Exp $ */
00045 
00046 
00047 
00048 // QGAR
00049 #include <qgarlib/GenImage.H>
00050 #include <qgarlib/QgarErrorDomain.H>
00051 
00052 
00053 
00054 namespace qgar
00055 {
00056 
00057 /**
00058  * @ingroup IMGPROC_MORPH
00059  *
00060  * @class LinErodedBinaryImage LinErodedBinaryImage.H "qgarlib/LinErodedBinaryImage.H"
00061  *
00062  * @brief Binary image linearly eroded, using a segment.
00063  *
00064  * The length of the segment is <b>2 * aDilSize + 1</b>.
00065  * The algorithm is very simple: Two pointers follow the current line,
00066  * at a <b>aDilSize</b> distance from each other. When the first pointer
00067  * meets a zero pixel or when the second pointer meets a non-zero pixel,
00068  * the next <b>aDilSize</b> pixels are set to zero.
00069  * 
00070  * @author <a href="mailto:qgar-develop@loria.fr?subject=Qgar fwd Mathieu Baeumler">Mathieu Baeumler</a>
00071  * @date   August 5, 2002  16:08
00072  * @since  Qgar 2.0
00073  */
00074 class LinErodedBinaryImage
00075 
00076   : public BinaryImage
00077 
00078 {
00079 // -------------------------------------------------------------------
00080 // T Y P E   D E F I N I T I O N S
00081 // -------------------------------------------------------------------
00082 public:
00083 
00084   /** @name Types */
00085   //        =====
00086   //@{
00087 
00088   /**
00089    * @brief Type of the elements stored in the pixel map.
00090    */
00091   typedef BinaryImage::value_type value_type;
00092 
00093   /**
00094    * @brief Reference to qgar::LinErodedBinaryImage::value_type.
00095    */
00096   typedef value_type& reference;
00097 
00098   /**
00099    * @brief Constant reference to qgar::LinErodedBinaryImage::value_type.
00100    */
00101   typedef const value_type& const_reference;
00102 
00103   /**
00104    * @brief Pointer to qgar::LinErodedBinaryImage::value_type.
00105    */
00106   typedef value_type* pointer;
00107 
00108   /**
00109    * @brief Constant pointer to qgar::LinErodedBinaryImage::value_type.
00110    */
00111   typedef const value_type* const_pointer;
00112 
00113   //@}
00114 
00115 // -------------------------------------------------------------------
00116 // P U B L I C    M E M B E R S
00117 // -------------------------------------------------------------------
00118 public:
00119 
00120   /** @name Constructors */
00121   //        ============
00122   //@{
00123 
00124   /**
00125    * @brief Construct from a binary image. 
00126    *
00127    * Orientation qgar::QGE_ORIENTATION_ALL corresponds to the
00128    * maximum of the 4 possible erosions.
00129    *
00130    * @param anImg      image to be eroded
00131    * @param anOrient   erosion orientation
00132    *                   (default qgar::QGE_ORIENTATION_HOR)
00133    * @param anEroSize  erosion size (default <b>1</b>)
00134    *
00135    * @exception qgar::QgarErrorDomain
00136    * (erosion size too large for image)
00137    */
00138   LinErodedBinaryImage(const BinaryImage& anImg,
00139                        QGEorientation anOrient = QGE_ORIENTATION_HOR,
00140                        unsigned int anEroSize = 1)
00141     throw(QgarErrorDomain);
00142 
00143   //@}
00144 
00145 
00146   /** @name Linear erosion */
00147   //        ==============
00148   //@{
00149 
00150   /**
00151    * @brief Perform a linear erosion on a given binary image.
00152    *
00153    * <b>To be used to perform a linear erosion without preserving
00154    * the initial image.</b>
00155    *
00156    * @param  anImg      image to be eroded
00157    * @param  anOrient   erosion orientation
00158    * @param  anEroSize  erosion size (default <b>1</b>)
00159    */
00160   static void perform(BinaryImage* anImg,
00161                       QGEorientation anOrient,
00162                       unsigned int anEroSize = 1);
00163 
00164   //@}
00165 
00166 // -------------------------------------------------------------------
00167 // P R I V A T E    M E M B E R S
00168 // -------------------------------------------------------------------
00169 private:
00170 
00171   /** @name Oriented erosions */
00172   //        =================
00173   //@{
00174 
00175   /**
00176    * @brief Horizontal erosion.
00177    *
00178    * @param anImg      image to be eroded
00179    * @param anEroSize  erosion size
00180    *
00181    * @exception qgar::QgarErrorDomain
00182    * (erosion size too large for image)
00183    */
00184   static void erodeHor(BinaryImage* anImg, unsigned int anEroSize)
00185     throw(QgarErrorDomain);
00186 
00187   /**
00188    * @brief Vertical erosion.
00189    *
00190    * @param anImg      image to be eroded
00191    * @param anEroSize  erosion size
00192    *
00193    * @exception qgar::QgarErrorDomain
00194    * (erosion size too large for image)
00195    */
00196   static void erodeVer(BinaryImage* anImg, unsigned int anEroSize)
00197     throw(QgarErrorDomain);
00198 
00199   /**
00200    * @brief NE-SW erosion.
00201    *
00202    * @param anImg      image to be eroded
00203    * @param anEroSize  erosion size
00204    *
00205    * @exception qgar::QgarErrorDomain
00206    * (erosion size too large for image)
00207    */
00208   static void erodePdiag(BinaryImage* anImg, unsigned int anEroSize)
00209     throw(QgarErrorDomain);
00210   
00211   /**
00212    * @brief NW-SE erosion.
00213    *
00214    * @param anImg      image to be eroded
00215    * @param anEroSize  erosion size
00216    *
00217    * @exception qgar::QgarErrorDomain
00218    * (erosion size too large for image)
00219    */
00220   static void erodeNdiag(BinaryImage* anImg, unsigned int anEroSize)
00221     throw(QgarErrorDomain);
00222 
00223   /**
00224    * @brief Maximum of the 4 erosions.
00225    *
00226    * @param anImg      image to be eroded
00227    * @param anEroSize  erosion size
00228    *
00229    * @exception qgar::QgarErrorDomain
00230    * (erosion size too large for image)
00231    */
00232   static void erodeAll(BinaryImage* anImg, unsigned int anEroSize)
00233     throw(QgarErrorDomain);
00234 
00235   //@}
00236 
00237 // -------------------------------------------------------------------
00238 }; // class LinErodedBinaryImage
00239 
00240 
00241 } // namespace qgar
00242 
00243 
00244 #endif /* __LINERODEDBINARYIMAGE_H_INCLUDED__ */