ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkMixtureModelComponentBase.h
Go to the documentation of this file.
00001 /*=========================================================================
00002  *
00003  *  Copyright Insight Software Consortium
00004  *
00005  *  Licensed under the Apache License, Version 2.0 (the "License");
00006  *  you may not use this file except in compliance with the License.
00007  *  You may obtain a copy of the License at
00008  *
00009  *         http://www.apache.org/licenses/LICENSE-2.0.txt
00010  *
00011  *  Unless required by applicable law or agreed to in writing, software
00012  *  distributed under the License is distributed on an "AS IS" BASIS,
00013  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  *  See the License for the specific language governing permissions and
00015  *  limitations under the License.
00016  *
00017  *=========================================================================*/
00018 #ifndef __itkMixtureModelComponentBase_h
00019 #define __itkMixtureModelComponentBase_h
00020 
00021 #include "vnl/vnl_vector.h"
00022 #include "vnl/vnl_matrix.h"
00023 
00024 #include "itkArray.h"
00025 #include "itkObject.h"
00026 #include "itkMembershipFunctionBase.h"
00027 
00028 namespace itk
00029 {
00030 namespace Statistics
00031 {
00055 template< class TSample >
00056 class ITK_EXPORT MixtureModelComponentBase:
00057   public Object
00058 {
00059 public:
00061   typedef MixtureModelComponentBase  Self;
00062   typedef Object                     Superclass;
00063   typedef SmartPointer< Self >       Pointer;
00064   typedef SmartPointer< const Self > ConstPointer;
00065 
00067   itkTypeMacro(MixtureModelComponentBase, Object);
00068 
00069   typedef typename TSample::MeasurementVectorType     MeasurementVectorType;
00070   typedef typename TSample::MeasurementVectorSizeType MeasurementVectorSizeType;
00071 
00073   typedef MembershipFunctionBase< MeasurementVectorType >
00074   MembershipFunctionType;
00075 
00077   typedef Array< double > WeightArrayType;
00078 
00079   typedef Array< double > ParametersType;
00080 
00082   virtual void SetSample(const TSample *sample);
00083 
00085   const TSample * GetSample() const;
00086 
00091   MembershipFunctionType * GetMembershipFunction();
00092 
00093   void SetMinimalParametersChange(double change)
00094   {
00095     m_MinimalParametersChange = change;
00096   }
00097 
00098   double GetMinimalParametersChange()
00099   {
00100     return m_MinimalParametersChange;
00101   }
00102 
00103   virtual void SetParameters(const ParametersType & parameters);
00104 
00105   virtual ParametersType GetFullParameters()
00106   {
00107     return m_Parameters;
00108   }
00109 
00112   void AreParametersModified(bool flag);
00113 
00115   bool AreParametersModified();
00116 
00118   void SetWeight(unsigned int index, double value);
00119 
00121   double GetWeight(unsigned int index) const;
00122 
00124   double Evaluate(MeasurementVectorType & measurements);
00125 
00127   itkGetConstReferenceMacro(Weights, WeightArrayType);
00128 
00129   virtual void Update();
00130 
00131 protected:
00132   MixtureModelComponentBase();
00133   virtual ~MixtureModelComponentBase();
00134   void PrintSelf(std::ostream & os, Indent indent) const;
00135 
00139   void SetMembershipFunction(MembershipFunctionType *function);
00140 
00141   virtual void GenerateData() = 0;
00142 
00143 private:
00145   const TSample *m_Sample;
00146 
00147   double m_MinimalParametersChange;
00148 
00149   ParametersType m_Parameters;
00150 
00152   MembershipFunctionType *m_MembershipFunction;
00153 
00155   WeightArrayType m_Weights;
00156 
00158   bool m_ParametersModified;
00159 };  // end of class
00160 } // end of namespace Statistics
00161 } // end of namespace itk
00162 
00163 #ifndef ITK_MANUAL_INSTANTIATION
00164 #include "itkMixtureModelComponentBase.hxx"
00165 #endif
00166 
00167 #endif
00168