00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
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
00030
namespace itk{
00031
namespace Statistics{
00032
00042
template<
class TVector >
00043 class ITK_EXPORT MahalanobisDistanceMembershipFunction :
00044
public MembershipFunctionBase< TVector >
00045 {
00046
public:
00048 typedef MahalanobisDistanceMembershipFunction
Self;
00049 typedef MembershipFunctionBase< TVector > Superclass ;
00050 typedef SmartPointer<Self> Pointer;
00051 typedef SmartPointer<const Self> ConstPointer;
00052
00054
itkTypeMacro(MahalanobisDistanceMembershipFunction,
MembershipFunctionBase);
00055
itkNewMacro(
Self);
00056
00058
typedef TVector
MeasurementVectorType ;
00059
00061
typedef vnl_vector<double> MeanVectorType;
00062
00064
typedef vnl_matrix<double> CovarianceMatrixType;
00065
00067
void SetMean(
const MeanVectorType &mean) ;
00068
00070
const MeanVectorType & GetMean() const;
00071
00076
void SetCovariance(const
CovarianceMatrixType &cov);
00077
00079 itkGetConstReferenceMacro( Covariance,
CovarianceMatrixType );
00080
00085
void SetInverseCovariance(const CovarianceMatrixType &invcov);
00086
00088 itkGetConstReferenceMacro( InverseCovariance, CovarianceMatrixType );
00089
00091 itkSetMacro( NumberOfSamples,
double );
00092
00094 itkGetMacro( NumberOfSamples,
double );
00095
00099
double Evaluate(const
MeasurementVectorType &measurement) const;
00100
00101 protected:
00102 MahalanobisDistanceMembershipFunction(
void) ;
00103 virtual ~MahalanobisDistanceMembershipFunction(
void) {}
00104 void PrintSelf(std::ostream& os,
Indent indent)
const;
00105
00106
private:
00107
MeanVectorType m_Mean;
00108
CovarianceMatrixType m_Covariance;
00109
00110
00111
00112
CovarianceMatrixType m_InverseCovariance;
00113
00114
00115
double m_NumberOfSamples;
00116
00117
00118
double m_PreFactor;
00119
double m_Epsilon;
00120
double m_DoubleMax;
00121
00122
itkStaticConstMacro(VectorDimension,
unsigned int, TVector::Dimension);
00123
typedef vnl_matrix_fixed<double,1,itkGetStaticConstMacro(VectorDimension)> ColumnVectorType;
00124
00125
mutable ColumnVectorType m_TempVec;
00126
mutable ColumnVectorType m_TempMat;
00127
00128
void CalculateInverseCovariance();
00129 };
00130
00131 }
00132 }
00133
00134
#ifndef ITK_MANUAL_INSTANTIATION
00135
#include "itkMahalanobisDistanceMembershipFunction.txx"
00136
#endif
00137
00138
#endif