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: 2005/07/26 15:54:55 $
00007   Version:   $Revision: 1.15 $
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);
00068   
00070   typedef TMeasurementVector MeasurementVectorType ;
00071 
00073   typedef typename Superclass::MeasurementVectorSizeType MeasurementVectorSizeType;
00074   
00076   typedef Array< double >                               MeanType;
00077   
00079   typedef VariableSizeMatrix< double >                  CovarianceType;
00080 
00082   void SetMean( const MeanType * mean )
00083   {
00084   if( this->GetMeasurementVectorSize() )
00085     {
00086     MeasurementVectorTraits::Assert(mean, this->GetMeasurementVectorSize(),
00087       "GaussianDensityFunction::SetMean Size of measurement vectors in the sample must the same as the size of the mean." );
00088     }
00089   else
00090     {
00091     this->SetMeasurementVectorSize( mean->Size() );
00092     }
00093 
00094   if ( m_Mean != mean) 
00095     {
00096     m_Mean = mean ;
00097     this->Modified() ;
00098     }
00099   }
00100   
00102   const MeanType * GetMean() const
00103   { return m_Mean ; }
00104 
00108   void SetCovariance(const CovarianceType* cov); 
00109   
00111   const CovarianceType* GetCovariance() const ;
00112 
00114   double Evaluate(const MeasurementVectorType &measurement) const ;
00115   
00116 protected:
00117   GaussianDensityFunction(void) ;
00118   virtual ~GaussianDensityFunction(void) {}
00119   void PrintSelf(std::ostream& os, Indent indent) const;
00120 
00121 private:
00122   const MeanType        * m_Mean;           // mean
00123   const CovarianceType  * m_Covariance;     // covariance matrix
00124 
00125   // inverse covariance matrix which is automatically calculated 
00126   // when covariace matirx is set.  This speed up the GetProbability()
00127   CovarianceType  m_InverseCovariance; 
00128 
00129   // pre_factor which is automatically calculated 
00130   // when covariace matirx is set.  This speeds up the GetProbability()  
00131   double m_PreFactor;
00132 
00135   bool m_IsCovarianceZero ;
00136 };
00137 
00138 } // end of namespace Statistics
00139 } // end namespace itk
00140 
00141 #ifndef ITK_MANUAL_INSTANTIATION
00142 #include "itkGaussianDensityFunction.txx"
00143 #endif
00144 
00145 #endif

Generated at Wed May 24 23:10:40 2006 for ITK by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2000