Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkGaussianDensityFunction.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkGaussianDensityFunction.h,v $
00005   Language:  C++
00006   Date:      $Date: 2009-03-04 15:23:47 $
00007   Version:   $Revision: 1.16 $
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 __itkGaussianDensityFunction_h
00018 #define __itkGaussianDensityFunction_h
00019 
00020 #include "itkArray.h"
00021 #include "itkVariableSizeMatrix.h"
00022 #include "vnl/algo/vnl_matrix_inverse.h"
00023 #include "vnl/algo/vnl_determinant.h"
00024 #include "vnl/vnl_math.h"
00025 
00026 #include "itkMatrix.h"
00027 #include "itkDensityFunction.h"
00028 
00029 namespace itk { 
00030 namespace Statistics {
00031 
00054 template< class TMeasurementVector >
00055 class ITK_EXPORT GaussianDensityFunction :
00056     public DensityFunction< TMeasurementVector >
00057 {
00058 public:
00060   typedef GaussianDensityFunction               Self;
00061   typedef DensityFunction< TMeasurementVector > Superclass;
00062   typedef SmartPointer<Self>                    Pointer;
00063   typedef SmartPointer<const Self>              ConstPointer;
00064 
00066   itkTypeMacro(GaussianDensityFunction, DensityFunction);
00067   itkNewMacro(Self);
00069 
00071   typedef TMeasurementVector MeasurementVectorType;
00072 
00074   typedef typename Superclass::MeasurementVectorSizeType MeasurementVectorSizeType;
00075 
00077   typedef Array< double >                               MeanType;
00078 
00080   typedef VariableSizeMatrix< double >                  CovarianceType;
00081 
00083   void SetMean( const MeanType * mean )
00084     {
00085     if( this->GetMeasurementVectorSize() )
00086       {
00087       MeasurementVectorTraits::Assert(mean, this->GetMeasurementVectorSize(),
00088                                       "GaussianDensityFunction::SetMean Size of measurement vectors in the sample must the same as the size of the mean." );
00089       }
00090     else
00091       {
00092       this->SetMeasurementVectorSize( mean->Size() );
00093       }
00095 
00096     if ( m_Mean != mean) 
00097       {
00098       m_Mean = mean;
00099       this->Modified();
00100       }
00101     }
00102   
00104   const MeanType * GetMean() const
00105     { return m_Mean; }
00106 
00110   void SetCovariance(const CovarianceType* cov); 
00111 
00113   const CovarianceType* GetCovariance() const;
00114 
00116   double Evaluate(const MeasurementVectorType &measurement) const;
00117 
00118 protected:
00119   GaussianDensityFunction(void);
00120   virtual ~GaussianDensityFunction(void) {}
00121   void PrintSelf(std::ostream& os, Indent indent) const;
00122 
00123 private:
00124   const MeanType        * m_Mean;           // mean
00125   const CovarianceType  * m_Covariance;     // covariance matrix
00126 
00127   // inverse covariance matrix which is automatically calculated 
00128   // when covariace matirx is set.  This speed up the GetProbability()
00129   CovarianceType  m_InverseCovariance; 
00130 
00131   // pre_factor which is automatically calculated 
00132   // when covariace matirx is set.  This speeds up the GetProbability()  
00133   double m_PreFactor;
00134 
00137   bool m_IsCovarianceZero;
00138 };
00139 
00140 } // end of namespace Statistics
00141 } // end namespace itk
00142 
00143 #ifndef ITK_MANUAL_INSTANTIATION
00144 #include "itkGaussianDensityFunction.txx"
00145 #endif
00146 
00147 #endif
00148 

Generated at Tue Sep 15 03:01:17 2009 for ITK by doxygen 1.5.8 written by Dimitri van Heesch, © 1997-2000