]> Creatis software - cpPlugins.git/blob - lib/cpExtensions/Algorithms/UnaryThresholdImageFilter.h
...
[cpPlugins.git] / lib / cpExtensions / Algorithms / UnaryThresholdImageFilter.h
1 // -------------------------------------------------------------------------
2 // @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co)
3 // -------------------------------------------------------------------------
4
5 #ifndef __CPEXTENSIONS__ALGORITHMS__UNARYTHRESHOLDIMAGEFILTER__H__
6 #define __CPEXTENSIONS__ALGORITHMS__UNARYTHRESHOLDIMAGEFILTER__H__
7
8 #include <itkUnaryFunctorImageFilter.h>
9
10 namespace cpExtensions
11 {
12   namespace Algorithms
13   {
14     namespace Functor
15     {
16       /**
17        */
18       template< typename _TInput >
19       class UnaryThreshold
20       {
21       public:
22         UnaryThreshold( );
23         virtual ~UnaryThreshold( );
24
25         const _TInput& GetThreshold( ) const;
26         const _TInput& GetInsideValue( ) const;
27         const _TInput& GetOutsideValue( ) const;
28         const bool& GetStrict( ) const;
29
30         void StrictOn( );
31         void StrictOff( );
32         void SetStrict( bool s );
33         void SetThreshold( const _TInput& thresh );
34         void SetInsideValue( const _TInput& value );
35         void SetOutsideValue( const _TInput& value );
36         bool operator!=( const UnaryThreshold& other ) const;
37         bool operator==( const UnaryThreshold& other ) const;
38         _TInput operator()( const _TInput& A ) const;
39
40       private:
41         _TInput m_Threshold;
42         _TInput m_InsideValue;
43         _TInput m_OutsideValue;
44         bool    m_Strict;
45       };
46     }
47
48     /**
49      */
50     template< class _TImage >
51     class UnaryThresholdImageFilter
52       : public itk::UnaryFunctorImageFilter< _TImage, _TImage, cpExtensions::Algorithms::Functor::UnaryThreshold< typename _TImage::PixelType > >
53     {
54     public:
55       // Basic types
56       typedef typename _TImage::PixelType TPixel;
57       typedef cpExtensions::Algorithms::Functor::UnaryThreshold< TPixel > TFunctor;
58       typedef itk::UnaryFunctorImageFilter< _TImage, _TImage, TFunctor > Superclass;
59       typedef UnaryThresholdImageFilter       Self;
60       typedef itk::SmartPointer< Self >       Pointer;
61       typedef itk::SmartPointer< const Self > ConstPointer;
62
63       typedef _TImage TImage;
64
65     public:
66       itkNewMacro( Self );
67       itkTypeMacro( UnaryThresholdImageFilter, itkUnaryFunctorImageFilter );
68
69     public:
70       const TPixel& GetThreshold( ) const;
71       const TPixel& GetInsideValue( ) const;
72       const TPixel& GetOutsideValue( ) const;
73       const bool&    GetStrict( ) const;
74
75       void StrictOn( );
76       void StrictOff( );
77       void SetStrict( bool s );
78       void SetThreshold( const TPixel& thresh );
79       void SetInsideValue( const TPixel& value );
80       void SetOutsideValue( const TPixel& value );
81       
82     protected:
83       UnaryThresholdImageFilter( );
84       virtual ~UnaryThresholdImageFilter( );
85
86     private:
87       // Purposely not implemented
88       UnaryThresholdImageFilter( const Self& );
89       void operator=( const Self& );
90     };
91
92   } // ecapseman
93
94 } // ecapseman
95
96 #ifndef ITK_MANUAL_INSTANTIATION
97 #  include <cpExtensions/Algorithms/UnaryThresholdImageFilter.hxx>
98 #endif // ITK_MANUAL_INSTANTIATION
99
100 #endif // __CPEXTENSIONS__ALGORITHMS__UNARYTHRESHOLDIMAGEFILTER__H__
101
102 // eof - $RCSfile$