]> Creatis software - FrontAlgorithms.git/blob - lib/fpa/Image/Functors/GaussianModelEstimatorFunction.hxx
a90a39a4b99bc067353367f8d9b23f7b20e0ab71
[FrontAlgorithms.git] / lib / fpa / Image / Functors / GaussianModelEstimatorFunction.hxx
1 #ifndef __FPA__IMAGE__FUNCTORS__GAUSSIANMODELESTIMATORFUNCTION__HXX__
2 #define __FPA__IMAGE__FUNCTORS__GAUSSIANMODELESTIMATORFUNCTION__HXX__
3
4 // -------------------------------------------------------------------------
5 template< class I, class S >
6 bool fpa::Image::Functors::GaussianModelEstimatorFunction< I, S >::
7 Evaluate( const typename I::PixelType& rgb ) const
8 {
9   if( !this->m_Estimating )
10   {
11     this->m_Estimator->AddSample( this->m_YPbPrFunction( rgb ) );
12     if( this->m_Estimator->GetNumberOfSamples( ) == this->m_ModelSupport )
13     {
14       this->m_Estimating = true;
15       this->m_Estimator->UpdateModel( );
16
17     } // fi
18     return( true );
19   }
20   else
21   {
22     S p = this->m_Estimator->Probability( this->m_YPbPrFunction( rgb ) );
23     return( p > this->m_Estimator->GetMinimumProbability( ) );
24
25   } // fi
26 }
27
28 // -------------------------------------------------------------------------
29 template< class I, class S >
30 fpa::Image::Functors::GaussianModelEstimatorFunction< I, S >::
31 GaussianModelEstimatorFunction( )
32   : Superclass( ),
33     m_ModelSupport( 10 )
34 {
35   this->m_Estimator = TEstimator::New( );
36   this->m_Estimator->Clear( );
37   this->m_Estimating = false;
38 }
39
40 // -------------------------------------------------------------------------
41 template< class I, class S >
42 fpa::Image::Functors::GaussianModelEstimatorFunction< I, S >::
43 ~GaussianModelEstimatorFunction( )
44 {
45 }
46
47 #endif // __FPA__IMAGE__FUNCTORS__GAUSSIANMODELESTIMATORFUNCTION__HXX__
48
49 // eof - $RCSfile$