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
00055 itkTypeMacro(ExpectationMaximizationMixtureModelEstimator,
00056 Object);
00057 itkNewMacro(Self) ;
00058
00060 itkStaticConstMacro(MeasurementVectorSize, unsigned int,
00061 TSample::MeasurementVectorSize);
00062
00064 typedef typename TSample::MeasurementType MeasurementType ;
00065 typedef typename TSample::MeasurementVectorType MeasurementVectorType ;
00066
00068 typedef MixtureModelComponentBase< TSample > ComponentType ;
00069
00071 typedef std::vector< ComponentType* > ComponentVectorType ;
00072
00074 typedef MembershipFunctionBase< MeasurementVectorType >
00075 ComponentMembershipFunctionType ;
00076
00078 typedef Array< double > ProportionVectorType ;
00079
00081 void SetSample(TSample* sample) ;
00082
00084 TSample* GetSample() ;
00085
00088 void SetInitialProportions(ProportionVectorType &propotion) ;
00089 ProportionVectorType* GetInitialProportions() ;
00090
00092 ProportionVectorType* GetProportions() ;
00093
00098 void SetMaximumIteration(int numberOfIterations) ;
00099 int GetMaximumIteration() ;
00100
00102 int GetCurrentIteration()
00103 { return m_CurrentIteration ; }
00104
00106 int AddComponent(ComponentType* component) ;
00107
00109 int GetNumberOfComponents() ;
00110
00112 void Update() ;
00113
00115 enum TERMINATION_CODE { CONVERGED = 0, NOT_CONVERGED = 1 } ;
00116
00118 TERMINATION_CODE GetTerminationCode() ;
00119
00122 ComponentMembershipFunctionType* GetComponentMembershipFunction(int componentIndex) ;
00123
00124 protected:
00125 ExpectationMaximizationMixtureModelEstimator() ;
00126 virtual ~ExpectationMaximizationMixtureModelEstimator() {}
00127 void PrintSelf(std::ostream& os, Indent indent) const ;
00128
00129 bool CalculateDensities() ;
00130 double CalculateExpectation() ;
00131 bool UpdateComponentParameters() ;
00132 bool UpdateProportions() ;
00133
00135 void GenerateData() ;
00136
00137 private:
00139 TSample* m_Sample ;
00140
00141 int m_MaxIteration ;
00142 int m_CurrentIteration ;
00143 TERMINATION_CODE m_TerminationCode ;
00144 ComponentVectorType m_ComponentVector ;
00145 ProportionVectorType m_InitialProportions ;
00146 ProportionVectorType m_Proportions ;
00147 } ;
00148
00149
00150 }
00151 }
00152
00153
00154 #ifndef ITK_MANUAL_INSTANTIATION
00155 #include "itkExpectationMaximizationMixtureModelEstimator.txx"
00156 #endif
00157
00158 #endif
00159
00160
00161
00162
00163
00164
00165