]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/Extensions/Algorithms/IterativeGaussianModelEstimator.h
Filters improved
[cpPlugins.git] / lib / cpPlugins / Extensions / Algorithms / IterativeGaussianModelEstimator.h
1 // -------------------------------------------------------------------------
2 // @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co)
3 // -------------------------------------------------------------------------
4
5 #ifndef __CPPLUGINS__EXTENSIONS__ALGORITHMS__ITERATIVEGAUSSIANMODELESTIMATOR__H__
6 #define __CPPLUGINS__EXTENSIONS__ALGORITHMS__ITERATIVEGAUSSIANMODELESTIMATOR__H__
7
8 #include <vector>
9 #include <itkConceptChecking.h>
10 #include <itkObject.h>
11 #include <vnl/vnl_matrix.h>
12
13 namespace cpPlugins
14 {
15   namespace Extensions
16   {
17     namespace Algorithms
18     {
19       /**
20        */
21       template< class S, unsigned int D >
22       class IterativeGaussianModelEstimator
23         : public itk::Object
24       {
25       public:
26         typedef IterativeGaussianModelEstimator Self;
27         typedef itk::Object                     Superclass;
28         typedef itk::SmartPointer< Self >       Pointer;
29         typedef itk::SmartPointer< const Self > ConstPointer;
30
31         typedef S TScalar;
32         itkStaticConstMacro( Dimension, unsigned int, D );
33
34         // Begin concept checking
35 #ifdef ITK_USE_CONCEPT_CHECKING
36         itkConceptMacro(
37           ScalarTypeHasFloatResolution,
38           ( itk::Concept::IsFloatingPoint< S > )
39           );
40 #endif
41         // End concept checking
42
43         typedef vnl_matrix< S >        TMatrix;
44         typedef std::vector< TMatrix > TMatrices;
45
46       public:
47         itkNewMacro( Self );
48         itkTypeMacro( IterativeGaussianModelEstimator, itkObject );
49
50         itkGetConstMacro( MinimumProbability, S );
51         itkGetConstMacro( MaximumProbability, S );
52
53       public:
54         unsigned long GetNumberOfSamples( ) const
55           { return( this->m_Samples.size( ) ); }
56
57         void UpdateModel( );
58
59         template< class V >
60         S Probability( const V& sample ) const;
61
62         S Probability( const S& s_x, const S& s_y, ... ) const;
63
64         template< class V, class M >
65         void GetModel( V& m, M& E ) const;
66
67         void Clear( );
68
69         template< class V >
70         void AddSample( const V& sample );
71
72         void AddSample( const S& s_x, const S& s_y, ... );
73
74       protected:
75         IterativeGaussianModelEstimator( );
76         virtual ~IterativeGaussianModelEstimator( );
77
78       private:
79         // Purposely not implemented
80         IterativeGaussianModelEstimator( const Self& other );
81         void operator=( const Self& other );
82
83       protected:
84         TMatrix   m_S1;
85         TMatrix   m_S2;
86         TMatrices m_Samples;
87
88         bool m_Updated;
89         TMatrix m_Cov;
90         TMatrix m_Mean;
91         TMatrix m_InvCov;
92         S m_DensityCoeff;
93
94         S m_MinimumProbability;
95         S m_MaximumProbability;
96       };
97
98     } // ecapseman
99
100   } // ecapseman
101
102 } // ecapseman
103
104 #include <cpPlugins/Extensions/Algorithms/IterativeGaussianModelEstimator.hxx>
105
106 #endif // __CPPLUGINS__EXTENSIONS__ALGORITHMS__ITERATIVEGAUSSIANMODELESTIMATOR__H__
107
108 // eof - $RCSfile$