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_math.h"
00026 #include "vnl/algo/vnl_matrix_inverse.h"
00027
00028
00029 #include "itkImageRegionIterator.h"
00030 #include "itkExceptionObject.h"
00031
00032 #include "itkImageModelEstimatorBase.h"
00033
00034 namespace itk
00035 {
00036
00077 template <class TInputImage,
00078 class TMembershipFunction,
00079 class TTrainingImage>
00080 class ITK_EXPORT ImageGaussianModelEstimator:
00081 public ImageModelEstimatorBase<TInputImage, TMembershipFunction>
00082 {
00083 public:
00085 typedef ImageGaussianModelEstimator Self;
00086 typedef ImageModelEstimatorBase<TInputImage,TMembershipFunction> Superclass;
00087
00088 typedef SmartPointer<Self> Pointer;
00089 typedef SmartPointer<const Self> ConstPointer;
00090
00092 itkNewMacro(Self);
00093
00095 itkTypeMacro(ImageGaussianModelEstimator, ImageModelEstimatorBase);
00096
00098 typedef typename TInputImage::Pointer InputImagePointer;
00099
00101 typedef typename TTrainingImage::Pointer TrainingImagePointer;
00102
00105 typedef typename TInputImage::PixelType InputImagePixelType;
00106
00109 typedef typename TTrainingImage::PixelType TrainingImagePixelType;
00110
00112 typedef
00113 ImageRegionIterator< TInputImage > InputImageIterator;
00114 typedef
00115 ImageRegionIterator< TTrainingImage > TrainingImageIterator;
00116
00118 typedef typename TMembershipFunction::Pointer MembershipFunctionPointer ;
00119
00121 itkSetMacro(TrainingImage,TrainingImagePointer);
00122
00124 itkGetMacro(TrainingImage,TrainingImagePointer);
00125
00126
00127
00128 protected:
00129 ImageGaussianModelEstimator();
00130 ~ImageGaussianModelEstimator();
00131 virtual void PrintSelf(std::ostream& os, Indent indent) const;
00132
00134 void GenerateData() ;
00135
00136 private:
00137 ImageGaussianModelEstimator(const Self&);
00138 void operator=(const Self&);
00139
00140 typedef vnl_matrix<double> MatrixType;
00141 typedef vnl_vector<double> VectorType;
00142
00143 typedef typename TInputImage::SizeType InputImageSizeType;
00144
00146 itkStaticConstMacro(VectorDimension, unsigned int,
00147 InputImagePixelType::Dimension);
00148 typedef vnl_matrix_fixed<double,1,itkGetStaticConstMacro(VectorDimension)> ColumnVectorType;
00149
00150 MatrixType m_NumberOfSamples;
00151 MatrixType m_Means;
00152 MatrixType *m_Covariance;
00153
00154 TrainingImagePointer m_TrainingImage;
00155
00159 virtual void EstimateModels();
00160
00161 void EstimateGaussianModelParameters();
00162
00163 };
00164
00165 }
00166
00167 #ifndef ITK_MANUAL_INSTANTIATION
00168 #include "itkImageGaussianModelEstimator.txx"
00169 #endif
00170
00171
00172
00173 #endif