]> Creatis software - FrontAlgorithms.git/blob - lib/fpa/Base/Functors/GaussianModel.hxx
...
[FrontAlgorithms.git] / lib / fpa / Base / Functors / GaussianModel.hxx
1 #ifndef __fpa__Base__Functors__GaussianModel__hxx__
2 #define __fpa__Base__Functors__GaussianModel__hxx__
3
4 // -------------------------------------------------------------------------
5 template< class _TInput, class _TOutput >
6 typename fpa::Base::Functors::GaussianModel< _TInput, _TOutput >::
7 TOutput fpa::Base::Functors::GaussianModel< _TInput, _TOutput >::
8 Evaluate( const TInput& x ) const
9 {
10   TOutput r = TOutput( 0 );
11   if( this->m_Model->GetNumberOfSamples( ) > this->m_SupportSize )
12   {
13     r = this->m_Model->SquaredMahalanobis( TOutput( x ) );
14     if( r <= TOutput( 1 ) )
15       this->m_Model->AddSample( TOutput( x ) );
16   }
17   else
18   {
19     this->m_Model->AddSample( TOutput( x ) );
20     if( this->m_Model->GetNumberOfSamples( ) > 2 )
21       r = this->m_Model->SquaredMahalanobis( TOutput( x ) );
22
23   } // fi
24   if( r < this->m_MinimumCost )
25     return( this->m_MinimumCost );
26   else
27     return( r );
28 }
29
30 // -------------------------------------------------------------------------
31 template< class _TInput, class _TOutput >
32 fpa::Base::Functors::GaussianModel< _TInput, _TOutput >::
33 GaussianModel( )
34   : Superclass( ),
35     m_SupportSize( 30 ),
36     m_MinimumCost( TOutput( 1e-10 ) )
37 {
38   this->m_Model = TModel::New( );
39 }
40
41 // -------------------------------------------------------------------------
42 template< class _TInput, class _TOutput >
43 fpa::Base::Functors::GaussianModel< _TInput, _TOutput >::
44 ~GaussianModel( )
45 {
46 }
47
48 #endif // __fpa__Base__Functors__GaussianModel__hxx__
49
50 // eof - $RCSfile$