00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkExpectationMaximizationMixtureModelEstimator_h
00018 #define __itkExpectationMaximizationMixtureModelEstimator_h
00019
00020 #include "itkMembershipFunctionBase.h"
00021 #include "itkMixtureModelComponentBase.h"
00022
00023 namespace itk{
00024 namespace Statistics{
00025
00052 template< class TSample >
00053 class ITK_EXPORT ExpectationMaximizationMixtureModelEstimator : public Object
00054 {
00055 public:
00057 typedef ExpectationMaximizationMixtureModelEstimator Self;
00058 typedef Object Superclass;
00059 typedef SmartPointer< Self > Pointer;
00060 typedef SmartPointer<const Self> ConstPointer;
00061
00063 itkTypeMacro(ExpectationMaximizationMixtureModelEstimator,
00064 Object);
00065 itkNewMacro(Self) ;
00066
00068 typedef typename TSample::MeasurementType MeasurementType ;
00069 typedef typename TSample::MeasurementVectorType MeasurementVectorType ;
00070
00072 typedef MixtureModelComponentBase< TSample > ComponentType ;
00073
00075 typedef std::vector< ComponentType* > ComponentVectorType ;
00076
00078 typedef MembershipFunctionBase< MeasurementVectorType >
00079 ComponentMembershipFunctionType ;
00080
00082 typedef Array< double > ProportionVectorType ;
00083
00085 void SetSample(const TSample* sample) ;
00086
00088 const TSample* GetSample() const;
00089
00092 void SetInitialProportions(ProportionVectorType &propotion) ;
00093 ProportionVectorType* GetInitialProportions() ;
00094
00096 ProportionVectorType* GetProportions() ;
00097
00102 void SetMaximumIteration(int numberOfIterations) ;
00103 int GetMaximumIteration() ;
00104
00106 int GetCurrentIteration()
00107 { return m_CurrentIteration ; }
00108
00110 int AddComponent(ComponentType* component) ;
00111
00113 unsigned int GetNumberOfComponents() ;
00114
00116 void Update() ;
00117
00119 enum TERMINATION_CODE { CONVERGED = 0, NOT_CONVERGED = 1 } ;
00120
00122 TERMINATION_CODE GetTerminationCode() ;
00123
00126 ComponentMembershipFunctionType* GetComponentMembershipFunction(int componentIndex) ;
00127
00128 protected:
00129 ExpectationMaximizationMixtureModelEstimator() ;
00130 virtual ~ExpectationMaximizationMixtureModelEstimator() {}
00131 void PrintSelf(std::ostream& os, Indent indent) const ;
00132
00133 bool CalculateDensities() ;
00134 double CalculateExpectation() ;
00135 bool UpdateComponentParameters() ;
00136 bool UpdateProportions() ;
00137
00139 void GenerateData() ;
00140
00141 private:
00143 const TSample* m_Sample ;
00144
00145 int m_MaxIteration ;
00146 int m_CurrentIteration ;
00147 TERMINATION_CODE m_TerminationCode ;
00148 ComponentVectorType m_ComponentVector ;
00149 ProportionVectorType m_InitialProportions ;
00150 ProportionVectorType m_Proportions ;
00151 } ;
00152
00153
00154 }
00155 }
00156
00157
00158 #ifndef ITK_MANUAL_INSTANTIATION
00159 #include "itkExpectationMaximizationMixtureModelEstimator.txx"
00160 #endif
00161
00162 #endif
00163
00164
00165
00166
00167
00168
00169