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 .......: ltiBhattacharyyaDistOfSubset.h 00027 * authors ....: Jens Paustenbach 00028 * organization: LTI, RWTH Aachen 00029 * creation ...: 22.10.2002 00030 * revisions ..: $Id: ltiBhattacharyyaDistOfSubset.h,v 1.3 2006/02/07 18:12:11 ltilib Exp $ 00031 */ 00032 00033 #ifndef _LTI_BHATTACHARYYA_DIST_OF_SUBSET_H_ 00034 #define _LTI_BHATTACHARYYA_DIST_OF_SUBSET_H_ 00035 00036 #include "ltiCostFunction.h" 00037 #include <map> 00038 #include <list> 00039 00040 namespace lti { 00041 /** 00042 * The class implements the bhattacharyya distance as cost function. The 00043 * cost function evaluates a subset of features from a dataset. 00044 * First you have to initialize this class with the hole data set 00045 * and the ids to which cluster each data point belongs. To do 00046 * this you have to call the setSrc method. This must be done before 00047 * you can compute the cost function. 00048 * Then you can choose a subset of features. The cost function then will be 00049 * the average bhattacharyya distance of all clusters. 00050 */ 00051 class bhattacharyyaDistOfSubset : public costFunction { 00052 public: 00053 /** 00054 * default constructor 00055 */ 00056 bhattacharyyaDistOfSubset(); 00057 00058 /** 00059 * copy constructor 00060 * @param other the object to be copied 00061 */ 00062 bhattacharyyaDistOfSubset(const bhattacharyyaDistOfSubset& other); 00063 00064 /** 00065 * destructor 00066 */ 00067 virtual ~bhattacharyyaDistOfSubset(); 00068 00069 /** 00070 * returns the name of this type ("bhattacharyyaDistOfSubset") 00071 */ 00072 virtual const char* getTypeName() const; 00073 00074 /** 00075 * Set the src data, that is used for the cost function. 00076 * This must be done before you call one of the apply methods. 00077 * Later each feature can be adressed by its column number in this src 00078 * matrix. 00079 */ 00080 virtual void setSrc(const dmatrix& src, const ivector& srcIds); 00081 00082 /** 00083 * computes the bhattacharyya distance with the given subset of features 00084 * @param in std::list with the features that should be included 00085 * for computing the function 00086 * @param dist the result of the cost function. 00087 * @return true if apply successful or false otherwise. 00088 */ 00089 virtual bool apply(const std::list<int>& in,double& dist); 00090 00091 /** 00092 * copy data of "other" functor. 00093 * @param other the functor to be copied 00094 * @return a reference to this functor object 00095 */ 00096 bhattacharyyaDistOfSubset& copy(const bhattacharyyaDistOfSubset& other); 00097 00098 /** 00099 * alias for copy member 00100 * @param other the functor to be copied 00101 * @return a reference to this functor object 00102 */ 00103 bhattacharyyaDistOfSubset& operator=(const bhattacharyyaDistOfSubset& other); 00104 00105 /** 00106 * returns a pointer to a clone of this functor. 00107 */ 00108 virtual functor* clone() const; 00109 00110 protected: 00111 /** 00112 * Each element of the list contains all data points belonging to one 00113 * cluster. 00114 */ 00115 std::list<dmatrix> clusters; 00116 }; 00117 } 00118 00119 #endif