00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkGaussianDensityFunction_h
00018 #define __itkGaussianDensityFunction_h
00019
00020 #include "vnl/vnl_vector.h"
00021 #include "vnl/vnl_matrix.h"
00022 #include "vnl/algo/vnl_matrix_inverse.h"
00023 #include "vnl/algo/vnl_determinant.h"
00024 #include "vnl/vnl_math.h"
00025
00026 #include "itkMatrix.h"
00027 #include "itkDensityFunction.h"
00028
00029 namespace itk{
00030 namespace Statistics{
00031
00045 template< class TMeasurementVector >
00046 class ITK_EXPORT GaussianDensityFunction :
00047 public DensityFunction< TMeasurementVector >
00048 {
00049 public:
00051 typedef GaussianDensityFunction Self;
00052 typedef DensityFunction< TMeasurementVector > Superclass ;
00053 typedef SmartPointer<Self> Pointer;
00054 typedef SmartPointer<const Self> ConstPointer;
00055
00057 itkTypeMacro(GaussianDensityFunction, DensityFunction);
00058 itkNewMacro(Self);
00059
00061 typedef TMeasurementVector MeasurementVectorType ;
00062
00064 itkStaticConstMacro(VectorDimension, unsigned int,
00065 TMeasurementVector::Length);
00066
00068 typedef Vector< double, itkGetStaticConstMacro(VectorDimension) > MeanType ;
00069
00071 typedef Matrix< double, itkGetStaticConstMacro(VectorDimension),
00072 itkGetStaticConstMacro(VectorDimension) > CovarianceType ;
00073
00075 void SetMean( const MeanType * mean )
00076 {
00077 if ( m_Mean != mean)
00078 {
00079 m_Mean = mean ;
00080 this->Modified() ;
00081 }
00082 }
00083
00085 const MeanType * GetMean() const
00086 { return m_Mean ; }
00087
00091 void SetCovariance(const CovarianceType* cov);
00092
00094 const CovarianceType* GetCovariance() const ;
00095
00097 double Evaluate(const MeasurementVectorType &measurement) const ;
00098
00099 protected:
00100 GaussianDensityFunction(void) ;
00101 virtual ~GaussianDensityFunction(void) {}
00102 void PrintSelf(std::ostream& os, Indent indent) const;
00103
00104 private:
00105 const MeanType * m_Mean;
00106 const CovarianceType * m_Covariance;
00107
00108
00109
00110 CovarianceType m_InverseCovariance;
00111
00112
00113
00114 double m_PreFactor;
00115
00118 bool m_IsCovarianceZero ;
00119 };
00120
00121 }
00122 }
00123
00124 #ifndef ITK_MANUAL_INSTANTIATION
00125 #include "itkGaussianDensityFunction.txx"
00126 #endif
00127
00128 #endif