00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkMixtureModelComponentBase.h,v $ 00005 Language: C++ 00006 Date: $Date: 2002/09/23 10:25:22 $ 00007 Version: $Revision: 1.5 $ 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 __itkMixtureModelComponentBase_h 00018 #define __itkMixtureModelComponentBase_h 00019 00020 #include <vnl/vnl_vector.h> 00021 #include <vnl/vnl_matrix.h> 00022 00023 #include "itkArray.h" 00024 #include "itkObject.h" 00025 #include "itkMembershipFunctionBase.h" 00026 00027 namespace itk{ 00028 namespace Statistics{ 00029 00052 template< class TSample > 00053 class MixtureModelComponentBase : 00054 public Object 00055 { 00056 public: 00058 typedef MixtureModelComponentBase Self; 00059 typedef Object Superclass ; 00060 typedef SmartPointer<Self> Pointer; 00061 00063 itkTypeMacro(MixtureModelComponentBase, Object); 00064 itkNewMacro(Self) ; 00065 00066 typedef typename TSample::MeasurementVectorType MeasurementVectorType ; 00067 00069 typedef MembershipFunctionBase< MeasurementVectorType > 00070 MembershipFunctionType ; 00071 00073 typedef Array< double > WeightArrayType ; 00074 00075 typedef Array< double > ParametersType ; 00076 00078 virtual void SetSample(TSample* sample) ; 00079 00081 TSample* GetSample() ; 00082 00087 MembershipFunctionType* GetMembershipFunction() ; 00088 00089 void SetMinimalParametersChange(double change) 00090 { m_MinimalParametersChange = change ; } 00091 00092 double GetMinimalParametersChange() 00093 { return m_MinimalParametersChange ; } 00094 00095 virtual void SetParameters(const ParametersType ¶meters) ; 00096 00097 virtual ParametersType GetFullParameters() 00098 { return m_Parameters ; } 00099 00100 00103 void AreParametersModified(bool flag) ; 00104 00106 bool AreParametersModified() ; 00107 00109 void SetWeight(int index, double value) ; 00110 00112 double GetWeight(int index) ; 00113 00115 double Evaluate(MeasurementVectorType& measurements) ; 00116 00118 WeightArrayType* GetWeights() ; 00119 00120 virtual void Update() ; 00121 00122 protected: 00123 MixtureModelComponentBase() ; 00124 virtual ~MixtureModelComponentBase() ; 00125 void PrintSelf(std::ostream& os, Indent indent) const; 00126 00128 void CreateWeightArray() ; 00130 void DeleteWeightArray() ; 00134 void SetMembershipFunction(MembershipFunctionType* function) ; 00135 00136 virtual void GenerateData() ; 00137 00138 private: 00140 TSample* m_Sample ; 00141 00142 double m_MinimalParametersChange ; 00143 00144 ParametersType m_Parameters ; 00146 MembershipFunctionType* m_MembershipFunction ; 00148 WeightArrayType* m_Weights ; 00150 bool m_ParametersModified ; 00151 00152 } ; // end of class 00153 00154 } // end of namespace Statistics 00155 } // end of namespace itk 00156 00157 #ifndef ITK_MANUAL_INSTANTIATION 00158 #include "itkMixtureModelComponentBase.txx" 00159 #endif 00160 00161 #endif 00162