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

itkMahalanobisDistanceMembershipFunction.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkMahalanobisDistanceMembershipFunction.h,v $
00005   Language:  C++
00006   Date:      $Date: 2002/09/11 19:57:14 $
00007   Version:   $Revision: 1.2 $
00008 
00009   Copyright (c) 2002 Insight 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 __itkMahalanobisDistanceMembershipFunction_h
00018 #define __itkMahalanobisDistanceMembershipFunction_h
00019 
00020 #include <vnl/vnl_vector.h>
00021 #include <vnl/vnl_transpose.h>
00022 #include <vnl/vnl_matrix.h>
00023 #include <vnl/algo/vnl_matrix_inverse.h>
00024 #include <vnl/algo/vnl_determinant.h>
00025 
00026 
00027 #include "itkMembershipFunctionBase.h"
00028 
00029 #define PI 3.141592
00030 
00031 namespace itk{ 
00032   namespace Statistics{
00033 
00043 template< class TVector >
00044 class ITK_EXPORT MahalanobisDistanceMembershipFunction :
00045       public MembershipFunctionBase< TVector >
00046 {
00047 public:
00049   typedef MahalanobisDistanceMembershipFunction Self;
00050   typedef MembershipFunctionBase< TVector > Superclass ;
00051   typedef SmartPointer<Self> Pointer;
00052 
00054   itkTypeMacro(MahalanobisDistanceMembershipFunction, MembershipFunctionBase);
00055   itkNewMacro(Self);
00056   
00058   typedef TVector MeasurementVectorType ;
00059 
00061   void SetMean(const vnl_vector<double> &mean) ;
00062   
00064   const vnl_vector<double> & GetMean() const;
00065 
00070   void SetCovariance(const vnl_matrix<double> &cov); 
00071   
00073   const vnl_matrix<double> & GetCovariance() const;
00074 
00079   void SetInverseCovariance(const vnl_matrix<double> &invcov); 
00080   
00082   const vnl_matrix<double> & GetInverseCovariance() const;
00083 
00085   itkSetMacro( NumberOfSamples, double );
00086 
00088   itkGetMacro( NumberOfSamples, double );
00089 
00093   double Evaluate(const MeasurementVectorType &measurement) const;
00094   
00095 protected:
00096   MahalanobisDistanceMembershipFunction(void) ;
00097   virtual ~MahalanobisDistanceMembershipFunction(void) {}
00098   void PrintSelf(std::ostream& os, Indent indent) const;
00099 
00100 private:
00101   vnl_vector< double >  m_Mean;              // mean
00102   vnl_matrix< double >  m_Covariance;         // covariance matrix
00103 
00104   // inverse covariance matrix which is automatically calculated 
00105   // when covariace matirx is set.  This speed up the GetProbability()
00106   vnl_matrix< double >  m_InverseCovariance; 
00107 
00108   // Number of samples defining this density
00109   double m_NumberOfSamples;
00110   // pre_factor which is automatically calculated 
00111   // when covariace matirx is set.  This speeds up the GetProbability()  
00112   double       m_PreFactor;
00113   double       m_Epsilon;
00114   double       m_DoubleMax;
00115  
00116   bool         m_ValidInverseCovarianceFlag;
00117 
00118   itkStaticConstMacro(VectorDimension, unsigned int, TVector::VectorDimension);
00119   typedef vnl_matrix_fixed<double,1,itkGetStaticConstMacro(VectorDimension)> ColumnVectorType;
00120 
00121   mutable ColumnVectorType      m_TempVec;
00122   mutable ColumnVectorType      m_TempMat;
00123 
00124   void CalculateInverseCovariance(); 
00125 };
00126 
00127   } // end of namespace Statistics
00128 } // end namespace itk
00129 
00130 #ifndef ITK_MANUAL_INSTANTIATION
00131 #include "itkMahalanobisDistanceMembershipFunction.txx"
00132 #endif
00133 
00134 #endif

Generated at Wed Mar 12 01:13:05 2003 for ITK by doxygen 1.2.15 written by Dimitri van Heesch, © 1997-2000