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 .......: ltiOrientationMap.h 00027 * authors ....: Pablo Alvarado 00028 * organization: LTI, RWTH Aachen 00029 * creation ...: 26.5.2000 00030 * revisions ..: $Id: ltiOrientationMap.h,v 1.9 2006/02/08 11:36:27 ltilib Exp $ 00031 */ 00032 00033 #ifndef _LTI_ORIENTATION_MAP_H_ 00034 #define _LTI_ORIENTATION_MAP_H_ 00035 00036 #include "ltiTransform.h" 00037 00038 namespace lti { 00039 /** 00040 * Generate an orientation map of a given channel 00041 * 00042 * There are two modes for this functor: 00043 * - The first one is based on the gradient approximation of the 00044 * channel values, which will consider the whole frequency spectrum 00045 * for the orientation estimation. 00046 * 00047 * - The second mode is base on some characteristics of the first order 00048 * oriented gaussian derivative to calculate the direction with the 00049 * maximal energy. The use of this steerable filters allows the 00050 * consideration of just one frequency band. It is much slower than the 00051 * gradient mode. 00052 * 00053 * The result of the analysis are two channels: 00054 * 00055 * In the gradient mode the first resulting channel contains the 00056 * angle (in radians) of the local gradient. 00057 * The second channel contains the magnitude of the gradient. 00058 * 00059 * In the ogd mode the first channel will contain the 00060 * angle (in radians) with the local maximal energy, and 00061 * the second channel contains a relevance-ratio of the obtained direction. 00062 * 00063 * Note that the return angle is always perpendicular to the edge direction. 00064 * 00065 * The angular value lies between -Pi and Pi. 00066 * 00067 * \warning: This functor is too old, maybe you are just looking for the 00068 * lti::gradientFunctor in the polar coordinates mode. 00069 * 00070 * @see orientationMap::parameters 00071 */ 00072 class orientationMap : public transform { 00073 public: 00074 /** 00075 * the parameters for the class orientationMap 00076 */ 00077 class parameters : public transform::parameters { 00078 public: 00079 /** 00080 * default constructor 00081 */ 00082 parameters(); 00083 00084 /** 00085 * copy constructor 00086 * @param other the parameters object to be copied 00087 */ 00088 parameters(const parameters& other); 00089 00090 /** 00091 * destructor 00092 */ 00093 ~parameters(); 00094 00095 /** 00096 * returns name of this type 00097 */ 00098 const char* getTypeName() const; 00099 00100 /** 00101 * copy the contents of a parameters object 00102 * @param other the parameters object to be copied 00103 * @return a reference to this parameters object 00104 */ 00105 parameters& copy(const parameters& other); 00106 00107 /** 00108 * copy the contents of a parameters object 00109 * @param other the parameters object to be copied 00110 * @return a reference to this parameters object 00111 */ 00112 parameters& operator=(const parameters& other); 00113 00114 /** 00115 * returns a pointer to a clone of the parameters 00116 */ 00117 virtual functor::parameters* clone() const; 00118 00119 /** 00120 * write the parameters in the given ioHandler 00121 * @param handler the ioHandler to be used 00122 * @param complete if true (the default) the enclosing begin/end will 00123 * be also written, otherwise only the data block will be written. 00124 * @return true if write was successful 00125 */ 00126 virtual bool write(ioHandler& handler,const bool complete=true) const; 00127 00128 /** 00129 * read the parameters from the given ioHandler 00130 * @param handler the ioHandler to be used 00131 * @param complete if true (the default) the enclosing begin/end will 00132 * be also written, otherwise only the data block will be written. 00133 * @return true if write was successful 00134 */ 00135 virtual bool read(ioHandler& handler,const bool complete=true); 00136 00137 # ifdef _LTI_MSC_6 00138 /** 00139 * this function is required by MSVC only, as a workaround for a 00140 * very awful bug, which exists since MSVC V.4.0, and still by 00141 * V.6.0 with all bugfixes (so called "service packs") remains 00142 * there... This method is also public due to another bug, so please 00143 * NEVER EVER call this method directly: use read() instead 00144 */ 00145 bool readMS(ioHandler& handler,const bool complete=true); 00146 00147 /** 00148 * this function is required by MSVC only, as a workaround for a 00149 * very awful bug, which exists since MSVC V.4.0, and still by 00150 * V.6.0 with all bugfixes (so called "service packs") remains 00151 * there... This method is also public due to another bug, so please 00152 * NEVER EVER call this method directly: use write() instead 00153 */ 00154 bool writeMS(ioHandler& handler,const bool complete=true) const; 00155 # endif 00156 00157 // ------------------------------------------------ 00158 // the parameters 00159 // ------------------------------------------------ 00160 00161 /** 00162 * the possible modes for the orientation map 00163 */ 00164 enum eMode { 00165 Ogd, /*!< Oriented gaussian derivative */ 00166 Gradient /*!< Gradient mode */ 00167 }; 00168 00169 /** 00170 * mode for the orientation map. It can be Ogd or Gradient. 00171 * 00172 * Default value: Gradient 00173 */ 00174 eMode mode; 00175 00176 /** 00177 * size of the used filter. 00178 * 00179 * This specify the size of the region being used to calculate 00180 * the direction. In "Gradient"-mode this is the size of the 00181 * gradient approximation kernel. 00182 */ 00183 int size; 00184 00185 /** 00186 * variance of the used ogd filter 00187 */ 00188 double variance; 00189 00190 /** 00191 * size of the low pass filter used as integrator 00192 * 00193 * To calculate the direction, a local-region from 00194 * the ogd-filtered channel must be evaluated. This parameter 00195 * specify the dimensions of this region. 00196 */ 00197 int localFilterSize; 00198 00199 /** 00200 * variance of the low pass filter used as integrator 00201 */ 00202 double localFilterVariance; 00203 }; 00204 00205 /** 00206 * default constructor 00207 */ 00208 orientationMap(); 00209 00210 /** 00211 * copy constructor 00212 * @param other the object to be copied 00213 */ 00214 orientationMap(const orientationMap& other); 00215 00216 /** 00217 * destructor 00218 */ 00219 virtual ~orientationMap(); 00220 00221 /** 00222 * returns the name of this type ("orientationMap") 00223 */ 00224 virtual const char* getTypeName() const; 00225 00226 /** 00227 * generate the orientation map 00228 * @param src channel with the source data. 00229 * @param direction channel where the direction will be left. 00230 * The values will be between -Pi and Pi. 00231 * @param relevance channel with values between 0 and 1, which 00232 * specify how relevant the direction information is. 00233 * @return true if successful, false otherwise. 00234 */ 00235 bool apply(const channel& src, 00236 channel& direction, 00237 channel& relevance) const; 00238 00239 00240 /** 00241 * generate the orientation map 00242 * @param src channel8 with the source data. 00243 * @param direction channel8 where the direction will be left. 00244 * The values will be between -Pi and Pi. 00245 * @param relevance channel8 with values between 0 and 1, which 00246 * specify how relevant the direction information is. 00247 * @return true if successful, false otherwise. 00248 */ 00249 bool apply(const channel8& src, 00250 channel8& direction, 00251 channel8& relevance) const; 00252 00253 /** 00254 * copy data of "other" functor. 00255 * @param other the functor to be copied 00256 * @return a reference to this functor object 00257 */ 00258 orientationMap& copy(const orientationMap& other); 00259 00260 /** 00261 * returns a pointer to a clone of this functor. 00262 */ 00263 virtual functor* clone() const; 00264 00265 /** 00266 * returns used parameters 00267 */ 00268 const parameters& getParameters() const; 00269 00270 protected: 00271 /** 00272 * generate the orientation map 00273 * @param src channel with the source data. 00274 * @param direction channel where the direction will be left. 00275 * The values will be between -Pi and Pi. 00276 * @param relevance channel with values between 0 and 1, which 00277 * specify how relevant the direction information is. 00278 * @result a reference to the <code>direction</code>. 00279 */ 00280 channel& ogdMap(const channel& src, 00281 channel& direction, 00282 channel& relevance) const; 00283 00284 /** 00285 * generate the orientation map 00286 * @param src channel with the source data. 00287 * @param direction channel where the direction will be left. 00288 * The values will be between -Pi and Pi. 00289 * @param relevance channel with values between 0 and 1, which 00290 * specify how relevant the direction information is. 00291 * @result a reference to the <code>direction</code>. 00292 */ 00293 channel& gradientMap(const channel& src, 00294 channel& direction, 00295 channel& relevance) const; 00296 00297 }; 00298 } 00299 00300 #endif