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: 2005/11/21 02:40:48 $
00007   Version:   $Revision: 1.13 $
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);
00057   
00059   typedef TVector MeasurementVectorType ;
00060 
00062   typedef typename Superclass::MeasurementVectorSizeType MeasurementVectorSizeType;
00063 
00065   typedef vnl_vector<double>  MeanVectorType;
00066 
00068   typedef vnl_matrix<double>  CovarianceMatrixType;
00069 
00071   virtual void SetMeasurementVectorSize( const MeasurementVectorSizeType );
00072   
00074   void SetMean(const MeanVectorType &mean) ;
00075   void SetMean(const Array< double > &mean) ;
00076   
00078   const MeanVectorType & GetMean() const;
00079 
00084   void SetCovariance(const CovarianceMatrixType &cov); 
00085   
00087   itkGetConstReferenceMacro( Covariance, CovarianceMatrixType );
00088 
00093   void SetInverseCovariance(const CovarianceMatrixType &invcov); 
00094   
00096   itkGetConstReferenceMacro( InverseCovariance, CovarianceMatrixType );
00097 
00099   itkSetMacro( NumberOfSamples, double );
00100 
00102   itkGetMacro( NumberOfSamples, double );
00103 
00107   double Evaluate(const MeasurementVectorType &measurement) const;
00108   
00109 protected:
00110   MahalanobisDistanceMembershipFunction(void) ;
00111   virtual ~MahalanobisDistanceMembershipFunction(void) {}
00112   void PrintSelf(std::ostream& os, Indent indent) const;
00113 
00114 private:
00115   MeanVectorType        m_Mean;              // mean
00116   CovarianceMatrixType  m_Covariance;        // covariance matrix
00117 
00118   // inverse covariance matrix which is automatically calculated 
00119   // when covariace matirx is set.  This speed up the GetProbability()
00120   CovarianceMatrixType  m_InverseCovariance; 
00121 
00122   // Number of samples defining this density
00123   double m_NumberOfSamples;
00124   // pre_factor which is automatically calculated 
00125   // when covariace matirx is set.  This speeds up the GetProbability()  
00126   double       m_PreFactor;
00127   double       m_Epsilon;
00128   double       m_DoubleMax;
00129  
00130   mutable vnl_matrix< double > m_TempVec;
00131   mutable vnl_matrix< double > m_TempMat;
00132 
00133   void CalculateInverseCovariance(); 
00134 };
00135 
00136 } // end of namespace Statistics
00137 } // end namespace itk
00138 
00139 #ifndef ITK_MANUAL_INSTANTIATION
00140 #include "itkMahalanobisDistanceMembershipFunction.txx"
00141 #endif
00142 
00143 #endif

Generated at Wed May 24 23:37:03 2006 for ITK by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2000