]> Creatis software - FrontAlgorithms.git/blob - lib/fpa/Image/Functors/RegionGrow/BinaryThreshold.hxx
e1853e2ca7db676bdb483d41e91f21e8497f29da
[FrontAlgorithms.git] / lib / fpa / Image / Functors / RegionGrow / BinaryThreshold.hxx
1 #ifndef __fpa__Image__Functors__RegionGrow__BinaryThreshold__hxx__
2 #define __fpa__Image__Functors__RegionGrow__BinaryThreshold__hxx__
3
4 #include <limits>
5
6 // -------------------------------------------------------------------------
7 template< class _TImage, class _TOutput >
8 _TOutput
9 fpa::Image::Functors::RegionGrow::BinaryThreshold< _TImage, _TOutput >::
10 Evaluate( const TIndex& a, const TIndex& b ) const
11 {
12   const _TImage* im =
13     dynamic_cast< const _TImage* >( this->m_Image.GetPointer( ) );
14   if( im != NULL )
15   {
16     TPixel v = im->GetPixel( b );
17     return(
18       ( this->m_Lower <= v && v <= this->m_Upper )?
19       this->m_InsideValue:
20       this->m_OutsideValue
21       );
22   }
23   else
24     return( this->m_OutsideValue );
25 }
26
27 // -------------------------------------------------------------------------
28 template< class _TImage, class _TOutput >
29 fpa::Image::Functors::RegionGrow::BinaryThreshold< _TImage, _TOutput >::
30 BinaryThreshold( )
31   : Superclass( )
32 {
33   this->m_Upper = std::numeric_limits< TPixel >::max( );
34   if( std::numeric_limits< TPixel >::is_integer )
35     this->m_Lower = std::numeric_limits< TPixel >::min( );
36   else
37     this->m_Lower = -this->m_Upper;
38 }
39
40 // -------------------------------------------------------------------------
41 template< class _TImage, class _TOutput >
42 fpa::Image::Functors::RegionGrow::BinaryThreshold< _TImage, _TOutput >::
43 ~BinaryThreshold( )
44 {
45 }
46
47 #endif // __fpa__Image__Functors__RegionGrow__BinaryThreshold__hxx__
48
49 // eof - $RCSfile$