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
00060 template< class TSample >
00061 class ITK_EXPORT ExpectationMaximizationMixtureModelEstimator : public Object
00062 {
00063 public:
00065 typedef ExpectationMaximizationMixtureModelEstimator Self;
00066 typedef Object Superclass;
00067 typedef SmartPointer< Self > Pointer;
00068
00070 itkTypeMacro(ExpectationMaximizationMixtureModelEstimator,
00071 Object);
00072 itkNewMacro(Self) ;
00073
00075 itkStaticConstMacro(MeasurementVectorSize, unsigned int,
00076 TSample::MeasurementVectorSize);
00077
00079 typedef typename TSample::MeasurementType MeasurementType ;
00080 typedef typename TSample::MeasurementVectorType MeasurementVectorType ;
00081
00082 typedef MixtureModelComponentBase< TSample > ComponentType ;
00083 typedef std::vector< ComponentType* > ComponentVectorType ;
00084 typedef MembershipFunctionBase< MeasurementVectorType > ComponentMembershipFunctionType ;
00085
00087 void SetSample(TSample* sample) ;
00088
00090 TSample* GetSample() ;
00091
00092 typedef Array< double > ProportionVectorType ;
00093
00094 void SetInitialProportions(ProportionVectorType &propotion) ;
00095
00096 ProportionVectorType* GetInitialProportions() ;
00097
00098 ProportionVectorType* GetProportions() ;
00099
00100 void SetMaximumIteration(int numberOfIterations) ;
00101
00102 int GetMaximumIteration() ;
00103
00104 int GetCurrentIteration()
00105 { return m_CurrentIteration ; }
00106
00107 int AddComponent(ComponentType* component) ;
00108
00109 int GetNumberOfComponents() ;
00110
00111 void Update() ;
00112
00113 enum TERMINATION_CODE { CONVERGED = 0, NOT_CONVERGED = 1 } ;
00114
00115 TERMINATION_CODE GetTerminationCode() ;
00116 ComponentMembershipFunctionType* GetComponentMembershipFunction(int componentIndex) ;
00117
00118 protected:
00119 ExpectationMaximizationMixtureModelEstimator() ;
00120 virtual ~ExpectationMaximizationMixtureModelEstimator() {}
00121 void PrintSelf(std::ostream& os, Indent indent) const ;
00122
00123 bool CalculateDensities() ;
00124 double CalculateExpectation() ;
00125 bool UpdateComponentParameters() ;
00126 bool UpdateProportions() ;
00127
00129 void GenerateData() ;
00130
00131 private:
00133 TSample* m_Sample ;
00134
00135 int m_MaxIteration ;
00136 int m_CurrentIteration ;
00137 TERMINATION_CODE m_TerminationCode ;
00138 ComponentVectorType m_ComponentVector ;
00139 ProportionVectorType m_InitialProportions ;
00140 ProportionVectorType m_Proportions ;
00141 } ;
00142
00143
00144 }
00145 }
00146
00147
00148 #ifndef ITK_MANUAL_INSTANTIATION
00149 #include "itkExpectationMaximizationMixtureModelEstimator.txx"
00150 #endif
00151
00152 #endif
00153
00154
00155
00156
00157
00158
00159