]> Creatis software - cpPlugins.git/blobdiff - lib/cpExtensions/Algorithms/UnaryThresholdImageFilter.h
yet another refactoring
[cpPlugins.git] / lib / cpExtensions / Algorithms / UnaryThresholdImageFilter.h
diff --git a/lib/cpExtensions/Algorithms/UnaryThresholdImageFilter.h b/lib/cpExtensions/Algorithms/UnaryThresholdImageFilter.h
new file mode 100644 (file)
index 0000000..7de8b66
--- /dev/null
@@ -0,0 +1,102 @@
+// -------------------------------------------------------------------------
+// @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co)
+// -------------------------------------------------------------------------
+
+#ifndef __CPEXTENSIONS__ALGORITHMS__UNARYTHRESHOLDIMAGEFILTER__H__
+#define __CPEXTENSIONS__ALGORITHMS__UNARYTHRESHOLDIMAGEFILTER__H__
+
+#include <itkUnaryFunctorImageFilter.h>
+
+namespace cpExtensions
+{
+  namespace Algorithms
+  {
+    namespace Functor
+    {
+      /**
+       */
+      template< typename _TInput >
+      class UnaryThreshold
+      {
+      public:
+        UnaryThreshold( );
+        virtual ~UnaryThreshold( );
+
+        const _TInput& GetThreshold( ) const;
+        const _TInput& GetInsideValue( ) const;
+        const _TInput& GetOutsideValue( ) const;
+        const bool& GetStrict( ) const;
+
+        void StrictOn( );
+        void StrictOff( );
+        void SetStrict( bool s );
+        void SetThreshold( const _TInput& thresh );
+        void SetInsideValue( const _TInput& value );
+        void SetOutsideValue( const _TInput& value );
+        bool operator!=( const UnaryThreshold& other ) const;
+        bool operator==( const UnaryThreshold& other ) const;
+        _TInput operator()( const _TInput& A ) const;
+
+      private:
+        _TInput m_Threshold;
+        _TInput m_InsideValue;
+        _TInput m_OutsideValue;
+        bool    m_Strict;
+      };
+    }
+
+    /**
+     */
+    template< class _TImage >
+    class UnaryThresholdImageFilter
+      : public itk::UnaryFunctorImageFilter< _TImage, _TImage, cpExtensions::Algorithms::Functor::UnaryThreshold< typename _TImage::PixelType > >
+    {
+    public:
+      // Basic types
+      typedef typename _TImage::PixelType TPixel;
+      typedef cpExtensions::Algorithms::Functor::UnaryThreshold< TPixel > TFunctor;
+      typedef itk::UnaryFunctorImageFilter< _TImage, _TImage, TFunctor > Superclass;
+      typedef UnaryThresholdImageFilter       Self;
+      typedef itk::SmartPointer< Self >       Pointer;
+      typedef itk::SmartPointer< const Self > ConstPointer;
+
+      typedef _TImage TImage;
+
+    public:
+      itkNewMacro( Self );
+      itkTypeMacro( UnaryThresholdImageFilter, itkUnaryFunctorImageFilter );
+
+    public:
+      const TPixel& GetThreshold( ) const;
+      const TPixel& GetInsideValue( ) const;
+      const TPixel& GetOutsideValue( ) const;
+      const bool&    GetStrict( ) const;
+
+      void StrictOn( );
+      void StrictOff( );
+      void SetStrict( bool s );
+      void SetThreshold( const TPixel& thresh );
+      void SetInsideValue( const TPixel& value );
+      void SetOutsideValue( const TPixel& value );
+      
+    protected:
+      UnaryThresholdImageFilter( );
+      virtual ~UnaryThresholdImageFilter( );
+
+    private:
+      // Purposely not implemented
+      UnaryThresholdImageFilter( const Self& );
+      void operator=( const Self& );
+    };
+
+  } // ecapseman
+
+} // ecapseman
+
+#ifndef ITK_MANUAL_INSTANTIATION
+#  include <cpExtensions/Algorithms/UnaryThresholdImageFilter.hxx>
+#endif // ITK_MANUAL_INSTANTIATION
+
+#endif // __CPEXTENSIONS__ALGORITHMS__UNARYTHRESHOLDIMAGEFILTER__H__
+
+// eof - $RCSfile$