Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkMahalanobisDistanceMetric.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkMahalanobisDistanceMetric.h,v $
00005   Language:  C++
00006   Date:      $Date: 2009-05-02 05:43:56 $
00007   Version:   $Revision: 1.1 $
00008 
00009   Copyright (c) Insight Software Consortium. All rights reserved.
00010   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
00011 
00012      This software is distributed WITHOUT ANY WARRANTY; without even
00013      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00014      PURPOSE.  See the above copyright notices for more information.
00015 
00016 =========================================================================*/
00017 #ifndef __itkMahalanobisDistanceMetric_h
00018 #define __itkMahalanobisDistanceMetric_h
00019 
00020 #include <vnl/vnl_vector.h>
00021 #include <vnl/vnl_vector_ref.h>
00022 #include <vnl/vnl_transpose.h>
00023 #include <vnl/vnl_matrix.h>
00024 #include <vnl/algo/vnl_matrix_inverse.h>
00025 #include <vnl/algo/vnl_determinant.h>
00026 #include "itkArray.h"
00027 
00028 #include "itkDistanceMetric.h"
00029 
00030 
00031 namespace itk {
00032 namespace Statistics{
00033 
00043 template< class TVector >
00044 class ITK_EXPORT MahalanobisDistanceMetric :
00045     public DistanceMetric< TVector >
00046 {
00047 public:
00049   typedef MahalanobisDistanceMetric                 Self;
00050   typedef DistanceMetric< TVector >                 Superclass;
00051   typedef SmartPointer<Self>                        Pointer;
00052   typedef SmartPointer<const Self>                  ConstPointer;
00053 
00055   itkTypeMacro(MahalanobisDistanceMetric, DistanceMetric);
00056   itkNewMacro(Self);
00058 
00059 
00061   typedef typename Superclass::MeasurementVectorType  MeasurementVectorType;
00062 
00064   typedef typename Superclass::MeasurementVectorSizeType MeasurementVectorSizeType;
00065 
00066 
00068   typedef typename Superclass::OriginType MeanVectorType;
00069 
00071   typedef vnl_matrix<double>  CovarianceMatrixType;
00072 
00074   virtual void SetMeasurementVectorSize( MeasurementVectorSizeType );
00075 
00077   void SetMean(const MeanVectorType &mean);
00078 
00080   const MeanVectorType & GetMean() const;
00081 
00086   void SetCovariance(const CovarianceMatrixType &cov);
00087 
00089   itkGetConstReferenceMacro( Covariance, CovarianceMatrixType );
00090 
00093   void SetInverseCovariance(const CovarianceMatrixType &invcov);
00094 
00096   itkGetConstReferenceMacro( InverseCovariance, CovarianceMatrixType );
00097 
00101   double Evaluate(const MeasurementVectorType &measurement) const;
00102 
00104   double Evaluate(const MeasurementVectorType &x1, const MeasurementVectorType &x2) const; 
00105 
00107   itkSetMacro( Epsilon, double );
00108   itkGetConstMacro( Epsilon, double );
00110 
00111   itkSetMacro( DoubleMax, double );
00112   itkGetConstMacro( DoubleMax, double );
00113 
00114 protected:
00115   MahalanobisDistanceMetric(void);
00116   virtual ~MahalanobisDistanceMetric(void) {}
00117   void PrintSelf(std::ostream& os, Indent indent) const;
00118 
00119 private:
00120   MeanVectorType        m_Mean;              // mean
00121   CovarianceMatrixType  m_Covariance;        // covariance matrix
00122 
00123   // inverse covariance matrix which is automatically calculated
00124   // when covariace matirx is set.  This speed up the GetProbability()
00125   CovarianceMatrixType  m_InverseCovariance;
00126 
00127   double       m_Epsilon;
00128   double       m_DoubleMax;
00129  
00130   void CalculateInverseCovariance();
00131 
00132 };
00133 
00134 } // end of namespace Statistics
00135 } // end namespace itk
00136 
00137 #ifndef ITK_MANUAL_INSTANTIATION
00138 #include "itkMahalanobisDistanceMetric.txx"
00139 #endif
00140 
00141 #endif
00142 

Generated at Mon Jul 12 2010 19:05:03 for ITK by doxygen 1.7.1 written by Dimitri van Heesch, © 1997-2000