]> Creatis software - FrontAlgorithms.git/blobdiff - lib/fpa/Functors/RegionGrow/BinaryThreshold.hxx
...
[FrontAlgorithms.git] / lib / fpa / Functors / RegionGrow / BinaryThreshold.hxx
diff --git a/lib/fpa/Functors/RegionGrow/BinaryThreshold.hxx b/lib/fpa/Functors/RegionGrow/BinaryThreshold.hxx
new file mode 100644 (file)
index 0000000..f7ad48f
--- /dev/null
@@ -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 <limits>
+
+// -------------------------------------------------------------------------
+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$