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