ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkImageGaussianModelEstimator.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 __itkImageGaussianModelEstimator_h
00019 #define __itkImageGaussianModelEstimator_h
00020 
00021 #include <math.h>
00022 #include <float.h>
00023 
00024 #include "vnl/vnl_vector.h"
00025 #include "vnl/vnl_matrix.h"
00026 #include "vnl/vnl_matrix_fixed.h"
00027 #include "vnl/vnl_math.h"
00028 #include "vnl/algo/vnl_matrix_inverse.h"
00029 
00030 #include "itkImageRegionIterator.h"
00031 #include "itkMacro.h"
00032 
00033 #include "itkImageModelEstimatorBase.h"
00034 
00035 namespace itk
00036 {
00074 template< class TInputImage,
00075           class TMembershipFunction,
00076           class TTrainingImage >
00077 class ITK_EXPORT ImageGaussianModelEstimator:
00078   public ImageModelEstimatorBase< TInputImage, TMembershipFunction >
00079 {
00080 public:
00082   typedef ImageGaussianModelEstimator                                 Self;
00083   typedef ImageModelEstimatorBase< TInputImage, TMembershipFunction > Superclass;
00084   typedef SmartPointer< Self >                                        Pointer;
00085   typedef SmartPointer< const Self >                                  ConstPointer;
00086 
00088   itkNewMacro(Self);
00089 
00091   itkTypeMacro(ImageGaussianModelEstimator, ImageModelEstimatorBase);
00092 
00094   typedef typename TInputImage::Pointer InputImagePointer;
00095 
00097   typedef typename TTrainingImage::Pointer TrainingImagePointer;
00098 
00101   typedef typename TInputImage::PixelType InputImagePixelType;
00102 
00105   typedef typename TTrainingImage::PixelType TrainingImagePixelType;
00106 
00108   typedef ImageRegionIterator< TInputImage >    InputImageIterator;
00109   typedef ImageRegionIterator< TTrainingImage > TrainingImageIterator;
00110 
00112   typedef TMembershipFunction                   MembershipFunctionType;
00113   typedef typename TMembershipFunction::Pointer MembershipFunctionPointer;
00114 
00116   itkSetMacro(TrainingImage, TrainingImagePointer);
00117 
00119   itkGetConstMacro(TrainingImage, TrainingImagePointer);
00120 protected:
00121   ImageGaussianModelEstimator();
00122   ~ImageGaussianModelEstimator();
00123   virtual void PrintSelf(std::ostream & os, Indent indent) const;
00125 
00127   void GenerateData();
00128 
00129 private:
00130   ImageGaussianModelEstimator(const Self &); //purposely not implemented
00131   void operator=(const Self &);              //purposely not implemented
00132 
00133   typedef vnl_matrix< double > MatrixType;
00134 
00135   typedef typename TInputImage::SizeType InputImageSizeType;
00136 
00138   itkStaticConstMacro(VectorDimension, unsigned int,
00139                       InputImagePixelType::Dimension);
00140 
00141   MatrixType  m_NumberOfSamples;
00142   MatrixType  m_Means;
00143   MatrixType *m_Covariance;
00144 
00145   TrainingImagePointer m_TrainingImage;
00146 
00150   virtual void EstimateModels();
00151 
00152   void EstimateGaussianModelParameters();
00153 }; // class ImageGaussianModelEstimator
00154 } // namespace itk
00155 
00156 #ifndef ITK_MANUAL_INSTANTIATION
00157 #include "itkImageGaussianModelEstimator.hxx"
00158 #endif
00159 
00160 #endif
00161