latest version v1.9 - last update 10 Apr 2010 |
00001 /* 00002 * Copyright (C) 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-Lib: Image Processing and Computer Vision Library 00026 * file .......: ltiCurvatureFeature.h 00027 * authors ....: Pablo Alvarado 00028 * organization: LTI, RWTH Aachen 00029 * creation ...: 5.12.2001 00030 * revisions ..: $Id: ltiCurvatureFeature.h,v 1.8 2006/02/07 18:43:49 ltilib Exp $ 00031 */ 00032 00033 #ifndef _LTI_CURVATURE_FEATURE_H_ 00034 #define _LTI_CURVATURE_FEATURE_H_ 00035 00036 00037 #include "ltiImage.h" 00038 #include "ltiGlobalFeatureExtractor.h" 00039 00040 namespace lti { 00041 /** 00042 * The curvature feature is similar to the lti::orientationFeature, 00043 * but instead of creating a histogram of the pixel orientations, a 00044 * histogram of the curvature of a pixel will be done, considering 00045 * also the "relevance" channel when constructing it. All values in 00046 * the relevance channel smaller than the 00047 * <code>relevanceThreshold</code> will be ignored (will be marked 00048 * with zero curvature). 00049 * 00050 * The curvature is defined as the derivative of the tangent of a given 00051 * contour. This will be approximated here using the differences of 00052 * orientation between the neighbour pixels. 00053 */ 00054 class curvatureFeature : public globalFeatureExtractor { 00055 public: 00056 /** 00057 * the parameters for the class curvatureFeature 00058 */ 00059 class parameters : public globalFeatureExtractor::parameters { 00060 public: 00061 /** 00062 * default constructor 00063 */ 00064 parameters(); 00065 00066 /** 00067 * copy constructor 00068 * @param other the parameters object to be copied 00069 */ 00070 parameters(const parameters& other); 00071 00072 /** 00073 * destructor 00074 */ 00075 ~parameters(); 00076 00077 /** 00078 * returns name of this type 00079 */ 00080 const char* getTypeName() const; 00081 00082 /** 00083 * copy the contents of a parameters object 00084 * @param other the parameters object to be copied 00085 * @return a reference to this parameters object 00086 */ 00087 parameters& copy(const parameters& other); 00088 00089 /** 00090 * copy the contents of a parameters object 00091 * @param other the parameters object to be copied 00092 * @return a reference to this parameters object 00093 */ 00094 parameters& operator=(const parameters& other); 00095 00096 00097 /** 00098 * returns a pointer to a clone of the parameters 00099 */ 00100 virtual functor::parameters* clone() const; 00101 00102 /** 00103 * write the parameters in the given ioHandler 00104 * @param handler the ioHandler to be used 00105 * @param complete if true (the default) the enclosing begin/end will 00106 * be also written, otherwise only the data block will be written. 00107 * @return true if write was successful 00108 */ 00109 virtual bool write(ioHandler& handler,const bool complete=true) const; 00110 00111 /** 00112 * read the parameters from the given ioHandler 00113 * @param handler the ioHandler to be used 00114 * @param complete if true (the default) the enclosing begin/end will 00115 * be also written, otherwise only the data block will be written. 00116 * @return true if write was successful 00117 */ 00118 virtual bool read(ioHandler& handler,const bool complete=true); 00119 00120 # ifdef _LTI_MSC_6 00121 /** 00122 * this function is required by MSVC only, as a workaround for a 00123 * very awful bug, which exists since MSVC V.4.0, and still by 00124 * V.6.0 with all bugfixes (so called "service packs") remains 00125 * there... This method is also public due to another bug, so please 00126 * NEVER EVER call this method directly: use read() instead 00127 */ 00128 bool readMS(ioHandler& handler,const bool complete=true); 00129 00130 /** 00131 * this function is required by MSVC only, as a workaround for a 00132 * very awful bug, which exists since MSVC V.4.0, and still by 00133 * V.6.0 with all bugfixes (so called "service packs") remains 00134 * there... This method is also public due to another bug, so please 00135 * NEVER EVER call this method directly: use write() instead 00136 */ 00137 bool writeMS(ioHandler& handler,const bool complete=true) const; 00138 # endif 00139 00140 // ------------------------------------------------ 00141 // the parameters 00142 // ------------------------------------------------ 00143 00144 /** 00145 * Size for the gaussian kernel used to smooth the orientation 00146 * channel. If you do not want to smooth the angles, use a 00147 * gaussian size of 0 or 1. 00148 * 00149 * Default value: 3 00150 */ 00151 int gaussianSize; 00152 00153 /** 00154 * Variance for the gaussian filter used to smooth the 00155 * orientation channel. If you do not want to smooth the 00156 * angles, use a gaussian size of 0 or 1. 00157 * 00158 * Default value: -1 (i.e. let the constructor of the gaussian 00159 * kernel choose a variance value 00160 * appropriate for the kernel size) 00161 */ 00162 float gaussianVariance; 00163 00164 /** 00165 * Value used to get the orientation of the neighbour pixels 00166 */ 00167 float deltaLength; 00168 00169 /** 00170 * Minimal relevance value needed to consider a pixel in the 00171 * computations. 00172 */ 00173 float relevanceThreshold; 00174 00175 /** 00176 * if true, the feature vector will be normalized to have an area of 00177 * one, i.e. the feature vector can be interpreted as a probability 00178 * distribution for the orientations. 00179 * If false, the resulting values depend on the values of the 00180 * magnitud channel. 00181 * Default: true 00182 */ 00183 bool normalize; 00184 00185 /** 00186 * lower limit for the histogram. All curvature values below this 00187 * threshold will be ignored. This value MUST be lower than the 00188 * upperLimit. 00189 * 00190 * Valid value range: -Pi/2 .. Pi/2 00191 * 00192 * Default value: -Pi/2 00193 */ 00194 float lowerLimit; 00195 00196 /** 00197 * upper limit for the histogram. All curvature values above this 00198 * threshold will be ignored. This value MUST be higher than the 00199 * lowerLimit 00200 * 00201 * Valid value range: -Pi/2 .. Pi/2 00202 * 00203 * Default value: Pi/2 00204 */ 00205 float upperLimit; 00206 00207 /** 00208 * size of the histogram. The curvature values from -lowerLimit 00209 * to upperLimit will be mapped between 0 and size-1. 00210 * 00211 * Default value: 64 00212 */ 00213 int size; 00214 }; 00215 00216 /** 00217 * default constructor 00218 */ 00219 curvatureFeature(); 00220 00221 /** 00222 * copy constructor 00223 * @param other the object to be copied 00224 */ 00225 curvatureFeature(const curvatureFeature& other); 00226 00227 /** 00228 * destructor 00229 */ 00230 virtual ~curvatureFeature(); 00231 00232 /** 00233 * returns the name of this type ("curvatureFeature") 00234 */ 00235 virtual const char* getTypeName() const; 00236 00237 /** 00238 * compute the feature vector 00239 * @param orientation channel with the angle of the tangent for all pixels 00240 * @param relevance channel with a "relevance"-degree for the orientation 00241 * channel. Values of 0 mean, the angle in the 00242 * orientation channel has to be ignored, and 1 that 00243 * the value in the orientation channel is reliable. 00244 * @param dest feature vector. 00245 * @return true if apply successful or false otherwise. 00246 */ 00247 bool apply(const channel& orientation, 00248 const channel& relevance, 00249 dvector& dest) const; 00250 00251 /** 00252 * Computes a curvature channel from the given orientation and relevance 00253 * channels. 00254 * 00255 * @param orientation channel with the angle of the tangent for all pixels 00256 * @param relevance channel with a "relevance"-degree for the orientation 00257 * channel. Values of 0 mean, the angle in the 00258 * orientation channel has to be ignored, and 1 that 00259 * the value in the orientation channel is reliable. 00260 * @param dest channel with the curvature value computed for each pixel. 00261 * @return true if apply successful or false otherwise. 00262 */ 00263 bool apply(const channel& orientation, 00264 const channel& relevance, 00265 channel& dest) const; 00266 00267 /** 00268 * Computes a curvature channel and the corresponding feature vector 00269 * from the given orientation and relevance channels. 00270 * 00271 * @param orientation channel with the angle of the tangent for all pixels 00272 * @param relevance channel with a "relevance"-degree for the orientation 00273 * channel. Values of 0 mean, the angle in the 00274 * orientation channel has to be ignored, and 1 that 00275 * the value in the orientation channel is reliable. 00276 * @param dest channel with the curvature value computed for each pixel. 00277 * @param vct feature vector 00278 * @return true if apply successful or false otherwise. 00279 */ 00280 bool apply(const channel& orientation, 00281 const channel& relevance, 00282 channel& dest, 00283 dvector& vct) const; 00284 00285 /** 00286 * copy data of "other" functor. 00287 * @param other the functor to be copied 00288 * @return a reference to this functor object 00289 */ 00290 curvatureFeature& copy(const curvatureFeature& other); 00291 00292 /** 00293 * alias for copy member 00294 * @param other the functor to be copied 00295 * @return a reference to this functor object 00296 */ 00297 curvatureFeature& operator=(const curvatureFeature& other); 00298 00299 /** 00300 * returns a pointer to a clone of this functor. 00301 */ 00302 virtual functor* clone() const; 00303 00304 /** 00305 * returns used parameters 00306 */ 00307 const parameters& getParameters() const; 00308 00309 }; 00310 } 00311 00312 #endif