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 .......: ltiCostFunction.h 00027 * authors ....: Jens Paustenbach 00028 * organization: LTI, RWTH Aachen 00029 * creation ...: 4.9.2002 00030 * revisions ..: $Id: ltiCostFunction.h,v 1.3 2006/02/07 18:15:35 ltilib Exp $ 00031 */ 00032 00033 #ifndef _LTI_COST_FUNCTION_H_ 00034 #define _LTI_COST_FUNCTION_H_ 00035 00036 #include "ltiFunctor.h" 00037 #include "ltiMatrix.h" 00038 #include "ltiVector.h" 00039 #include <list> 00040 00041 using std::list; 00042 00043 namespace lti { 00044 /** 00045 * Base class for all cost functions. 00046 * The cost functions are used to evaluate feature subsets of data sets. 00047 * These cost functions are used by the feature selectors. 00048 */ 00049 class costFunction : public functor { 00050 public: 00051 00052 /** 00053 * default constructor 00054 */ 00055 costFunction(); 00056 00057 /** 00058 * copy constructor 00059 * @param other the object to be copied 00060 */ 00061 costFunction(const costFunction& other); 00062 00063 /** 00064 * destructor 00065 */ 00066 virtual ~costFunction(); 00067 00068 /** 00069 * returns the name of this type ("costFunction") 00070 */ 00071 virtual const char* getTypeName() const; 00072 00073 /** 00074 * copy data of "other" functor. 00075 * @param other the functor to be copied 00076 * @return a reference to this functor object 00077 */ 00078 costFunction& copy(const costFunction& other); 00079 00080 /** 00081 * alias for copy member 00082 * @param other the functor to be copied 00083 * @return a reference to this functor object 00084 */ 00085 costFunction& operator=(const costFunction& other); 00086 00087 /** 00088 * Set the src data points and ids used for computation of 00089 * the cost function. 00090 */ 00091 virtual void setSrc(const dmatrix& src, const ivector& srcIds); 00092 00093 /** 00094 * computes the cost function with the given subset of features 00095 * @param in ivector with the features that should be included. 00096 * @param dist the result of the cost function. 00097 * @return true if apply successful or false otherwise. 00098 */ 00099 virtual bool apply(const ivector& in,double& dist); 00100 00101 /** 00102 * computes the cost function with the given subset of features 00103 * @param in ivector with the features that should be included 00104 * for computing the function 00105 * @return the result of the cost function 00106 */ 00107 virtual double apply(const ivector& in); 00108 00109 /** 00110 * computes the cost function with the given subset of features 00111 * @param in std::list with the features that should be inclueded 00112 * for computing the function 00113 * @return the result of the cost function 00114 */ 00115 virtual double apply(const std::list<int>& in); 00116 00117 /** 00118 * computes the cost function with the given subset of features 00119 * @param in std::list with the features that should be inclueded 00120 * for computing the function 00121 * @param value the result of the cost function 00122 * @return true if apply successful or false otherwise. 00123 */ 00124 virtual bool apply(const std::list<int>& in,double& value)=0; 00125 00126 00127 protected: 00128 /** 00129 * the source data points 00130 */ 00131 dmatrix pSrc; 00132 00133 /** 00134 * the src ids corresponding to the data points 00135 */ 00136 ivector pSrcIds; 00137 }; 00138 } 00139 00140 #endif