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 .......: ltiMahalanobisDistance.h 00027 * authors ....: Jens Paustenbach 00028 * organization: LTI, RWTH Aachen 00029 * creation ...: 13.8.2002 00030 * revisions ..: $Id: ltiMahalanobisDistance.h,v 1.5 2006/02/08 12:32:41 ltilib Exp $ 00031 */ 00032 00033 #ifndef _LTI_MAHALANOBIS_DISTANCE_H_ 00034 #define _LTI_MAHALANOBIS_DISTANCE_H_ 00035 00036 #include "ltiVector.h" 00037 #include "ltiMatrix.h" 00038 #include "ltiVarianceFunctor.h" 00039 #include "ltiLinearAlgebraFunctor.h" 00040 00041 namespace lti { 00042 /** 00043 * This class computes the mahalanobis distance. 00044 * The distance can either be computed as distance between a point and 00045 * a matrix with a distribution or direct from two points and a given 00046 * covariance matrix, where one point is expected to be the mean of the 00047 * distribution.<p> 00048 * The mahalanobis distance is defined as follows: 00049 * \f[ d=\sqrt{(z_1-z_2)^T\Sigma^{-1}(z_1-z_2)} \f] 00050 * where \f$ \Sigma \f$ is the covariance matrix of the distribution. 00051 */ 00052 class mahalanobisDistance : public linearAlgebraFunctor { 00053 public: 00054 /** 00055 * default constructor 00056 */ 00057 mahalanobisDistance(); 00058 00059 /** 00060 * copy constructor 00061 * @param other the object to be copied 00062 */ 00063 mahalanobisDistance(const mahalanobisDistance& other); 00064 00065 /** 00066 * destructor 00067 */ 00068 virtual ~mahalanobisDistance(); 00069 00070 /** 00071 * returns the name of this type ("mahalanobisDistance") 00072 */ 00073 virtual const char* getTypeName() const; 00074 00075 /** 00076 * computes the mahalanobis distance between the point p1 and 00077 * the given distribution 00078 * @param p1 the point whose distance to the distribution is computed. 00079 * @param p2 the mean of the distribution . 00080 * @param coV the covarianz matrix of the distribution . 00081 * @param distance the mahalanobis distance. 00082 * @return true if apply successful or false otherwise. 00083 */ 00084 bool apply(const dvector& p1,const dvector& p2, const dmatrix& coV, 00085 double& distance) const; 00086 00087 /** 00088 * computes the mahalanobis distance between the point p1 and 00089 * the given distribution 00090 * @param p1 the point whose distance to the distribution is computed. 00091 * @param p2 the mean of the distribution . 00092 * @param coV the covarianz matrix of the distribution . 00093 * @return the mahalanobis distance. 00094 */ 00095 double apply(const dvector& p1,const dvector& p2, 00096 const dmatrix& coV) const; 00097 00098 /** 00099 * computes the mahalanobis distance between the point p1 and 00100 * the given distribution 00101 * @param p1 the point whose distance to the distribution is computed. 00102 * @param cluster the distribution. 00103 * @param distance the mahalanobis distance. 00104 * @return true if apply successful or false otherwise. 00105 */ 00106 bool apply(const dvector& p1,const dmatrix& cluster, 00107 double& distance) const; 00108 00109 /** 00110 * computes the mahalanobis distance between the point p1 and 00111 * the given distribution 00112 * @param p1 the point whose distance to the distribution is computed. 00113 * @param cluster the mean of the distribution . 00114 * @return the mahalanobis distance. 00115 */ 00116 double apply(const dvector& p1,const dmatrix& cluster) const; 00117 00118 /** 00119 * copy data of "other" functor. 00120 * @param other the functor to be copied 00121 * @return a reference to this functor object 00122 */ 00123 mahalanobisDistance& copy(const mahalanobisDistance& other); 00124 00125 /** 00126 * alias for copy member 00127 * @param other the functor to be copied 00128 * @return a reference to this functor object 00129 */ 00130 mahalanobisDistance& operator=(const mahalanobisDistance& other); 00131 00132 /** 00133 * returns a pointer to a clone of this functor. 00134 */ 00135 virtual functor* clone() const; 00136 00137 /** 00138 * returns used parameters 00139 */ 00140 const parameters& getParameters() const; 00141 00142 }; 00143 } 00144 00145 #endif