latest version v1.9 - last update 10 Apr 2010 |
00001 /* 00002 * Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006 00003 * Lehrstuhl fuer Technische Informatik, RWTH-Aachen, Germany 00004 * 00005 * This file is part of the LTI-Computer Vision Library (LTI-Lib) 00006 * 00007 * The LTI-Lib is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU Lesser General Public License (LGPL) 00009 * as published by the Free Software Foundation; either version 2.1 of 00010 * the License, or (at your option) any later version. 00011 * 00012 * The LTI-Lib is distributed in the hope that it will be 00013 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty 00014 * of 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 the LTI-Lib; see the file LICENSE. If 00019 * not, write to the Free Software Foundation, Inc., 59 Temple Place - 00020 * Suite 330, Boston, MA 02111-1307, USA. 00021 */ 00022 00023 00024 /*---------------------------------------------------------------- 00025 * project ....: LTI Digital Image/Signal Processing Library 00026 * file .......: ltiSkeleton.h 00027 * authors ....: Daniel Ruijters 00028 * organization: LTI, RWTH Aachen 00029 * creation ...: 3.8.2000 00030 * revisions ..: $Id: ltiSkeleton.h,v 1.6 2006/02/08 11:50:50 ltilib Exp $ 00031 */ 00032 00033 #ifndef _LTI_SKELETON_H_ 00034 #define _LTI_SKELETON_H_ 00035 00036 #include "ltiObject.h" 00037 #include "ltiDilation.h" 00038 #include "ltiErosion.h" 00039 #include "ltiBinaryKernels.h" 00040 #include "ltiTransform.h" 00041 00042 namespace lti { 00043 00044 /** 00045 * Homotopy preserving Skeleton. 00046 * 00047 * This class implements the algorithm of Ji and Piper (IEEE 00048 * Transactions on Pattern Analysis and Maschine Intelligence, 00049 * vol. 14, no. 6, june 1992). 00050 * 00051 * The generated skeletons will keep the original homotopy of the 00052 * input channel. 00053 * 00054 * The input data must be segmented, with values 0 (background) and not 0 00055 * (object). 00056 * 00057 * @ingroup gMorphology 00058 */ 00059 class skeleton : public transform { 00060 public: 00061 /** 00062 * the parameters for the class skeleton 00063 */ 00064 class parameters : public transform::parameters { 00065 public: 00066 /** 00067 * default constructor 00068 */ 00069 parameters(); 00070 00071 /** 00072 * copy constructor 00073 * @param other the parameters object to be copied 00074 */ 00075 parameters(const parameters& other); 00076 00077 /** 00078 * destructor 00079 */ 00080 ~parameters(); 00081 00082 /** 00083 * returns name of this type 00084 */ 00085 const char* getTypeName() const; 00086 00087 /** 00088 * copy the contents of a parameters object 00089 * @param other the parameters object to be copied 00090 * @return a reference to this parameters object 00091 */ 00092 parameters& copy(const parameters& other); 00093 00094 /** 00095 * returns a pointer to a clone of the parameters 00096 */ 00097 virtual functor::parameters* clone() const; 00098 00099 /** 00100 * type of kernel 00101 */ 00102 enum eKernelType { 00103 CityBlock, /*!< city block kernel */ 00104 ChessBoard, /*!< chessboard kernel */ 00105 Euclidean /*!< eucledian kernel */ 00106 }; 00107 00108 /** 00109 * the type of the kernel. (Default type: CityBlock) 00110 */ 00111 eKernelType kernelType; 00112 00113 /** 00114 * Value given to the skeleton pixels (Default: 255) 00115 */ 00116 int formPointsValue; 00117 00118 /** 00119 * Value given to the homotopy-preserving pixels (Default: 255) 00120 */ 00121 int jPointsValue; 00122 }; 00123 00124 /** 00125 * default constructor 00126 */ 00127 skeleton(); 00128 00129 /** 00130 * copy constructor 00131 * @param other the object to be copied 00132 */ 00133 skeleton(const skeleton& other); 00134 00135 /** 00136 * destructor 00137 */ 00138 virtual ~skeleton(); 00139 00140 /** 00141 * returns the name of this type ("skeleton") 00142 */ 00143 virtual const char* getTypeName() const; 00144 00145 //TODO: comment your apply methods! 00146 00147 /** 00148 * operates on the given parameter. 00149 * @param srcdest channel with the source data. The result 00150 * will be left here too. 00151 * @result a reference to the <code>srcdest</code>. 00152 */ 00153 channel& apply(channel& srcdest) const; 00154 00155 /** 00156 * operates on the given parameter. 00157 * @param srcdest channel8 with the source data. The result 00158 * will be left here too. 00159 * @result a reference to the <code>srcdest</code>. 00160 */ 00161 channel8& apply(channel8& srcdest) const; 00162 00163 /** 00164 * operates on a copy of the given parameters. 00165 * @param src channel with the source data. 00166 * @param dest channel where the result will be left. 00167 * @result a reference to the <code>dest</code>. 00168 */ 00169 channel& apply(const channel& src,channel& dest) const; 00170 00171 /** 00172 * operates on a copy of the given parameters. 00173 * @param src channel8 with the source data. 00174 * @param dest channel8 where the result will be left. 00175 * @result a reference to the <code>dest</code>. 00176 */ 00177 channel8& apply(const channel8& src,channel8& dest) const; 00178 00179 /** 00180 * copy data of "other" functor. 00181 * @param other the functor to be copied 00182 * @return a reference to this functor object 00183 */ 00184 skeleton& copy(const skeleton& other); 00185 00186 /** 00187 * returns a pointer to a clone of this functor. 00188 */ 00189 virtual functor* clone() const; 00190 00191 /** 00192 * returns used parameters 00193 */ 00194 const parameters& getParameters() const; 00195 00196 protected: 00197 00198 /** 00199 * provides logical or of two channel8s 00200 */ 00201 channel8& img_or(const channel8& src1, channel8& srcdest) const; 00202 00203 /** 00204 * returns img \ stamp. (img with all pixels of stamp left out) 00205 */ 00206 channel8& difference(const channel8& img, 00207 const channel8& stamp, 00208 channel8& dest) const; 00209 00210 /** 00211 * calculate the jpoints for every pixel in src 00212 * jpoints are needed to preserve homotopy 00213 */ 00214 channel8& calc_jpoints(const channel8& src, 00215 const channel8& match, 00216 channel8& dest) const; 00217 00218 channel8& calc_hpoints(const channel8& src, 00219 const channel8& match1, 00220 const channel8& match2, 00221 channel8& dest) const; 00222 00223 /** 00224 * sets all non-zero values of a channel to int val 00225 */ 00226 channel8& visualize(channel8& srcdest, const int& val) const; 00227 00228 }; 00229 } 00230 00231 #endif