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

Numerics/Statistics/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: 2009-03-04 15:23:56 $
00007   Version:   $Revision: 1.14 $
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 __itkMahalanobisDistanceMembershipFunction_h
00018 #define __itkMahalanobisDistanceMembershipFunction_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 "itkMembershipFunctionBase.h"
00029 
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   typedef SmartPointer<const Self>              ConstPointer;
00053 
00055   itkTypeMacro(MahalanobisDistanceMembershipFunction, MembershipFunctionBase);
00056   itkNewMacro(Self);
00058 
00060   typedef TVector MeasurementVectorType;
00061 
00063   typedef typename Superclass::MeasurementVectorSizeType MeasurementVectorSizeType;
00064 
00066   typedef vnl_vector<double>  MeanVectorType;
00067 
00069   typedef vnl_matrix<double>  CovarianceMatrixType;
00070 
00072   virtual void SetMeasurementVectorSize( const MeasurementVectorSizeType );
00073 
00075   void SetMean(const MeanVectorType &mean);
00076   void SetMean(const Array< double > &mean);
00078 
00080   const MeanVectorType & GetMean() const;
00081 
00086   void SetCovariance(const CovarianceMatrixType &cov); 
00087 
00089   itkGetConstReferenceMacro( Covariance, CovarianceMatrixType );
00090 
00095   void SetInverseCovariance(const CovarianceMatrixType &invcov); 
00096 
00098   itkGetConstReferenceMacro( InverseCovariance, CovarianceMatrixType );
00099 
00101   itkSetMacro( NumberOfSamples, double );
00102 
00104   itkGetMacro( NumberOfSamples, double );
00105 
00109   double Evaluate(const MeasurementVectorType &measurement) const;
00110 
00111 protected:
00112   MahalanobisDistanceMembershipFunction(void);
00113   virtual ~MahalanobisDistanceMembershipFunction(void) {}
00114   void PrintSelf(std::ostream& os, Indent indent) const;
00115 
00116 private:
00117   MeanVectorType        m_Mean;              // mean
00118   CovarianceMatrixType  m_Covariance;        // covariance matrix
00119 
00120   // inverse covariance matrix which is automatically calculated 
00121   // when covariace matirx is set.  This speed up the GetProbability()
00122   CovarianceMatrixType  m_InverseCovariance; 
00123 
00124   // Number of samples defining this density
00125   double m_NumberOfSamples;
00126   // pre_factor which is automatically calculated 
00127   // when covariace matirx is set.  This speeds up the GetProbability()  
00128   double       m_PreFactor;
00129   double       m_Epsilon;
00130   double       m_DoubleMax;
00131  
00132   mutable vnl_matrix< double > m_TempVec;
00133   mutable vnl_matrix< double > m_TempMat;
00134 
00135   void CalculateInverseCovariance(); 
00136 };
00137 
00138 } // end of namespace Statistics
00139 } // end namespace itk
00140 
00141 #ifndef ITK_MANUAL_INSTANTIATION
00142 #include "itkMahalanobisDistanceMembershipFunction.txx"
00143 #endif
00144 
00145 #endif
00146 

Generated at Tue Sep 15 03:53:02 2009 for ITK by doxygen 1.5.8 written by Dimitri van Heesch, © 1997-2000