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 .......: ltiMahalanobisDistOfSubset.h 00027 * authors ....: Jens Paustenbach 00028 * organization: LTI, RWTH Aachen 00029 * creation ...: 22.10.2002 00030 * revisions ..: $Id: ltiMahalanobisDistOfSubset.h,v 1.4 2006/02/07 18:21:03 ltilib Exp $ 00031 */ 00032 00033 #ifndef _LTI_MAHALANOBIS_DIST_OF_SUBSET_H_ 00034 #define _LTI_MAHALANOBIS_DIST_OF_SUBSET_H_ 00035 00036 #include "ltiCostFunction.h" 00037 #include <list> 00038 #include <map> 00039 00040 namespace lti { 00041 /** 00042 * This class implements a cost function for evaluating a subset of features 00043 * based on the mahalanobis distance. 00044 * A great value of this cost function shows well seperated clusters. First, 00045 * for all points in the data set the mahalanobis distance to each 00046 * cluster in distribution is computed. Then the result of this 00047 * costFunction is the average of all these distances. 00048 * Before you can compute the cost function use the setSrc method to 00049 * pass the complete data set with all features to this class. Later 00050 * the features are accessed only by their column number. 00051 */ 00052 class mahalanobisDistOfSubset : public costFunction { 00053 public: 00054 00055 /** 00056 * default constructor 00057 */ 00058 mahalanobisDistOfSubset(); 00059 00060 /** 00061 * copy constructor 00062 * @param other the object to be copied 00063 */ 00064 mahalanobisDistOfSubset(const mahalanobisDistOfSubset& other); 00065 00066 /** 00067 * destructor 00068 */ 00069 virtual ~mahalanobisDistOfSubset(); 00070 00071 /** 00072 * returns the name of this type ("mahalanobisDistOfSubset") 00073 */ 00074 virtual const char* getTypeName() const; 00075 00076 /** 00077 * Set the src data, that is used for computation. This must be done 00078 * before apply methods are called. Later each feature can be adressed 00079 * by its column number, because usually a column represents a feature. 00080 */ 00081 virtual void setSrc(const dmatrix& src, const ivector& srcIds); 00082 00083 /** 00084 * computes the mahalanobis distance with the given subset of features 00085 * @param value the result of the cost function. 00086 * @param in std::list with the features that should be inclueded 00087 * for computing the function 00088 * @return true if apply successful or false otherwise. 00089 */ 00090 virtual bool apply(const std::list<int>& in,double& value); 00091 00092 /** 00093 * copy data of "other" functor. 00094 * @param other the functor to be copied 00095 * @return a reference to this functor object 00096 */ 00097 mahalanobisDistOfSubset& copy(const mahalanobisDistOfSubset& other); 00098 00099 /** 00100 * alias for copy member 00101 * @param other the functor to be copied 00102 * @return a reference to this functor object 00103 */ 00104 mahalanobisDistOfSubset& operator=(const mahalanobisDistOfSubset& other); 00105 00106 /** 00107 * returns a pointer to a clone of this functor. 00108 */ 00109 virtual functor* clone() const; 00110 00111 /** 00112 * returns used parameters 00113 */ 00114 const parameters& getParameters() const; 00115 00116 protected: 00117 00118 /** 00119 * A list with each element containing a matrix with one cluster. 00120 * This list is build from the contructor. 00121 */ 00122 list<dmatrix> clusters; 00123 00124 00125 }; 00126 } 00127 00128 #endif