1 // -------------------------------------------------------------------------
2 // @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co)
3 // -------------------------------------------------------------------------
5 #ifndef __CPEXTENSIONS__ALGORITHMS__UNARYTHRESHOLDIMAGEFILTER__HXX__
6 #define __CPEXTENSIONS__ALGORITHMS__UNARYTHRESHOLDIMAGEFILTER__HXX__
8 // -------------------------------------------------------------------------
9 template< typename _TInput >
10 cpExtensions::Algorithms::Functor::UnaryThreshold< _TInput >::
14 this->m_Threshold = itk::NumericTraits< _TInput >::NonpositiveMin( );
15 this->m_OutsideValue = itk::NumericTraits< _TInput >::ZeroValue( );
16 this->m_InsideValue = itk::NumericTraits< _TInput >::max( );
19 // -------------------------------------------------------------------------
20 template< typename _TInput >
21 cpExtensions::Algorithms::Functor::UnaryThreshold< _TInput >::
26 // -------------------------------------------------------------------------
27 template< typename _TInput >
28 const _TInput& cpExtensions::Algorithms::Functor::UnaryThreshold< _TInput >::
31 return( this->m_Threshold );
34 // -------------------------------------------------------------------------
35 template< typename _TInput >
36 const _TInput& cpExtensions::Algorithms::Functor::UnaryThreshold< _TInput >::
37 GetInsideValue( ) const
39 return( this->m_InsideValue );
42 // -------------------------------------------------------------------------
43 template< typename _TInput >
44 const _TInput& cpExtensions::Algorithms::Functor::UnaryThreshold< _TInput >::
45 GetOutsideValue( ) const
47 return( this->m_OutsideValue );
50 // -------------------------------------------------------------------------
51 template< typename _TInput >
52 const bool& cpExtensions::Algorithms::Functor::UnaryThreshold< _TInput >::
55 return( this->m_Strict );
58 // -------------------------------------------------------------------------
59 template< typename _TInput >
60 void cpExtensions::Algorithms::Functor::UnaryThreshold< _TInput >::
63 this->SetStrict( true );
66 // -------------------------------------------------------------------------
67 template< typename _TInput >
68 void cpExtensions::Algorithms::Functor::UnaryThreshold< _TInput >::
71 this->SetStrict( false );
74 // -------------------------------------------------------------------------
75 template< typename _TInput >
76 void cpExtensions::Algorithms::Functor::UnaryThreshold< _TInput >::
82 // -------------------------------------------------------------------------
83 template< typename _TInput >
84 void cpExtensions::Algorithms::Functor::UnaryThreshold< _TInput >::
85 SetThreshold( const _TInput& thresh )
87 this->m_Threshold = thresh;
90 // -------------------------------------------------------------------------
91 template< typename _TInput >
92 void cpExtensions::Algorithms::Functor::UnaryThreshold< _TInput >::
93 SetInsideValue( const _TInput& value )
95 this->m_InsideValue = value;
98 // -------------------------------------------------------------------------
99 template< typename _TInput >
100 void cpExtensions::Algorithms::Functor::UnaryThreshold< _TInput >::
101 SetOutsideValue( const _TInput& value )
103 this->m_OutsideValue = value;
106 // -------------------------------------------------------------------------
107 template< typename _TInput >
108 bool cpExtensions::Algorithms::Functor::UnaryThreshold< _TInput >::
109 operator!=( const UnaryThreshold& other ) const
112 this->m_Threshold != other.m_Threshold ||
113 itk::Math::NotExactlyEquals( this->m_InsideValue, other.m_InsideValue ) ||
114 itk::Math::NotExactlyEquals( this->m_OutsideValue, other.m_OutsideValue )
118 // -------------------------------------------------------------------------
119 template< typename _TInput >
120 bool cpExtensions::Algorithms::Functor::UnaryThreshold< _TInput >::
121 operator==( const UnaryThreshold& other ) const
123 return( !( *this != other ) );
126 // -------------------------------------------------------------------------
127 template< typename _TInput >
128 _TInput cpExtensions::Algorithms::Functor::UnaryThreshold< _TInput >::
129 operator()( const _TInput& A ) const
133 if( this->m_Threshold < A )
134 return( this->m_InsideValue );
135 return( this->m_OutsideValue );
139 if( this->m_Threshold <= A )
140 return( this->m_InsideValue );
141 return( this->m_OutsideValue );
146 // -------------------------------------------------------------------------
147 template< class _TImage >
148 const typename cpExtensions::Algorithms::UnaryThresholdImageFilter< _TImage >::
149 TPixel& cpExtensions::Algorithms::UnaryThresholdImageFilter< _TImage >::
150 GetThreshold( ) const
152 return( this->GetFunctor( ).GetThreshold( ) );
155 // -------------------------------------------------------------------------
156 template< class _TImage >
157 const typename cpExtensions::Algorithms::UnaryThresholdImageFilter< _TImage >::
158 TPixel& cpExtensions::Algorithms::UnaryThresholdImageFilter< _TImage >::
159 GetInsideValue( ) const
161 return( this->GetFunctor( ).GetInsideValue( ) );
164 // -------------------------------------------------------------------------
165 template< class _TImage >
166 const typename cpExtensions::Algorithms::UnaryThresholdImageFilter< _TImage >::
167 TPixel& cpExtensions::Algorithms::UnaryThresholdImageFilter< _TImage >::
168 GetOutsideValue( ) const
170 return( this->GetFunctor( ).GetOutsideValue( ) );
173 // -------------------------------------------------------------------------
174 template< class _TImage >
175 const bool& cpExtensions::Algorithms::UnaryThresholdImageFilter< _TImage >::
178 return( this->GetFunctor( ).GetStrict( ) );
181 // -------------------------------------------------------------------------
182 template< class _TImage >
183 void cpExtensions::Algorithms::UnaryThresholdImageFilter< _TImage >::
186 this->GetFunctor( ).SetStrict( true );
189 // -------------------------------------------------------------------------
190 template< class _TImage >
191 void cpExtensions::Algorithms::UnaryThresholdImageFilter< _TImage >::
194 this->GetFunctor( ).SetStrict( false );
197 // -------------------------------------------------------------------------
198 template< class _TImage >
199 void cpExtensions::Algorithms::UnaryThresholdImageFilter< _TImage >::
202 this->GetFunctor( ).SetStrict( s );
205 // -------------------------------------------------------------------------
206 template< class _TImage >
207 void cpExtensions::Algorithms::UnaryThresholdImageFilter< _TImage >::
208 SetThreshold( const TPixel& thresh )
210 this->GetFunctor( ).SetThreshold( thresh );
213 // -------------------------------------------------------------------------
214 template< class _TImage >
215 void cpExtensions::Algorithms::UnaryThresholdImageFilter< _TImage >::
216 SetInsideValue( const TPixel& value )
218 this->GetFunctor( ).SetInsideValue( value );
221 // -------------------------------------------------------------------------
222 template< class _TImage >
223 void cpExtensions::Algorithms::UnaryThresholdImageFilter< _TImage >::
224 SetOutsideValue( const TPixel& value )
226 this->GetFunctor( ).SetOutsideValue( value );
229 // -------------------------------------------------------------------------
230 template< class _TImage >
231 cpExtensions::Algorithms::UnaryThresholdImageFilter< _TImage >::
232 UnaryThresholdImageFilter( )
236 // -------------------------------------------------------------------------
237 template< class _TImage >
238 cpExtensions::Algorithms::UnaryThresholdImageFilter< _TImage >::
239 ~UnaryThresholdImageFilter( )
243 #endif // __CPEXTENSIONS__ALGORITHMS__UNARYTHRESHOLDIMAGEFILTER__HXX__