00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkGaussianMembershipFunction.h,v $ 00005 Language: C++ 00006 Date: $Date: 2009-05-02 05:43:55 $ 00007 Version: $Revision: 1.1 $ 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 __itkGaussianMembershipFunction_h 00018 #define __itkGaussianMembershipFunction_h 00019 00020 #include "itkArray.h" 00021 #include "itkMatrix.h" 00022 #include "itkMembershipFunctionBase.h" 00023 00024 namespace itk { 00025 namespace Statistics { 00026 00040 template< class TMeasurementVector > 00041 class ITK_EXPORT GaussianMembershipFunction : 00042 public MembershipFunctionBase< TMeasurementVector > 00043 { 00044 public: 00046 typedef GaussianMembershipFunction Self; 00047 typedef MembershipFunctionBase< TMeasurementVector > Superclass; 00048 typedef SmartPointer<Self> Pointer; 00049 typedef SmartPointer<const Self> ConstPointer; 00050 00052 itkTypeMacro(GaussianMembershipFunction, MembershipFunction); 00053 itkNewMacro(Self); 00055 00057 typedef TMeasurementVector MeasurementVectorType; 00058 00060 typedef typename Superclass::MeasurementVectorSizeType MeasurementVectorSizeType; 00061 00063 typedef Array< double > MeanType; 00064 00066 typedef VariableSizeMatrix< double > CovarianceType; 00067 00069 void SetMean( const MeanType & mean ); 00070 itkGetConstMacro( Mean, MeanType ); 00072 00076 void SetCovariance(const CovarianceType & cov); 00077 itkGetConstMacro( Covariance, CovarianceType ); 00079 00081 double Evaluate(const MeasurementVectorType &measurement) const; 00082 00084 Pointer Clone(); 00085 00086 protected: 00087 GaussianMembershipFunction(void); 00088 virtual ~GaussianMembershipFunction(void) {} 00089 void PrintSelf(std::ostream& os, Indent indent) const; 00090 00091 private: 00092 MeanType m_Mean; // mean 00093 CovarianceType m_Covariance; // covariance matrix 00094 00095 // inverse covariance matrix which is automatically calculated 00096 // when covariace matirx is set. This speed up the GetProbability() 00097 CovarianceType m_InverseCovariance; 00098 00099 // pre_factor which is automatically calculated 00100 // when covariace matirx is set. This speeds up the GetProbability() 00101 double m_PreFactor; 00102 00105 bool m_IsCovarianceZero; 00106 }; 00107 00108 } // end of namespace Statistics 00109 } // end namespace itk 00110 00111 #ifndef ITK_MANUAL_INSTANTIATION 00112 #include "itkGaussianMembershipFunction.txx" 00113 #endif 00114 00115 #endif 00116