ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
itkBinaryThresholdImageFilter.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright NumFOCUS
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#ifndef itkBinaryThresholdImageFilter_h
19#define itkBinaryThresholdImageFilter_h
20
22#include "itkConceptChecking.h"
24
25namespace itk
26{
64namespace Functor
65{
66template <typename TInput, typename TOutput>
67class ITK_TEMPLATE_EXPORT BinaryThreshold
68{
69public:
71 : m_LowerThreshold(NumericTraits<TInput>::NonpositiveMin())
72 , m_UpperThreshold(NumericTraits<TInput>::max())
73 , m_InsideValue(NumericTraits<TOutput>::max())
74 , m_OutsideValue(TOutput{})
75 {}
76
77 ~BinaryThreshold() = default;
78
79 void
80 SetLowerThreshold(const TInput & thresh)
81 {
82 m_LowerThreshold = thresh;
83 }
84 void
85 SetUpperThreshold(const TInput & thresh)
86 {
87 m_UpperThreshold = thresh;
88 }
89 void
90 SetInsideValue(const TOutput & value)
91 {
92 m_InsideValue = value;
93 }
94 void
95 SetOutsideValue(const TOutput & value)
96 {
97 m_OutsideValue = value;
98 }
99
100
101 bool
108
110
111 inline TOutput
112 operator()(const TInput & A) const
113 {
114 if (m_LowerThreshold <= A && A <= m_UpperThreshold)
115 {
116 return m_InsideValue;
117 }
118 return m_OutsideValue;
119 }
120
121private:
126};
127} // namespace Functor
128
129template <typename TInputImage, typename TOutputImage>
130class ITK_TEMPLATE_EXPORT BinaryThresholdImageFilter
132 TInputImage,
133 TOutputImage,
134 Functor::BinaryThreshold<typename TInputImage::PixelType, typename TOutputImage::PixelType>>
135{
136public:
137 ITK_DISALLOW_COPY_AND_MOVE(BinaryThresholdImageFilter);
138
142 TInputImage,
143 TOutputImage,
147
149 itkNewMacro(Self);
150
152 itkOverrideGetNameOfClassMacro(BinaryThresholdImageFilter);
153
155 using InputPixelType = typename TInputImage::PixelType;
156 using OutputPixelType = typename TOutputImage::PixelType;
157
160
163 itkSetMacro(OutsideValue, OutputPixelType);
164
166 itkGetConstReferenceMacro(OutsideValue, OutputPixelType);
167
170 itkSetMacro(InsideValue, OutputPixelType);
171
173 itkGetConstReferenceMacro(InsideValue, OutputPixelType);
174
179 virtual void
181
182 virtual void
184
185 virtual void
187
188 virtual void
190
192 virtual InputPixelType
194
195 virtual InputPixelObjectType *
197
198 virtual const InputPixelObjectType *
200
201 virtual InputPixelType
203
204 virtual InputPixelObjectType *
206
207 virtual const InputPixelObjectType *
209
210 itkConceptMacro(OutputEqualityComparableCheck, (Concept::EqualityComparable<OutputPixelType>));
211 itkConceptMacro(InputPixelTypeComparable, (Concept::Comparable<InputPixelType>));
212 itkConceptMacro(InputOStreamWritableCheck, (Concept::OStreamWritable<InputPixelType>));
213 itkConceptMacro(OutputOStreamWritableCheck, (Concept::OStreamWritable<OutputPixelType>));
214
215protected:
217 ~BinaryThresholdImageFilter() override = default;
218 void
219 PrintSelf(std::ostream & os, Indent indent) const override;
220
223 void
225
226private:
229};
230} // end namespace itk
231
232#ifndef ITK_MANUAL_INSTANTIATION
233# include "itkBinaryThresholdImageFilter.hxx"
234#endif
235
236#endif
typename TInputImage::PixelType InputPixelType
virtual const InputPixelObjectType * GetLowerThresholdInput() const
UnaryFunctorImageFilter< TInputImage, TOutputImage, Functor::BinaryThreshold< typename TInputImage::PixelType, typename TOutputImage::PixelType > > Superclass
void BeforeThreadedGenerateData() override
virtual InputPixelType GetLowerThreshold() const
virtual InputPixelObjectType * GetUpperThresholdInput()
virtual const InputPixelObjectType * GetUpperThresholdInput() const
~BinaryThresholdImageFilter() override=default
virtual void SetUpperThreshold(const InputPixelType threshold)
virtual void SetLowerThreshold(const InputPixelType threshold)
typename TOutputImage::PixelType OutputPixelType
virtual void SetLowerThresholdInput(const InputPixelObjectType *)
virtual void SetUpperThresholdInput(const InputPixelObjectType *)
virtual InputPixelObjectType * GetLowerThresholdInput()
SimpleDataObjectDecorator< InputPixelType > InputPixelObjectType
virtual InputPixelType GetUpperThreshold() const
void PrintSelf(std::ostream &os, Indent indent) const override
void SetUpperThreshold(const TInput &thresh)
void SetLowerThreshold(const TInput &thresh)
ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(BinaryThreshold)
bool operator==(const BinaryThreshold &other) const
TOutput operator()(const TInput &A) const
Control indentation during Print() invocation.
Definition itkIndent.h:50
Define additional traits for native types such as int or float.
Decorates any "simple" data type (data types without smart pointers) with a DataObject API.
Implements transparent reference counting.
#define itkConceptMacro(name, concept)
bool ExactlyEquals(const TInput1 &x1, const TInput2 &x2)
Return the result of an exact comparison between two scalar values of potentially different types.
Definition itkMath.h:716
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....