#line 1 "/user/cvsspst/ees1cg/RAVL/RAVL-0.7/PatternRec/Distance/DistanceMahalanobis.hh" // This file is part of RAVL, Recognition And Vision Library // Copyright (C) 2001, University of Surrey // This code may be redistributed under the terms of the GNU Lesser // General Public License (LGPL). See the lgpl.licence file for details or // see http://www.gnu.org/copyleft/lesser.html // file-header-ends-here #ifndef RAVL_DISTANCEMAHALANOBIS_HEADER #define RAVL_DISTANCEMAHALANOBIS_HEADER 1 ////////////////////////////////////////////////////////////// //! rcsid="$Id: DistanceMahalanobis.hh,v 1.6 2002/06/19 19:18:53 craftit Exp $" //! lib=RavlPatternRec //! docentry="Ravl.Pattern Recognition.Distance" //! file="Ravl/PatternRec/Distance/DistanceMahalanobis.hh" #include "Ravl/PatternRec/Distance.hh" #include "Ravl/Matrix.hh" namespace RavlN { //! userlevel=Develop //: Mahalanobis Distance body. class DistanceMahalanobisBodyC : public DistanceBodyC { public: DistanceMahalanobisBodyC(const MatrixC &covVar); //: Constructor. DistanceMahalanobisBodyC(istream &strm); //: Load from stream. DistanceMahalanobisBodyC(BinIStreamC &strm); //: Load from binary stream. virtual bool Save (ostream &out) const; //: Writes object to stream, can be loaded using constructor virtual bool Save (BinOStreamC &out) const; //: Writes object to stream, can be loaded using constructor virtual RealT Measure(const VectorC &d1,const VectorC &d2) const; //: Measure the distance from d1 to d2. virtual RealT Magnitude(const VectorC &d1) const; //: Measure the magnitude of d1. virtual MatrixC Jacobian (const VectorC &X) const; //: Calculates Jacobian matrix at X protected: MatrixC iCovar; // Inverse covariance matrix. }; //! userlevel=Normal //: Mahalanobis distance metric class DistanceMahalanobisC : public DistanceC { public: DistanceMahalanobisC(const MatrixC &covVar) : DistanceC(*new DistanceMahalanobisBodyC(covVar)) {} //: Default constructor. DistanceMahalanobisC(istream &strm); //: Load from stream. DistanceMahalanobisC(BinIStreamC &strm); //: Load from binary stream. }; inline istream &operator>>(istream &strm,DistanceMahalanobisC &obj) { obj = DistanceMahalanobisC(strm); return strm; } //: Load from a stream. // Uses virtual constructor. inline ostream &operator<<(ostream &out,const DistanceMahalanobisC &obj) { obj.Save(out); return out; } //: Save to a stream. // Uses virtual constructor. inline BinIStreamC &operator>>(BinIStreamC &strm,DistanceMahalanobisC &obj) { obj = DistanceMahalanobisC(strm); return strm; } //: Load from a binary stream. // Uses virtual constructor. inline BinOStreamC &operator<<(BinOStreamC &out,const DistanceMahalanobisC &obj) { obj.Save(out); return out; } //: Save to a stream. // Uses virtual constructor. } #endif