ITK  6.0.0
Insight Toolkit
itkBinaryThresholdProjectionImageFilter.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 itkBinaryThresholdProjectionImageFilter_h
19#define itkBinaryThresholdProjectionImageFilter_h
20
22#include "itkConceptChecking.h"
23
24namespace itk
25{
50namespace Function
51{
52template <typename TInputPixel, typename TOutputPixel>
54{
55public:
58
59 inline void
61 {
62 m_IsForeground = false;
63 }
64
65 inline void
66 operator()(const TInputPixel & input)
67 {
68 if (input >= m_ThresholdValue)
69 {
70 m_IsForeground = true;
71 }
72 }
73
74 inline TOutputPixel
76 {
78 {
79 return m_ForegroundValue;
80 }
81 else
82 {
83 return m_BackgroundValue;
84 }
85 }
86
88
89 TInputPixel m_ThresholdValue;
90 TOutputPixel m_ForegroundValue;
91 TOutputPixel m_BackgroundValue;
92};
93} // end namespace Function
94
95template <typename TInputImage, typename TOutputImage>
97 : public ProjectionImageFilter<
98 TInputImage,
99 TOutputImage,
100 Function::BinaryThresholdAccumulator<typename TInputImage::PixelType, typename TOutputImage::PixelType>>
101{
102public:
103 ITK_DISALLOW_COPY_AND_MOVE(BinaryThresholdProjectionImageFilter);
104
107 TInputImage,
108 TOutputImage,
110
113
115 itkOverrideGetNameOfClassMacro(BinaryThresholdProjectionImageFilter);
116
118 itkNewMacro(Self);
119
121 using InputImageType = TInputImage;
122 using OutputImageType = TOutputImage;
123
125 using InputPixelType = typename InputImageType::PixelType;
126 using OutputPixelType = typename OutputImageType::PixelType;
127
128 using typename Superclass::AccumulatorType;
129
132 itkSetMacro(ForegroundValue, OutputPixelType);
133 itkGetConstMacro(ForegroundValue, OutputPixelType);
138 itkSetMacro(BackgroundValue, OutputPixelType);
139 itkGetConstMacro(BackgroundValue, OutputPixelType);
144 itkSetMacro(ThresholdValue, InputPixelType);
145 itkGetConstMacro(ThresholdValue, InputPixelType);
148#ifdef ITK_USE_CONCEPT_CHECKING
149 // Begin concept checking
150 itkConceptMacro(InputPixelTypeGreaterThanComparable, (Concept::GreaterThanComparable<InputPixelType>));
151 itkConceptMacro(InputHasNumericTraitsCheck, (Concept::HasNumericTraits<InputPixelType>));
152 // End concept checking
153#endif
154
155protected:
157 {
161 }
162
164
165 void
166 PrintSelf(std::ostream & os, Indent indent) const override
167 {
168 Superclass::PrintSelf(os, indent);
169
170 using InputPixelPrintType = typename NumericTraits<InputPixelType>::PrintType;
171
172 os << indent << "ForegroundValue: " << static_cast<InputPixelPrintType>(m_ForegroundValue) << std::endl;
173
174 using OutputPixelPrintType = typename NumericTraits<OutputPixelType>::PrintType;
175
176 os << indent << "BackgroundValue: " << static_cast<OutputPixelPrintType>(m_BackgroundValue) << std::endl;
177
178 os << indent << "ThresholdValue: " << static_cast<InputPixelPrintType>(m_ThresholdValue) << std::endl;
179 }
180
182 NewAccumulator(SizeValueType size) const override
183 {
184 AccumulatorType accumulator(size);
185
189 return accumulator;
190 }
191
194
197
200}; // end BinaryThresholdProjectionImageFilter
201} // end namespace itk
202
203#endif
~BinaryThresholdProjectionImageFilter() override=default
AccumulatorType NewAccumulator(SizeValueType size) const override
void PrintSelf(std::ostream &os, Indent indent) const override
Base class for all process objects that output image data.
TOutputImage OutputImageType
Control indentation during Print() invocation.
Definition: itkIndent.h:50
Define additional traits for native types such as int or float.
static constexpr T NonpositiveMin()
static constexpr T max(const T &)
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Implements an accumulation of an image along a selected direction.
void PrintSelf(std::ostream &os, Indent indent) const override
#define itkConceptMacro(name, concept)
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
unsigned long SizeValueType
Definition: itkIntTypes.h:86