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
00045 template< class TSample >
00046 class ITK_EXPORT ExpectationMaximizationMixtureModelEstimator : public Object
00047 {
00048 public:
00050 typedef ExpectationMaximizationMixtureModelEstimator Self;
00051 typedef Object Superclass;
00052 typedef SmartPointer< Self > Pointer;
00053 typedef SmartPointer<const Self> ConstPointer;
00054
00056 itkTypeMacro(ExpectationMaximizationMixtureModelEstimator,
00057 Object);
00058 itkNewMacro(Self) ;
00059
00061 itkStaticConstMacro(MeasurementVectorSize, unsigned int,
00062 TSample::MeasurementVectorSize);
00063
00065 typedef typename TSample::MeasurementType MeasurementType ;
00066 typedef typename TSample::MeasurementVectorType MeasurementVectorType ;
00067
00069 typedef MixtureModelComponentBase< TSample > ComponentType ;
00070
00072 typedef std::vector< ComponentType* > ComponentVectorType ;
00073
00075 typedef MembershipFunctionBase< MeasurementVectorType >
00076 ComponentMembershipFunctionType ;
00077
00079 typedef Array< double > ProportionVectorType ;
00080
00082 void SetSample(const TSample* sample) ;
00083
00085 const TSample* GetSample() const;
00086
00089 void SetInitialProportions(ProportionVectorType &propotion) ;
00090 ProportionVectorType* GetInitialProportions() ;
00091
00093 ProportionVectorType* GetProportions() ;
00094
00099 void SetMaximumIteration(int numberOfIterations) ;
00100 int GetMaximumIteration() ;
00101
00103 int GetCurrentIteration()
00104 { return m_CurrentIteration ; }
00105
00107 int AddComponent(ComponentType* component) ;
00108
00110 int GetNumberOfComponents() ;
00111
00113 void Update() ;
00114
00116 enum TERMINATION_CODE { CONVERGED = 0, NOT_CONVERGED = 1 } ;
00117
00119 TERMINATION_CODE GetTerminationCode() ;
00120
00123 ComponentMembershipFunctionType* GetComponentMembershipFunction(int componentIndex) ;
00124
00125 protected:
00126 ExpectationMaximizationMixtureModelEstimator() ;
00127 virtual ~ExpectationMaximizationMixtureModelEstimator() {}
00128 void PrintSelf(std::ostream& os, Indent indent) const ;
00129
00130 bool CalculateDensities() ;
00131 double CalculateExpectation() ;
00132 bool UpdateComponentParameters() ;
00133 bool UpdateProportions() ;
00134
00136 void GenerateData() ;
00137
00138 private:
00140 const TSample* m_Sample ;
00141
00142 int m_MaxIteration ;
00143 int m_CurrentIteration ;
00144 TERMINATION_CODE m_TerminationCode ;
00145 ComponentVectorType m_ComponentVector ;
00146 ProportionVectorType m_InitialProportions ;
00147 ProportionVectorType m_Proportions ;
00148 } ;
00149
00150
00151 }
00152 }
00153
00154
00155 #ifndef ITK_MANUAL_INSTANTIATION
00156 #include "itkExpectationMaximizationMixtureModelEstimator.txx"
00157 #endif
00158
00159 #endif
00160
00161
00162
00163
00164
00165
00166