RTK  1.4.0
Reconstruction Toolkit
rtkSoftThresholdImageFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright RTK Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 
19 #ifndef rtkSoftThresholdImageFilter_h
20 #define rtkSoftThresholdImageFilter_h
21 
23 #include "itkConceptChecking.h"
25 
26 namespace rtk
27 {
28 
40 namespace Functor {
41 
42 template< class TInput, class TOutput>
44 {
45 public:
47  {
49  }
51 
52  void SetThreshold( const TInput & thresh )
53  { m_Threshold = thresh; }
54 
55  bool operator!=( const SoftThreshold & other ) const
56  {
57  if( m_Threshold != other.m_Threshold )
58  {
59  return true;
60  }
61  return false;
62  }
63  bool operator==( const SoftThreshold & other ) const
64  {
65  return !(*this != other);
66  }
67 
68  inline TOutput operator()( const TInput & A ) const
69  {
70  return (itk::Math::sgn(A) * std::max((TInput)itk::Math::abs(A) - m_Threshold, (TInput)0.0));
71  }
72 
73 private:
74  TInput m_Threshold;
75 
76 };
77 }
78 
79 template <class TInputImage, class TOutputImage>
80 class ITK_EXPORT SoftThresholdImageFilter :
81  public
82 itk::UnaryFunctorImageFilter<TInputImage,TOutputImage,
83  Functor::SoftThreshold<
84  typename TInputImage::PixelType,
85  typename TOutputImage::PixelType> >
86 {
87 public:
91  <TInputImage,TOutputImage,
92  Functor::SoftThreshold< typename TInputImage::PixelType,
93  typename TOutputImage::PixelType> > Superclass;
96 
98  itkNewMacro(Self);
99 
102 
104  typedef typename TInputImage::PixelType InputPixelType;
105  typedef typename TOutputImage::PixelType OutputPixelType;
106 
109 
111  virtual void SetThreshold(const InputPixelType threshold);
112 
113 #ifdef ITK_USE_CONCEPT_CHECKING
114 
115  itkConceptMacro(OutputEqualityComparableCheck,
117  itkConceptMacro(InputPixelTypeComparable,
119  itkConceptMacro(InputOStreamWritableCheck,
121  itkConceptMacro(OutputOStreamWritableCheck,
123 
125 #endif
126 
127 protected:
129  virtual ~SoftThresholdImageFilter() ITK_OVERRIDE {}
130 
131 private:
132  SoftThresholdImageFilter(const Self&); //purposely not implemented
133  void operator=(const Self&); //purposely not implemented
134 
135 };
136 
137 } // end namespace rtk
138 
139 #ifndef ITK_MANUAL_INSTANTIATION
140 #include "rtkSoftThresholdImageFilter.hxx"
141 #endif
142 
143 #endif
itk::SmartPointer< const Self > ConstPointer
TOutput operator()(const TInput &A) const
bool operator!=(const SoftThreshold &other) const
void SetThreshold(const TInput &thresh)
itk::UnaryFunctorImageFilter< TInputImage, TOutputImage, Functor::SoftThreshold< typename TInputImage::PixelType, typename TOutputImage::PixelType > > Superclass
#define itkConceptMacro(name, concept)
itk::SimpleDataObjectDecorator< InputPixelType > InputPixelObjectType
bool operator==(const SoftThreshold &other) const