X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2Ffpa%2FFunctors%2FRegionGrow%2FBinaryThreshold.hxx;fp=lib%2Ffpa%2FFunctors%2FRegionGrow%2FBinaryThreshold.hxx;h=f7ad48f2a09bc9cb2fad5c30b40962c4fc4c1e14;hb=2047276c8f1a02432fbcc7014722d460d6c1e60f;hp=0000000000000000000000000000000000000000;hpb=3c639e5da479c7216a0a302ffa156ac6762caeed;p=FrontAlgorithms.git diff --git a/lib/fpa/Functors/RegionGrow/BinaryThreshold.hxx b/lib/fpa/Functors/RegionGrow/BinaryThreshold.hxx new file mode 100644 index 0000000..f7ad48f --- /dev/null +++ b/lib/fpa/Functors/RegionGrow/BinaryThreshold.hxx @@ -0,0 +1,73 @@ +// ========================================================================= +// @author Leonardo Florez Valencia +// @email florez-l@javeriana.edu.co +// ========================================================================= +#ifndef __fpa__Functors__RegionGrow__BinaryThreshold__hxx__ +#define __fpa__Functors__RegionGrow__BinaryThreshold__hxx__ + +#include + +// ------------------------------------------------------------------------- +template< class _TValue > +void fpa::Functors::RegionGrow::BinaryThreshold< _TValue >:: +ThresholdAbove( const TValue& a ) +{ + this->SetLowerThreshold( a ); + this->SetUpperThreshold( std::numeric_limits< _TValue >::max( ) ); +} + +// ------------------------------------------------------------------------- +template< class _TValue > +void fpa::Functors::RegionGrow::BinaryThreshold< _TValue >:: +ThresholdBetween( const TValue& a, const TValue& b ) +{ + this->SetLowerThreshold( ( a < b )? a: b ); + this->SetUpperThreshold( ( b < a )? a: b ); +} + +// ------------------------------------------------------------------------- +template< class _TValue > +void fpa::Functors::RegionGrow::BinaryThreshold< _TValue >:: +ThresholdBelow( const TValue& a ) +{ + if( std::numeric_limits< _TValue >::is_integer ) + this->SetLowerThreshold( std::numeric_limits< _TValue >::min( ) ); + else + this->SetLowerThreshold( -std::numeric_limits< _TValue >::max( ) ); + this->SetUpperThreshold( a ); +} + +// ------------------------------------------------------------------------- +template< class _TValue > +bool fpa::Functors::RegionGrow::BinaryThreshold< _TValue >:: +Evaluate( const TValue& v ) const +{ + if( this->m_Strict ) + return( this->m_LowerThreshold < v && v < this->m_UpperThreshold ); + else + return( this->m_LowerThreshold <= v && v <= this->m_UpperThreshold ); +} + +// ------------------------------------------------------------------------- +template< class _TValue > +fpa::Functors::RegionGrow::BinaryThreshold< _TValue >:: +BinaryThreshold( ) + : Superclass( ), + m_Strict( true ) +{ + this->m_UpperThreshold = std::numeric_limits< _TValue >::max( ); + if( std::numeric_limits< _TValue >::is_integer ) + this->m_LowerThreshold = std::numeric_limits< _TValue >::min( ); + else + this->m_LowerThreshold = -this->m_UpperThreshold; +} + +// ------------------------------------------------------------------------- +template< class _TValue > +fpa::Functors::RegionGrow::BinaryThreshold< _TValue >:: +~BinaryThreshold( ) +{ +} + +#endif // __fpa__Functors__RegionGrow__BinaryThreshold__hxx__ +// eof - $RCSfile$