LTI-Lib latest version v1.9 - last update 10 Apr 2010

ltiFeatureSelector.h

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 .......: ltiFeatureSelector.h
00027  * authors ....: Jens Paustenbach
00028  * organization: LTI, RWTH Aachen
00029  * creation ...: 4.7.2002
00030  * revisions ..: $Id: ltiFeatureSelector.h,v 1.7 2006/02/07 18:17:23 ltilib Exp $
00031  */
00032 
00033 #ifndef _LTI_FEATURE_SELECTOR_H_
00034 #define _LTI_FEATURE_SELECTOR_H_
00035 
00036 
00037 #include "ltiVector.h"
00038 #include "ltiMatrix.h"
00039 #include "ltiFunctor.h"
00040 
00041 namespace lti {
00042   /**
00043    * Abstract base class for all feature selectors.
00044    * A feature selector extracts the most significant features from a data set.
00045    */
00046   class featureSelector : public functor {
00047   public:
00048     /**
00049      * the parameters for the class featureSelector
00050      */
00051     class parameters : public functor::parameters {
00052     public:
00053       /**
00054        * default constructor
00055        */
00056       parameters();
00057 
00058       /**
00059        * copy constructor
00060        * @param other the parameters object to be copied
00061        */
00062       parameters(const parameters& other);
00063 
00064       /**
00065        * destructor
00066        */
00067       ~parameters();
00068 
00069       /**
00070        * returns name of this type
00071        */
00072       const char* getTypeName() const;
00073 
00074       /**
00075        * copy the contents of a parameters object
00076        * @param other the parameters object to be copied
00077        * @return a reference to this parameters object
00078        */
00079       parameters& copy(const parameters& other);
00080    
00081       /**
00082        * copy the contents of a parameters object
00083        * @param other the parameters object to be copied
00084        * @return a reference to this parameters object
00085        */
00086       parameters& operator=(const parameters& other);
00087 
00088 
00089       /**
00090        * returns a pointer to a clone of the parameters
00091        */
00092       virtual functor::parameters* clone() const;
00093 
00094       /**
00095        * write the parameters in the given ioHandler
00096        * @param handler the ioHandler to be used
00097        * @param complete if true (the default) the enclosing begin/end will
00098        *        be also written, otherwise only the data block will be written.
00099        * @return true if write was successful
00100        */
00101       virtual bool write(ioHandler& handler,const bool complete=true) const;
00102 
00103       /**
00104        * read the parameters from 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 read(ioHandler& handler,const bool complete=true);
00111 
00112 #     ifdef _LTI_MSC_6     
00113       /**
00114        * this function is required by MSVC only, as a workaround for a
00115        * very awful bug, which exists since MSVC V.4.0, and still by
00116        * V.6.0 with all bugfixes (so called "service packs") remains
00117        * there...  This method is also public due to another bug, so please
00118        * NEVER EVER call this method directly: use read() instead
00119        */
00120       bool readMS(ioHandler& handler,const bool complete=true);
00121 
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 write() instead
00128        */
00129       bool writeMS(ioHandler& handler,const bool complete=true) const;
00130 #     endif
00131 
00132       // ------------------------------------------------
00133       // the parameters
00134       // ------------------------------------------------
00135 
00136       /**
00137        * Number of features that will be extracted
00138        */
00139       int nbFeatures;
00140 
00141       /**
00142        * Number of splits that are used in the cross validator.
00143        * When an other cost function is chosen this parameter is not used.
00144        */
00145       int nbOfSplits;
00146 
00147     };
00148 
00149     /**
00150      * default constructor
00151      */
00152     featureSelector();
00153 
00154     /**
00155      * copy constructor
00156      * @param other the object to be copied
00157      */
00158     featureSelector(const featureSelector& other);
00159 
00160     /**
00161      * destructor
00162      */
00163     virtual ~featureSelector();
00164 
00165     /**
00166      * returns the name of this type ("featureSelector")
00167      */
00168     virtual const char* getTypeName() const;
00169   
00170     /**
00171      * Extracts the best features of src copies them to dest.
00172      * @param src dmatrix with the source data.
00173      * @param srcIds ivector with the ids corresponding to src
00174      * @param dest dmatrix where the result will be left.
00175      * @return true if apply successful or false otherwise.
00176      */
00177     virtual bool apply(const dmatrix& src,const ivector& srcIds, dmatrix& dest) const=0;
00178 
00179     /**
00180      * Extracts the best features of src copies them to dest.
00181      * @param src dmatrix with the source data.
00182      * @param srcIds ivector with the ids corresponding to src
00183      * @return the data set, that contains only the extracted features
00184      */
00185     virtual dmatrix apply(const dmatrix& src,const ivector& srcIds) const;
00186       
00187     /**
00188      * copy data of "other" functor.
00189      * @param other the functor to be copied
00190      * @return a reference to this functor object
00191      */
00192     featureSelector& copy(const featureSelector& other);
00193 
00194     /**
00195      * alias for copy member
00196      * @param other the functor to be copied
00197      * @return a reference to this functor object
00198      */
00199     featureSelector& operator=(const featureSelector& other);
00200 
00201     /**
00202      * returns a pointer to a clone of this functor.
00203      */
00204     virtual functor* clone() const=0;
00205 
00206     /**
00207      * returns used parameters
00208      */
00209     const parameters& getParameters() const;
00210 
00211   };
00212 }
00213 
00214 #endif

Generated on Sat Apr 10 15:25:29 2010 for LTI-Lib by Doxygen 1.6.1