00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkMixtureModelComponentBase.h,v $ 00005 Language: C++ 00006 Date: $Date: 2009-03-04 15:24:02 $ 00007 Version: $Revision: 1.10 $ 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 __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 typedef SmartPointer<const Self> ConstPointer; 00062 00064 itkTypeMacro(MixtureModelComponentBase, Object); 00065 itkNewMacro(Self); 00067 00068 typedef typename TSample::MeasurementVectorType MeasurementVectorType; 00069 typedef typename TSample::MeasurementVectorSizeType MeasurementVectorSizeType; 00070 00072 typedef MembershipFunctionBase< MeasurementVectorType > 00073 MembershipFunctionType; 00074 00076 typedef Array< double > WeightArrayType; 00077 00078 typedef Array< double > ParametersType; 00079 00081 virtual void SetSample(const TSample* sample); 00082 00084 const TSample* GetSample() const; 00085 00090 MembershipFunctionType* GetMembershipFunction(); 00091 00092 void SetMinimalParametersChange(double change) 00093 { m_MinimalParametersChange = change; } 00094 00095 double GetMinimalParametersChange() 00096 { return m_MinimalParametersChange; } 00097 00098 virtual void SetParameters(const ParametersType ¶meters); 00099 00100 virtual ParametersType GetFullParameters() 00101 { return m_Parameters; } 00102 00103 00106 void AreParametersModified(bool flag); 00107 00109 bool AreParametersModified(); 00110 00112 void SetWeight(int index, double value); 00113 00115 double GetWeight(int index); 00116 00118 double Evaluate(MeasurementVectorType& measurements); 00119 00121 WeightArrayType* GetWeights(); 00122 00123 virtual void Update(); 00124 00125 protected: 00126 MixtureModelComponentBase(); 00127 virtual ~MixtureModelComponentBase(); 00128 void PrintSelf(std::ostream& os, Indent indent) const; 00129 00131 void CreateWeightArray(); 00132 00134 void DeleteWeightArray(); 00135 00139 void SetMembershipFunction(MembershipFunctionType* function); 00140 00141 virtual void GenerateData(); 00142 00143 private: 00145 const TSample* m_Sample; 00146 00147 double m_MinimalParametersChange; 00148 00149 ParametersType m_Parameters; 00151 MembershipFunctionType* m_MembershipFunction; 00152 00154 WeightArrayType* m_Weights; 00155 00157 bool m_ParametersModified; 00158 00159 }; // end of class 00160 00161 } // end of namespace Statistics 00162 } // end of namespace itk 00163 00164 #ifndef ITK_MANUAL_INSTANTIATION 00165 #include "itkMixtureModelComponentBase.txx" 00166 #endif 00167 00168 #endif 00169