]> Creatis software - cpPlugins.git/blobdiff - lib/cpPlugins/Extensions/Algorithms/IterativeGaussianModelEstimator.h
New pixel converter
[cpPlugins.git] / lib / cpPlugins / Extensions / Algorithms / IterativeGaussianModelEstimator.h
index 148fee9d9bffedf4dc52cedfb03b8bd254810091..017691e292548c3216a91376348ef0bffb017cb8 100644 (file)
@@ -5,6 +5,7 @@
 #ifndef __CPPLUGINS__EXTENSIONS__ALGORITHMS__ITERATIVEGAUSSIANMODELESTIMATOR__H__
 #define __CPPLUGINS__EXTENSIONS__ALGORITHMS__ITERATIVEGAUSSIANMODELESTIMATOR__H__
 
+#include <vector>
 #include <itkConceptChecking.h>
 #include <itkObject.h>
 #include <vnl/vnl_matrix.h>
@@ -39,15 +40,32 @@ namespace cpPlugins
 #endif
         // End concept checking
 
-        typedef vnl_matrix< S > TMatrix;
+        typedef vnl_matrix< S >        TMatrix;
+        typedef std::vector< TMatrix > TMatrices;
 
       public:
         itkNewMacro( Self );
         itkTypeMacro( IterativeGaussianModelEstimator, itkObject );
 
       public:
-        const unsigned long& GetNumberOfSamples( ) const
-          { return( this->m_N ); }
+        unsigned long GetNumberOfSamples( ) const
+          { return( ( unsigned long )( this->m_N ) ); }
+        const TMatrix& GetMu( ) const
+          { return( this->m_M ); }
+        const TMatrix& GetOmega( ) const
+          { return( this->m_O ); }
+
+        void SetNumberOfSamples( unsigned long n );
+        void SetMu( const TMatrix& m );
+        void SetOmega( const TMatrix& O );
+
+        bool SaveModelToFile( const std::string& filename ) const;
+        bool LoadModelFromFile( const std::string& filename );
+
+        template< class V >
+        S Probability( const V& sample ) const;
+
+        S Probability( const S& s_x, const S& s_y, ... ) const;
 
         template< class V, class M >
         void GetModel( V& m, M& E ) const;
@@ -63,15 +81,23 @@ namespace cpPlugins
         IterativeGaussianModelEstimator( );
         virtual ~IterativeGaussianModelEstimator( );
 
+      protected:
+        void _UpdateModel( ) const;
+
       private:
         // Purposely not implemented
         IterativeGaussianModelEstimator( const Self& other );
         void operator=( const Self& other );
 
       protected:
-        unsigned long m_N;
-        TMatrix m_S1;
-        TMatrix m_S2;
+        S m_N;
+        TMatrix m_M;
+        TMatrix m_O;
+
+        mutable bool m_Updated;
+        mutable TMatrix m_Cov;
+        mutable TMatrix m_Inv;
+        mutable S m_Norm;
       };
 
     } // ecapseman