]> Creatis software - cpPlugins.git/blobdiff - lib/cpExtensions/Algorithms/UnaryThresholdImageFilter.hxx
Architecture updated.
[cpPlugins.git] / lib / cpExtensions / Algorithms / UnaryThresholdImageFilter.hxx
diff --git a/lib/cpExtensions/Algorithms/UnaryThresholdImageFilter.hxx b/lib/cpExtensions/Algorithms/UnaryThresholdImageFilter.hxx
new file mode 100644 (file)
index 0000000..ff85edd
--- /dev/null
@@ -0,0 +1,245 @@
+// -------------------------------------------------------------------------
+// @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co)
+// -------------------------------------------------------------------------
+
+#ifndef __CPEXTENSIONS__ALGORITHMS__UNARYTHRESHOLDIMAGEFILTER__HXX__
+#define __CPEXTENSIONS__ALGORITHMS__UNARYTHRESHOLDIMAGEFILTER__HXX__
+
+// -------------------------------------------------------------------------
+template< typename _TInput >
+cpExtensions::Algorithms::Functor::UnaryThreshold< _TInput >::
+UnaryThreshold( )
+  : m_Strict( false )
+{
+  this->m_Threshold    = itk::NumericTraits< _TInput >::NonpositiveMin( );
+  this->m_OutsideValue = itk::NumericTraits< _TInput >::ZeroValue( );
+  this->m_InsideValue  = itk::NumericTraits< _TInput >::max( );
+}
+
+// -------------------------------------------------------------------------
+template< typename _TInput >
+cpExtensions::Algorithms::Functor::UnaryThreshold< _TInput >::
+~UnaryThreshold( )
+{
+}
+
+// -------------------------------------------------------------------------
+template< typename _TInput >
+const _TInput& cpExtensions::Algorithms::Functor::UnaryThreshold< _TInput >::
+GetThreshold( ) const
+{
+  return( this->m_Threshold );
+}
+
+// -------------------------------------------------------------------------
+template< typename _TInput >
+const _TInput& cpExtensions::Algorithms::Functor::UnaryThreshold< _TInput >::
+GetInsideValue( ) const
+{
+  return( this->m_InsideValue );
+}
+
+// -------------------------------------------------------------------------
+template< typename _TInput >
+const _TInput& cpExtensions::Algorithms::Functor::UnaryThreshold< _TInput >::
+GetOutsideValue( ) const
+{
+  return( this->m_OutsideValue );
+}
+
+// -------------------------------------------------------------------------
+template< typename _TInput >
+const bool& cpExtensions::Algorithms::Functor::UnaryThreshold< _TInput >::
+GetStrict( ) const
+{
+  return( this->m_Strict );
+}
+
+// -------------------------------------------------------------------------
+template< typename _TInput >
+void cpExtensions::Algorithms::Functor::UnaryThreshold< _TInput >::
+StrictOn( )
+{
+  this->SetStrict( true );
+}
+
+// -------------------------------------------------------------------------
+template< typename _TInput >
+void cpExtensions::Algorithms::Functor::UnaryThreshold< _TInput >::
+StrictOff( )
+{
+  this->SetStrict( false );
+}
+
+// -------------------------------------------------------------------------
+template< typename _TInput >
+void cpExtensions::Algorithms::Functor::UnaryThreshold< _TInput >::
+SetStrict( bool s )
+{
+  this->m_Strict = s;
+}
+
+// -------------------------------------------------------------------------
+template< typename _TInput >
+void cpExtensions::Algorithms::Functor::UnaryThreshold< _TInput >::
+SetThreshold( const _TInput& thresh )
+{
+  this->m_Threshold = thresh;
+}
+
+// -------------------------------------------------------------------------
+template< typename _TInput >
+void cpExtensions::Algorithms::Functor::UnaryThreshold< _TInput >::
+SetInsideValue( const _TInput& value )
+{
+  this->m_InsideValue = value;
+}
+
+// -------------------------------------------------------------------------
+template< typename _TInput >
+void cpExtensions::Algorithms::Functor::UnaryThreshold< _TInput >::
+SetOutsideValue( const _TInput& value )
+{
+  this->m_OutsideValue = value;
+}
+
+// -------------------------------------------------------------------------
+template< typename _TInput >
+bool cpExtensions::Algorithms::Functor::UnaryThreshold< _TInput >::
+operator!=( const UnaryThreshold& other ) const
+{
+  return(
+    this->m_Threshold != other.m_Threshold ||
+    itk::Math::NotExactlyEquals( this->m_InsideValue, other.m_InsideValue ) ||
+    itk::Math::NotExactlyEquals( this->m_OutsideValue, other.m_OutsideValue )
+    );
+}
+
+// -------------------------------------------------------------------------
+template< typename _TInput >
+bool cpExtensions::Algorithms::Functor::UnaryThreshold< _TInput >::
+operator==( const UnaryThreshold& other ) const
+{
+  return( !( *this != other ) );
+}
+
+// -------------------------------------------------------------------------
+template< typename _TInput >
+_TInput cpExtensions::Algorithms::Functor::UnaryThreshold< _TInput >::
+operator()( const _TInput& A ) const
+{
+  if( this->m_Strict )
+  {
+    if( this->m_Threshold < A  )
+      return( this->m_InsideValue );
+    return( this->m_OutsideValue );
+  }
+  else
+  {
+    if( this->m_Threshold <= A  )
+      return( this->m_InsideValue );
+    return( this->m_OutsideValue );
+
+  } // fi
+}
+
+// -------------------------------------------------------------------------
+template< class _TImage >
+const typename cpExtensions::Algorithms::UnaryThresholdImageFilter< _TImage >::
+TPixel& cpExtensions::Algorithms::UnaryThresholdImageFilter< _TImage >::
+GetThreshold( ) const
+{
+  return( this->GetFunctor( ).GetThreshold( ) );
+}
+
+// -------------------------------------------------------------------------
+template< class _TImage >
+const typename cpExtensions::Algorithms::UnaryThresholdImageFilter< _TImage >::
+TPixel& cpExtensions::Algorithms::UnaryThresholdImageFilter< _TImage >::
+GetInsideValue( ) const
+{
+  return( this->GetFunctor( ).GetInsideValue( ) );
+}
+
+// -------------------------------------------------------------------------
+template< class _TImage >
+const typename cpExtensions::Algorithms::UnaryThresholdImageFilter< _TImage >::
+TPixel& cpExtensions::Algorithms::UnaryThresholdImageFilter< _TImage >::
+GetOutsideValue( ) const
+{
+  return( this->GetFunctor( ).GetOutsideValue( ) );
+}
+
+// -------------------------------------------------------------------------
+template< class _TImage >
+const bool& cpExtensions::Algorithms::UnaryThresholdImageFilter< _TImage >::
+GetStrict( ) const
+{
+  return( this->GetFunctor( ).GetStrict( ) );
+}
+
+// -------------------------------------------------------------------------
+template< class _TImage >
+void cpExtensions::Algorithms::UnaryThresholdImageFilter< _TImage >::
+StrictOn( )
+{
+  this->GetFunctor( ).SetStrict( true );
+}
+
+// -------------------------------------------------------------------------
+template< class _TImage >
+void cpExtensions::Algorithms::UnaryThresholdImageFilter< _TImage >::
+StrictOff( )
+{
+  this->GetFunctor( ).SetStrict( false );
+}
+
+// -------------------------------------------------------------------------
+template< class _TImage >
+void cpExtensions::Algorithms::UnaryThresholdImageFilter< _TImage >::
+SetStrict( bool s )
+{
+  this->GetFunctor( ).SetStrict( s );
+}
+
+// -------------------------------------------------------------------------
+template< class _TImage >
+void cpExtensions::Algorithms::UnaryThresholdImageFilter< _TImage >::
+SetThreshold( const TPixel& thresh )
+{
+  this->GetFunctor( ).SetThreshold( thresh );
+}
+
+// -------------------------------------------------------------------------
+template< class _TImage >
+void cpExtensions::Algorithms::UnaryThresholdImageFilter< _TImage >::
+SetInsideValue( const TPixel& value )
+{
+  this->GetFunctor( ).SetInsideValue( value );
+}
+
+// -------------------------------------------------------------------------
+template< class _TImage >
+void cpExtensions::Algorithms::UnaryThresholdImageFilter< _TImage >::
+SetOutsideValue( const TPixel& value )
+{
+  this->GetFunctor( ).SetOutsideValue( value );
+}
+
+// -------------------------------------------------------------------------
+template< class _TImage >
+cpExtensions::Algorithms::UnaryThresholdImageFilter< _TImage >::
+UnaryThresholdImageFilter( )
+{
+}
+
+// -------------------------------------------------------------------------
+template< class _TImage >
+cpExtensions::Algorithms::UnaryThresholdImageFilter< _TImage >::
+~UnaryThresholdImageFilter( )
+{
+}
+
+#endif // __CPEXTENSIONS__ALGORITHMS__UNARYTHRESHOLDIMAGEFILTER__HXX__
+
+// eof - $RCSfile$