1 // -------------------------------------------------------------------------
2 // @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co)
3 // -------------------------------------------------------------------------
5 #ifndef __CPEXTENSIONS__ALGORITHMS__ITERATIVEGAUSSIANMODELESTIMATOR__H__
6 #define __CPEXTENSIONS__ALGORITHMS__ITERATIVEGAUSSIANMODELESTIMATOR__H__
9 #include <itkConceptChecking.h>
10 #include <itkObject.h>
11 #include <vnl/vnl_matrix.h>
13 namespace cpExtensions
19 template< class S, unsigned int D >
20 class IterativeGaussianModelEstimator
24 typedef IterativeGaussianModelEstimator Self;
25 typedef itk::Object Superclass;
26 typedef itk::SmartPointer< Self > Pointer;
27 typedef itk::SmartPointer< const Self > ConstPointer;
30 itkStaticConstMacro( Dimension, unsigned int, D );
32 // Begin concept checking
33 #ifdef ITK_USE_CONCEPT_CHECKING
35 ScalarTypeHasFloatResolution,
36 ( itk::Concept::IsFloatingPoint< S > )
39 // End concept checking
41 typedef vnl_matrix< S > TMatrix;
42 typedef std::vector< TMatrix > TMatrices;
46 itkTypeMacro( IterativeGaussianModelEstimator, itkObject );
49 unsigned long GetNumberOfSamples( ) const
50 { return( ( unsigned long )( this->m_N ) ); }
51 const TMatrix& GetMu( ) const
52 { return( this->m_M ); }
53 const TMatrix& GetOmega( ) const
54 { return( this->m_O ); }
56 void SetNumberOfSamples( unsigned long n );
57 void SetMu( const TMatrix& m );
58 void SetOmega( const TMatrix& O );
60 bool SaveModelToFile( const std::string& filename ) const;
61 bool LoadModelFromFile( const std::string& filename );
64 S Probability( const V& sample ) const;
66 S Probability( const S& s_x, const S& s_y, ... ) const;
68 template< class V, class M >
69 void GetModel( V& m, M& E ) const;
74 void AddSample( const V& sample );
76 void AddSample( const S& s_x, const S& s_y, ... );
79 IterativeGaussianModelEstimator( );
80 virtual ~IterativeGaussianModelEstimator( );
83 void _UpdateModel( ) const;
86 // Purposely not implemented
87 IterativeGaussianModelEstimator( const Self& other );
88 void operator=( const Self& other );
95 mutable bool m_Updated;
96 mutable TMatrix m_Cov;
97 mutable TMatrix m_Inv;
105 #ifndef ITK_MANUAL_INSTANTIATION
106 #include <cpExtensions/Algorithms/IterativeGaussianModelEstimator.hxx>
107 #endif // ITK_MANUAL_INSTANTIATION
109 #endif // __CPEXTENSIONS__ALGORITHMS__ITERATIVEGAUSSIANMODELESTIMATOR__H__