latest version v1.9 - last update 10 Apr 2010 |
00001 /* 00002 * Copyright (C) 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 .......: ltiSffs.h 00027 * authors ....: Jens Paustenbach 00028 * organization: LTI, RWTH Aachen 00029 * creation ...: 11.7.2002 00030 * revisions ..: $Id: ltiSffs.h,v 1.7 2006/02/07 18:25:59 ltilib Exp $ 00031 */ 00032 00033 #ifndef _LTI_SFFS_H_ 00034 #define _LTI_SFFS_H_ 00035 00036 00037 #include "ltiVector.h" 00038 #include "ltiMatrix.h" 00039 #include "ltiFeatureSelector.h" 00040 #include "ltiCostFunction.h" 00041 // #include "ltiSupervisedInstanceClassifier.h" 00042 00043 namespace lti { 00044 /** 00045 * Implemantation of the sequential floating forward search algorithm to 00046 * select the best features from a data set. 00047 * This algorithm is implented from: P. Pudil, F.J. Ferri, J. Novovicova, 00048 * J. Kittler: "Floating Search Methods for Feature Selection with 00049 * nonmonotonic criterion Functions" Procedings of the IEEE Intl. Conf. 00050 * on Pattern Recognition, 279-283, 1994; 00051 * The original SFFS-Algorithm is discriped in P.Pudil,J.Novovicova,Kittler 00052 * "Floating search methods in feature selection" Pattern Recogniton 00053 * Letters 15, pages 1119-1125 00054 */ 00055 class sffs : public featureSelector { 00056 public: 00057 /** 00058 * the parameters for the class sffs 00059 */ 00060 class parameters : public featureSelector::parameters { 00061 public: 00062 /** 00063 * default constructor 00064 */ 00065 parameters(); 00066 00067 /** 00068 * copy constructor 00069 * @param other the parameters object to be copied 00070 */ 00071 parameters(const parameters& other); 00072 00073 /** 00074 * destructor 00075 */ 00076 ~parameters(); 00077 00078 /** 00079 * returns name of this type 00080 */ 00081 const char* getTypeName() const; 00082 00083 /** 00084 * copy the contents of a parameters object 00085 * @param other the parameters object to be copied 00086 * @return a reference to this parameters object 00087 */ 00088 parameters& copy(const parameters& other); 00089 00090 /** 00091 * copy the contents of a parameters object 00092 * @param other the parameters object to be copied 00093 * @return a reference to this parameters object 00094 */ 00095 parameters& operator=(const parameters& other); 00096 00097 00098 /** 00099 * returns a pointer to a clone of the parameters 00100 */ 00101 virtual functor::parameters* clone() const; 00102 00103 /** 00104 * write the parameters in the given ioHandler 00105 * @param handler the ioHandler to be used 00106 * @param complete if true (the default) the enclosing begin/end will 00107 * be also written, otherwise only the data block will be written. 00108 * @return true if write was successful 00109 */ 00110 virtual bool write(ioHandler& handler,const bool complete=true) const; 00111 00112 /** 00113 * read the parameters from the given ioHandler 00114 * @param handler the ioHandler to be used 00115 * @param complete if true (the default) the enclosing begin/end will 00116 * be also written, otherwise only the data block will be written. 00117 * @return true if write was successful 00118 */ 00119 virtual bool read(ioHandler& handler,const bool complete=true); 00120 00121 # ifdef _LTI_MSC_6 00122 /** 00123 * this function is required by MSVC only, as a workaround for a 00124 * very awful bug, which exists since MSVC V.4.0, and still by 00125 * V.6.0 with all bugfixes (so called "service packs") remains 00126 * there... This method is also public due to another bug, so please 00127 * NEVER EVER call this method directly: use read() instead 00128 */ 00129 bool readMS(ioHandler& handler,const bool complete=true); 00130 00131 /** 00132 * this function is required by MSVC only, as a workaround for a 00133 * very awful bug, which exists since MSVC V.4.0, and still by 00134 * V.6.0 with all bugfixes (so called "service packs") remains 00135 * there... This method is also public due to another bug, so please 00136 * NEVER EVER call this method directly: use write() instead 00137 */ 00138 bool writeMS(ioHandler& handler,const bool complete=true) const; 00139 # endif 00140 00141 // ------------------------------------------------ 00142 // the parameters 00143 // ------------------------------------------------ 00144 00145 /** 00146 * the cost function that is used to decide which features are the best 00147 * in the context of the cost function 00148 */ 00149 costFunction* usedCostFunction; 00150 00151 // /** 00152 // * the classifier used in the cross validator 00153 // */ 00154 // supervisedInstanceClassifier* classifier; 00155 00156 // enum eCostFunctions { 00157 // bhattacharyyaDistance, 00158 // mahalanobisDistance, 00159 // crossValidation 00160 // }; 00161 00162 // /** 00163 // * The cost function that is used to decide if a feature is better than 00164 // * an other feature. 00165 // */ 00166 // eCostFunctions costFunction; 00167 00168 00169 }; 00170 00171 /** 00172 * default constructor 00173 */ 00174 sffs(); 00175 00176 /** 00177 * copy constructor 00178 * @param other the object to be copied 00179 */ 00180 sffs(const sffs& other); 00181 00182 /** 00183 * destructor 00184 */ 00185 virtual ~sffs(); 00186 00187 /** 00188 * returns the name of this type ("sffs") 00189 */ 00190 virtual const char* getTypeName() const; 00191 00192 //TODO: comment your apply methods! 00193 00194 // /** 00195 // * operates on the given %parameter. 00196 // * @param srcdest dmatrix with the source data. The result 00197 // * will be left here too. 00198 // * @return true if apply successful or false otherwise. 00199 // */ 00200 // bool apply(dmatrix& srcdest) const; 00201 00202 // /** 00203 // * operates on a copy of the given %parameters. 00204 // * @param src dmatrix with the source data. 00205 // * @param dest dmatrix where the result will be left. 00206 // * @return true if apply successful or false otherwise. 00207 // */ 00208 // bool apply(const dmatrix& src,const ivector& srcIds, dmatrix& dest) const; 00209 00210 /** 00211 * extracts the most significant features from a source data set 00212 * @param src the src data 00213 * @param srcIds the cluster ids corresponding to the data points in src 00214 * @param dest the extracted features 00215 * @return true if apply successful or false otherwise. 00216 */ 00217 bool apply(const dmatrix& src,const ivector& srcIds,dmatrix& dest) const; 00218 00219 /** 00220 * copy data of "other" functor. 00221 * @param other the functor to be copied 00222 * @return a reference to this functor object 00223 */ 00224 sffs& copy(const sffs& other); 00225 00226 /** 00227 * alias for copy member 00228 * @param other the functor to be copied 00229 * @return a reference to this functor object 00230 */ 00231 sffs& operator=(const sffs& other); 00232 00233 /** 00234 * returns a pointer to a clone of this functor. 00235 */ 00236 virtual functor* clone() const; 00237 00238 /** 00239 * returns used parameters 00240 */ 00241 const parameters& getParameters() const; 00242 00243 }; 00244 } 00245 00246 #endif