00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkDistanceToCentroidMembershipFunction.h,v $ 00005 Language: C++ 00006 Date: $Date: 2002/11/13 00:52:54 $ 00007 Version: $Revision: 1.3 $ 00008 00009 Copyright (c) 2002 Insight 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 __itkDistanceToCentroidMembershipFunction_h 00018 #define __itkDistanceToCentroidMembershipFunction_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 #define PI 3.141592 00030 00031 namespace itk{ 00032 namespace Statistics{ 00033 00043 template< class TVector > 00044 class ITK_EXPORT DistanceToCentroidMembershipFunction : 00045 public MembershipFunctionBase< TVector > 00046 { 00047 public: 00049 typedef DistanceToCentroidMembershipFunction Self; 00050 typedef MembershipFunctionBase< TVector > Superclass ; 00051 typedef SmartPointer<Self> Pointer; 00052 00054 itkTypeMacro(DistanceToCentroidMembershipFunction, MembershipFunctionBase); 00055 itkNewMacro(Self); 00056 00058 typedef TVector MeasurementVectorType ; 00059 00061 void SetCentroid(const vnl_vector<double> ¢roid) ; 00062 00064 const vnl_vector<double> & GetCentroid() const; 00065 00067 itkSetMacro( NumberOfSamples, int ); 00068 00070 itkGetMacro( NumberOfSamples, int ); 00071 00075 double Evaluate(const MeasurementVectorType &measurement) const; 00076 00077 protected: 00078 DistanceToCentroidMembershipFunction(void) ; 00079 virtual ~DistanceToCentroidMembershipFunction(void) {} 00080 void PrintSelf(std::ostream& os, Indent indent) const; 00081 00082 private: 00083 vnl_vector< double > m_Centroid; // mean 00084 00085 // Number of samples defining this density 00086 int m_NumberOfSamples; 00087 00088 itkStaticConstMacro(VectorDimension, unsigned int, TVector::Dimension); 00089 typedef vnl_matrix_fixed<double,1,itkGetStaticConstMacro(VectorDimension)> ColumnVectorType; 00090 00091 mutable ColumnVectorType m_TempVec; 00092 mutable ColumnVectorType m_TempMat; 00093 }; 00094 00095 } // end of namespace Statistics 00096 } // end namespace itk 00097 00098 #ifndef ITK_MANUAL_INSTANTIATION 00099 #include "itkDistanceToCentroidMembershipFunction.txx" 00100 #endif 00101 00102 #endif