00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef _itkImageGaussianModelEstimator_h
00018 #define _itkImageGaussianModelEstimator_h
00019
00020 #include <math.h>
00021 #include <float.h>
00022
00023 #include "vnl/vnl_vector.h"
00024 #include "vnl/vnl_matrix.h"
00025 #include "vnl/vnl_matrix_fixed.h"
00026 #include "vnl/vnl_math.h"
00027 #include "vnl/algo/vnl_matrix_inverse.h"
00028
00029
00030 #include "itkImageRegionIterator.h"
00031 #include "itkExceptionObject.h"
00032
00033 #include "itkImageModelEstimatorBase.h"
00034
00035 namespace itk
00036 {
00037
00078 template <class TInputImage,
00079 class TMembershipFunction,
00080 class TTrainingImage>
00081 class ITK_EXPORT ImageGaussianModelEstimator:
00082 public ImageModelEstimatorBase<TInputImage, TMembershipFunction>
00083 {
00084 public:
00086 typedef ImageGaussianModelEstimator Self;
00087 typedef ImageModelEstimatorBase<TInputImage,TMembershipFunction> Superclass;
00088
00089 typedef SmartPointer<Self> Pointer;
00090 typedef SmartPointer<const Self> ConstPointer;
00091
00093 itkNewMacro(Self);
00094
00096 itkTypeMacro(ImageGaussianModelEstimator, ImageModelEstimatorBase);
00097
00099 typedef typename TInputImage::Pointer InputImagePointer;
00100
00102 typedef typename TTrainingImage::Pointer TrainingImagePointer;
00103
00106 typedef typename TInputImage::PixelType InputImagePixelType;
00107
00110 typedef typename TTrainingImage::PixelType TrainingImagePixelType;
00111
00113 typedef
00114 ImageRegionIterator< TInputImage > InputImageIterator;
00115 typedef
00116 ImageRegionIterator< TTrainingImage > TrainingImageIterator;
00117
00119 typedef typename TMembershipFunction::Pointer MembershipFunctionPointer ;
00120
00122 itkSetMacro(TrainingImage,TrainingImagePointer);
00123
00125 itkGetMacro(TrainingImage,TrainingImagePointer);
00126
00127
00128
00129 protected:
00130 ImageGaussianModelEstimator();
00131 ~ImageGaussianModelEstimator();
00132 virtual void PrintSelf(std::ostream& os, Indent indent) const;
00133
00135 void GenerateData() ;
00136
00137 private:
00138 ImageGaussianModelEstimator(const Self&);
00139 void operator=(const Self&);
00140
00141 typedef vnl_matrix<double> MatrixType;
00142 typedef vnl_vector<double> VectorType;
00143
00144 typedef typename TInputImage::SizeType InputImageSizeType;
00145
00147 itkStaticConstMacro(VectorDimension, unsigned int,
00148 InputImagePixelType::Dimension);
00149 typedef vnl_matrix_fixed<double,1,itkGetStaticConstMacro(VectorDimension)> ColumnVectorType;
00151
00152 MatrixType m_NumberOfSamples;
00153 MatrixType m_Means;
00154 MatrixType *m_Covariance;
00155
00156 TrainingImagePointer m_TrainingImage;
00157
00161 virtual void EstimateModels();
00162
00163 void EstimateGaussianModelParameters();
00164
00165 };
00166
00167 }
00168
00169 #ifndef ITK_MANUAL_INSTANTIATION
00170 #include "itkImageGaussianModelEstimator.txx"
00171 #endif
00172
00173
00174
00175 #endif
00176