ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
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 * https://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
22#include "rtkConfiguration.h"
24#include "itkConceptChecking.h"
26
27namespace rtk
28{
29
40
41namespace Functor
42{
43
44template <class TInput, class TOutput>
45class ITK_TEMPLATE_EXPORT SoftThreshold
46{
47public:
49 ~SoftThreshold() = default;
50
51 void
52 SetThreshold(const TInput & thresh)
53 {
54 m_Threshold = thresh;
55 }
56
57 bool
58 operator!=(const SoftThreshold & other) const
59 {
60 return static_cast<bool>(m_Threshold != other.m_Threshold);
61 }
62 bool
63 operator==(const SoftThreshold & other) const
64 {
65 return !(*this != other);
66 }
67
68 TOutput
69 operator()(const TInput & A) const
70 {
71 return (itk::Math::sgn(A) * std::max((TInput)std::abs(A) - m_Threshold, (TInput)0.0));
72 }
73
74private:
76};
77} // namespace Functor
78
79template <class TInputImage, class TOutputImage>
80class ITK_TEMPLATE_EXPORT SoftThresholdImageFilter
82 TInputImage,
83 TOutputImage,
84 Functor::SoftThreshold<typename TInputImage::PixelType, typename TOutputImage::PixelType>>
85{
86public:
87 ITK_DISALLOW_COPY_AND_MOVE(SoftThresholdImageFilter);
88
92 TInputImage,
93 TOutputImage,
97
99 itkNewMacro(Self);
100
102 itkOverrideGetNameOfClassMacro(SoftThresholdImageFilter);
103
105 using InputPixelType = typename TInputImage::PixelType;
106 using OutputPixelType = typename TOutputImage::PixelType;
107
110
112 virtual void
114
121
122protected:
124 ~SoftThresholdImageFilter() override = default;
125};
126
127} // end namespace rtk
128
129#ifndef ITK_MANUAL_INSTANTIATION
130# include "rtkSoftThresholdImageFilter.hxx"
131#endif
132
133#endif
static const T ITKCommon_EXPORT Zero
Decorates any "simple" data type (data types without smart pointers) with a DataObject API.
Implements transparent reference counting.
Implements pixel-wise generic operation on one image.
TOutput operator()(const TInput &A) const
void SetThreshold(const TInput &thresh)
bool operator!=(const SoftThreshold &other) const
bool operator==(const SoftThreshold &other) const
virtual void SetThreshold(InputPixelType threshold)
itk::UnaryFunctorImageFilter< InputImageType, InputImageType, Functor::SoftThreshold< typename InputImageType::PixelType, typename InputImageType::PixelType > > Superclass
itk::SimpleDataObjectDecorator< InputPixelType > InputPixelObjectType
~SoftThresholdImageFilter() override=default
#define itkConceptMacro(name, conceptType)
Compile-time check that a template argument satisfies an itk::Concept.
constexpr int sgn(T x)
Sign of a value: -1, 0, or +1.
Definition itkMath.h:872