]> Creatis software - cpPlugins.git/blob - lib/cpExtensions/Algorithms/UnaryThresholdImageFilter.hxx
...
[cpPlugins.git] / lib / cpExtensions / Algorithms / UnaryThresholdImageFilter.hxx
1 // -------------------------------------------------------------------------
2 // @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co)
3 // -------------------------------------------------------------------------
4
5 #ifndef __CPEXTENSIONS__ALGORITHMS__UNARYTHRESHOLDIMAGEFILTER__HXX__
6 #define __CPEXTENSIONS__ALGORITHMS__UNARYTHRESHOLDIMAGEFILTER__HXX__
7
8 // -------------------------------------------------------------------------
9 template< typename _TInput >
10 cpExtensions::Algorithms::Functor::UnaryThreshold< _TInput >::
11 UnaryThreshold( )
12   : m_Strict( false )
13 {
14   this->m_Threshold    = itk::NumericTraits< _TInput >::NonpositiveMin( );
15   this->m_OutsideValue = itk::NumericTraits< _TInput >::ZeroValue( );
16   this->m_InsideValue  = itk::NumericTraits< _TInput >::max( );
17 }
18
19 // -------------------------------------------------------------------------
20 template< typename _TInput >
21 cpExtensions::Algorithms::Functor::UnaryThreshold< _TInput >::
22 ~UnaryThreshold( )
23 {
24 }
25
26 // -------------------------------------------------------------------------
27 template< typename _TInput >
28 const _TInput& cpExtensions::Algorithms::Functor::UnaryThreshold< _TInput >::
29 GetThreshold( ) const
30 {
31   return( this->m_Threshold );
32 }
33
34 // -------------------------------------------------------------------------
35 template< typename _TInput >
36 const _TInput& cpExtensions::Algorithms::Functor::UnaryThreshold< _TInput >::
37 GetInsideValue( ) const
38 {
39   return( this->m_InsideValue );
40 }
41
42 // -------------------------------------------------------------------------
43 template< typename _TInput >
44 const _TInput& cpExtensions::Algorithms::Functor::UnaryThreshold< _TInput >::
45 GetOutsideValue( ) const
46 {
47   return( this->m_OutsideValue );
48 }
49
50 // -------------------------------------------------------------------------
51 template< typename _TInput >
52 const bool& cpExtensions::Algorithms::Functor::UnaryThreshold< _TInput >::
53 GetStrict( ) const
54 {
55   return( this->m_Strict );
56 }
57
58 // -------------------------------------------------------------------------
59 template< typename _TInput >
60 void cpExtensions::Algorithms::Functor::UnaryThreshold< _TInput >::
61 StrictOn( )
62 {
63   this->SetStrict( true );
64 }
65
66 // -------------------------------------------------------------------------
67 template< typename _TInput >
68 void cpExtensions::Algorithms::Functor::UnaryThreshold< _TInput >::
69 StrictOff( )
70 {
71   this->SetStrict( false );
72 }
73
74 // -------------------------------------------------------------------------
75 template< typename _TInput >
76 void cpExtensions::Algorithms::Functor::UnaryThreshold< _TInput >::
77 SetStrict( bool s )
78 {
79   this->m_Strict = s;
80 }
81
82 // -------------------------------------------------------------------------
83 template< typename _TInput >
84 void cpExtensions::Algorithms::Functor::UnaryThreshold< _TInput >::
85 SetThreshold( const _TInput& thresh )
86 {
87   this->m_Threshold = thresh;
88 }
89
90 // -------------------------------------------------------------------------
91 template< typename _TInput >
92 void cpExtensions::Algorithms::Functor::UnaryThreshold< _TInput >::
93 SetInsideValue( const _TInput& value )
94 {
95   this->m_InsideValue = value;
96 }
97
98 // -------------------------------------------------------------------------
99 template< typename _TInput >
100 void cpExtensions::Algorithms::Functor::UnaryThreshold< _TInput >::
101 SetOutsideValue( const _TInput& value )
102 {
103   this->m_OutsideValue = value;
104 }
105
106 // -------------------------------------------------------------------------
107 template< typename _TInput >
108 bool cpExtensions::Algorithms::Functor::UnaryThreshold< _TInput >::
109 operator!=( const UnaryThreshold& other ) const
110 {
111   return(
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 )
115     );
116 }
117
118 // -------------------------------------------------------------------------
119 template< typename _TInput >
120 bool cpExtensions::Algorithms::Functor::UnaryThreshold< _TInput >::
121 operator==( const UnaryThreshold& other ) const
122 {
123   return( !( *this != other ) );
124 }
125
126 // -------------------------------------------------------------------------
127 template< typename _TInput >
128 _TInput cpExtensions::Algorithms::Functor::UnaryThreshold< _TInput >::
129 operator()( const _TInput& A ) const
130 {
131   if( this->m_Strict )
132   {
133     if( this->m_Threshold < A  )
134       return( this->m_InsideValue );
135     return( this->m_OutsideValue );
136   }
137   else
138   {
139     if( this->m_Threshold <= A  )
140       return( this->m_InsideValue );
141     return( this->m_OutsideValue );
142
143   } // fi
144 }
145
146 // -------------------------------------------------------------------------
147 template< class _TImage >
148 const typename cpExtensions::Algorithms::UnaryThresholdImageFilter< _TImage >::
149 TPixel& cpExtensions::Algorithms::UnaryThresholdImageFilter< _TImage >::
150 GetThreshold( ) const
151 {
152   return( this->GetFunctor( ).GetThreshold( ) );
153 }
154
155 // -------------------------------------------------------------------------
156 template< class _TImage >
157 const typename cpExtensions::Algorithms::UnaryThresholdImageFilter< _TImage >::
158 TPixel& cpExtensions::Algorithms::UnaryThresholdImageFilter< _TImage >::
159 GetInsideValue( ) const
160 {
161   return( this->GetFunctor( ).GetInsideValue( ) );
162 }
163
164 // -------------------------------------------------------------------------
165 template< class _TImage >
166 const typename cpExtensions::Algorithms::UnaryThresholdImageFilter< _TImage >::
167 TPixel& cpExtensions::Algorithms::UnaryThresholdImageFilter< _TImage >::
168 GetOutsideValue( ) const
169 {
170   return( this->GetFunctor( ).GetOutsideValue( ) );
171 }
172
173 // -------------------------------------------------------------------------
174 template< class _TImage >
175 const bool& cpExtensions::Algorithms::UnaryThresholdImageFilter< _TImage >::
176 GetStrict( ) const
177 {
178   return( this->GetFunctor( ).GetStrict( ) );
179 }
180
181 // -------------------------------------------------------------------------
182 template< class _TImage >
183 void cpExtensions::Algorithms::UnaryThresholdImageFilter< _TImage >::
184 StrictOn( )
185 {
186   this->GetFunctor( ).SetStrict( true );
187 }
188
189 // -------------------------------------------------------------------------
190 template< class _TImage >
191 void cpExtensions::Algorithms::UnaryThresholdImageFilter< _TImage >::
192 StrictOff( )
193 {
194   this->GetFunctor( ).SetStrict( false );
195 }
196
197 // -------------------------------------------------------------------------
198 template< class _TImage >
199 void cpExtensions::Algorithms::UnaryThresholdImageFilter< _TImage >::
200 SetStrict( bool s )
201 {
202   this->GetFunctor( ).SetStrict( s );
203 }
204
205 // -------------------------------------------------------------------------
206 template< class _TImage >
207 void cpExtensions::Algorithms::UnaryThresholdImageFilter< _TImage >::
208 SetThreshold( const TPixel& thresh )
209 {
210   this->GetFunctor( ).SetThreshold( thresh );
211 }
212
213 // -------------------------------------------------------------------------
214 template< class _TImage >
215 void cpExtensions::Algorithms::UnaryThresholdImageFilter< _TImage >::
216 SetInsideValue( const TPixel& value )
217 {
218   this->GetFunctor( ).SetInsideValue( value );
219 }
220
221 // -------------------------------------------------------------------------
222 template< class _TImage >
223 void cpExtensions::Algorithms::UnaryThresholdImageFilter< _TImage >::
224 SetOutsideValue( const TPixel& value )
225 {
226   this->GetFunctor( ).SetOutsideValue( value );
227 }
228
229 // -------------------------------------------------------------------------
230 template< class _TImage >
231 cpExtensions::Algorithms::UnaryThresholdImageFilter< _TImage >::
232 UnaryThresholdImageFilter( )
233 {
234 }
235
236 // -------------------------------------------------------------------------
237 template< class _TImage >
238 cpExtensions::Algorithms::UnaryThresholdImageFilter< _TImage >::
239 ~UnaryThresholdImageFilter( )
240 {
241 }
242
243 #endif // __CPEXTENSIONS__ALGORITHMS__UNARYTHRESHOLDIMAGEFILTER__HXX__
244
245 // eof - $RCSfile$