1 // -------------------------------------------------------------------------
2 // @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co)
3 // -------------------------------------------------------------------------
5 #ifndef __CPPLUGINS__EXTENSIONS__ALGORITHMS__ITERATIVEGAUSSIANMODELESTIMATOR__H__
6 #define __CPPLUGINS__EXTENSIONS__ALGORITHMS__ITERATIVEGAUSSIANMODELESTIMATOR__H__
9 #include <itkConceptChecking.h>
10 #include <itkObject.h>
11 #include <vnl/vnl_matrix.h>
21 template< class S, unsigned int D >
22 class IterativeGaussianModelEstimator
26 typedef IterativeGaussianModelEstimator Self;
27 typedef itk::Object Superclass;
28 typedef itk::SmartPointer< Self > Pointer;
29 typedef itk::SmartPointer< const Self > ConstPointer;
32 itkStaticConstMacro( Dimension, unsigned int, D );
34 // Begin concept checking
35 #ifdef ITK_USE_CONCEPT_CHECKING
37 ScalarTypeHasFloatResolution,
38 ( itk::Concept::IsFloatingPoint< S > )
41 // End concept checking
43 typedef vnl_matrix< S > TMatrix;
44 typedef std::vector< TMatrix > TMatrices;
48 itkTypeMacro( IterativeGaussianModelEstimator, itkObject );
51 unsigned long GetNumberOfSamples( ) const
52 { return( ( unsigned long )( this->m_N ) ); }
53 const TMatrix& GetMu( ) const
54 { return( this->m_M ); }
55 const TMatrix& GetOmega( ) const
56 { return( this->m_O ); }
58 void SetNumberOfSamples( unsigned long n );
59 void SetMu( const TMatrix& m );
60 void SetOmega( const TMatrix& O );
62 bool SaveModelToFile( const std::string& filename ) const;
63 bool LoadModelFromFile( const std::string& filename );
66 S Probability( const V& sample ) const;
68 S Probability( const S& s_x, const S& s_y, ... ) const;
70 template< class V, class M >
71 void GetModel( V& m, M& E ) const;
76 void AddSample( const V& sample );
78 void AddSample( const S& s_x, const S& s_y, ... );
81 IterativeGaussianModelEstimator( );
82 virtual ~IterativeGaussianModelEstimator( );
85 void _UpdateModel( ) const;
88 // Purposely not implemented
89 IterativeGaussianModelEstimator( const Self& other );
90 void operator=( const Self& other );
97 mutable bool m_Updated;
98 mutable TMatrix m_Cov;
99 mutable TMatrix m_Inv;
109 #include <cpPlugins/Extensions/Algorithms/IterativeGaussianModelEstimator.hxx>
111 #endif // __CPPLUGINS__EXTENSIONS__ALGORITHMS__ITERATIVEGAUSSIANMODELESTIMATOR__H__