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 Digital Image/Signal Processing Library 00026 * file .......: ltiOrientationFeature.h 00027 * authors ....: Pablo Alvarado 00028 * organization: LTI, RWTH Aachen 00029 * creation ...: 28.5.2001 00030 * revisions ..: $Id: ltiOrientationFeature.h,v 1.9 2006/02/08 11:36:01 ltilib Exp $ 00031 */ 00032 00033 #ifndef _LTI_ORIENTATION_FEATURE_H_ 00034 #define _LTI_ORIENTATION_FEATURE_H_ 00035 00036 #include "ltiImage.h" 00037 #include "ltiVector.h" 00038 00039 #include "ltiGlobalFeatureExtractor.h" 00040 00041 namespace lti { 00042 00043 /** 00044 * The orientation feature takes two channels: a "relevance" channel 00045 * and an "orientation" channel, and with them it creates an 00046 * orientation histogram with the given number of cells. 00047 * 00048 * Due to the fact that the orientation is Pi cyclic (0° is the same 00049 * thing as 180°) the histogram created will consider the angles as being 00050 * between 0 and Pi (angle mod Pi). 00051 * 00052 * A relevance/orientation pair can be for example the gradient 00053 * magnitude and phase channels (see lti::gradientKernelX and 00054 * lti::cartesicToPolar) and the OGD local energy maps (lti::axOGDFeature). 00055 * Both methods are ready implemented in the lti::orientationMap %functor. 00056 * 00057 * \code 00058 * 00059 * lti::orientationMap omapper; 00060 * lti::orientationFeature ofeat; 00061 * 00062 * lti::channel chnl,mag,dir; 00063 * lti::vector<double> vct; 00064 * 00065 * // construct a channel with a rectangle on it: 00066 * chnl.resize(256,256,0.0); 00067 * chnl.fill(1.0,32,32,200,240); 00068 * 00069 * // extract the orientation map from the channel 00070 * omapper.apply(chnl,dir,mag); 00071 * 00072 * // generate the orientation feature 00073 * ofeat.apply(dir,mag,vct); 00074 * 00075 * \endcode 00076 * 00077 * If you need a rotation invariant feature vector see also 00078 * lti::shiftInvariance 00079 */ 00080 class orientationFeature : public globalFeatureExtractor { 00081 public: 00082 /** 00083 * the parameters for the class orientationFeature 00084 */ 00085 class parameters : public globalFeatureExtractor::parameters { 00086 public: 00087 /** 00088 * default constructor 00089 */ 00090 parameters(); 00091 00092 /** 00093 * copy constructor 00094 * @param other the parameters object to be copied 00095 */ 00096 parameters(const parameters& other); 00097 00098 /** 00099 * destructor 00100 */ 00101 ~parameters(); 00102 00103 /** 00104 * returns name of this type 00105 */ 00106 const char* getTypeName() const; 00107 00108 /** 00109 * copy the contents of a parameters object 00110 * @param other the parameters object to be copied 00111 * @return a reference to this parameters object 00112 */ 00113 parameters& copy(const parameters& other); 00114 00115 /** 00116 * copy the contents of a parameters object 00117 * @param other the parameters object to be copied 00118 * @return a reference to this parameters object 00119 */ 00120 parameters& operator=(const parameters& other); 00121 00122 00123 /** 00124 * returns a pointer to a clone of the parameters 00125 */ 00126 virtual functor::parameters* clone() const; 00127 00128 /** 00129 * write the parameters in 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 write(ioHandler& handler,const bool complete=true) const; 00136 00137 /** 00138 * write the parameters in the given ioHandler 00139 * @param handler the ioHandler to be used 00140 * @param complete if true (the default) the enclosing begin/end will 00141 * be also written, otherwise only the data block will be written. 00142 * @return true if write was successful 00143 */ 00144 virtual bool read(ioHandler& handler,const bool complete=true); 00145 00146 # ifdef _LTI_MSC_6 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 read() instead 00153 */ 00154 bool readMS(ioHandler& handler,const bool complete=true); 00155 00156 /** 00157 * this function is required by MSVC only, as a workaround for a 00158 * very awful bug, which exists since MSVC V.4.0, and still by 00159 * V.6.0 with all bugfixes (so called "service packs") remains 00160 * there... This method is also public due to another bug, so please 00161 * NEVER EVER call this method directly: use write() instead 00162 */ 00163 bool writeMS(ioHandler& handler,const bool complete=true) const; 00164 # endif 00165 00166 // ------------------------------------------------ 00167 // the parameters 00168 // ------------------------------------------------ 00169 00170 //TODO: comment the parameters of your functor 00171 // If you add more parameters manually, do not forget to do following: 00172 // 1. indicate in the default constructor the default values 00173 // 2. make sure that the copy member also copy your new parameters 00174 // 3. make sure that the read and write members also read and 00175 // write your parameters 00176 00177 00178 /** 00179 * if true, the feature vector will be normalized to have an area of 00180 * one, i.e. the feature vector can be interpreted as a probability 00181 * distribution for the orientations. 00182 * If false, the resulting values depend on the values of the 00183 * magnitud channel. 00184 * Default: true 00185 */ 00186 bool normalize; 00187 00188 /** 00189 * size of the histogram. The angles from 0 to 180(1-1/size) degrees 00190 * will be mapped between 0 and size-1. 00191 * Default value: 36 (10 degrees resolution) 00192 */ 00193 int size; 00194 }; 00195 00196 /** 00197 * default constructor 00198 */ 00199 orientationFeature(); 00200 00201 /** 00202 * copy constructor 00203 * @param other the object to be copied 00204 */ 00205 orientationFeature(const orientationFeature& other); 00206 00207 /** 00208 * destructor 00209 */ 00210 virtual ~orientationFeature(); 00211 00212 /** 00213 * returns the name of this type ("orientationFeature") 00214 */ 00215 virtual const char* getTypeName() const; 00216 00217 /** 00218 * generates the "weighted histogram" of the given magnitude and 00219 * orientations channels. 00220 * 00221 * @param orientation channel with the orientation of edges 00222 * @param magnitude channel with the relevance of the orientation. 00223 * @param dest the result vector with the histogram data 00224 * @return true if apply successful or false otherwise. 00225 */ 00226 bool apply(const channel& orientation, 00227 const channel& magnitude, 00228 dvector& dest) const; 00229 00230 /** 00231 * copy data of "other" functor. 00232 * @param other the functor to be copied 00233 * @return a reference to this functor object 00234 */ 00235 orientationFeature& copy(const orientationFeature& other); 00236 00237 /** 00238 * returns a pointer to a clone of this functor. 00239 */ 00240 virtual functor* clone() const; 00241 00242 /** 00243 * returns used parameters 00244 */ 00245 const parameters& getParameters() const; 00246 }; 00247 } 00248 00249 #endif