00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkMixtureModelComponentBase.h,v $ 00005 Language: C++ 00006 Date: $Date: 2005/07/26 15:55:04 $ 00007 Version: $Revision: 1.9 $ 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) ; 00066 00067 typedef typename TSample::MeasurementVectorType MeasurementVectorType ; 00068 typedef typename TSample::MeasurementVectorSizeType MeasurementVectorSizeType; 00069 00071 typedef MembershipFunctionBase< MeasurementVectorType > 00072 MembershipFunctionType ; 00073 00075 typedef Array< double > WeightArrayType ; 00076 00077 typedef Array< double > ParametersType ; 00078 00080 virtual void SetSample(const TSample* sample) ; 00081 00083 const TSample* GetSample() const; 00084 00089 MembershipFunctionType* GetMembershipFunction() ; 00090 00091 void SetMinimalParametersChange(double change) 00092 { m_MinimalParametersChange = change ; } 00093 00094 double GetMinimalParametersChange() 00095 { return m_MinimalParametersChange ; } 00096 00097 virtual void SetParameters(const ParametersType ¶meters) ; 00098 00099 virtual ParametersType GetFullParameters() 00100 { return m_Parameters ; } 00101 00102 00105 void AreParametersModified(bool flag) ; 00106 00108 bool AreParametersModified() ; 00109 00111 void SetWeight(int index, double value) ; 00112 00114 double GetWeight(int index) ; 00115 00117 double Evaluate(MeasurementVectorType& measurements) ; 00118 00120 WeightArrayType* GetWeights() ; 00121 00122 virtual void Update() ; 00123 00124 protected: 00125 MixtureModelComponentBase() ; 00126 virtual ~MixtureModelComponentBase() ; 00127 void PrintSelf(std::ostream& os, Indent indent) const; 00128 00130 void CreateWeightArray() ; 00132 void DeleteWeightArray() ; 00136 void SetMembershipFunction(MembershipFunctionType* function) ; 00137 00138 virtual void GenerateData() ; 00139 00140 private: 00142 const TSample* m_Sample ; 00143 00144 double m_MinimalParametersChange ; 00145 00146 ParametersType m_Parameters ; 00148 MembershipFunctionType* m_MembershipFunction ; 00150 WeightArrayType* m_Weights ; 00152 bool m_ParametersModified ; 00153 00154 } ; // end of class 00155 00156 } // end of namespace Statistics 00157 } // end of namespace itk 00158 00159 #ifndef ITK_MANUAL_INSTANTIATION 00160 #include "itkMixtureModelComponentBase.txx" 00161 #endif 00162 00163 #endif 00164