ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
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{
49
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
82 return m_BackgroundValue;
83 }
84
86
87 TInputPixel m_ThresholdValue;
88 TOutputPixel m_ForegroundValue;
89 TOutputPixel m_BackgroundValue;
90};
91} // end namespace Function
92
93template <typename TInputImage, typename TOutputImage>
95 : public ProjectionImageFilter<
96 TInputImage,
97 TOutputImage,
98 Function::BinaryThresholdAccumulator<typename TInputImage::PixelType, typename TOutputImage::PixelType>>
99{
100public:
101 ITK_DISALLOW_COPY_AND_MOVE(BinaryThresholdProjectionImageFilter);
102
105 TInputImage,
106 TOutputImage,
108
111
113 itkOverrideGetNameOfClassMacro(BinaryThresholdProjectionImageFilter);
114
116 itkNewMacro(Self);
117
119 using InputImageType = TInputImage;
120 using OutputImageType = TOutputImage;
121
123 using InputPixelType = typename InputImageType::PixelType;
124 using OutputPixelType = typename OutputImageType::PixelType;
125
126 using typename Superclass::AccumulatorType;
127
130 itkSetMacro(ForegroundValue, OutputPixelType);
131 itkGetConstMacro(ForegroundValue, OutputPixelType);
133
136 itkSetMacro(BackgroundValue, OutputPixelType);
137 itkGetConstMacro(BackgroundValue, OutputPixelType);
139
142 itkSetMacro(ThresholdValue, InputPixelType);
143 itkGetConstMacro(ThresholdValue, InputPixelType);
145
146 itkConceptMacro(InputPixelTypeGreaterThanComparable, (Concept::GreaterThanComparable<InputPixelType>));
147 itkConceptMacro(InputHasNumericTraitsCheck, (Concept::HasNumericTraits<InputPixelType>));
148
149protected:
156
158
159 void
160 PrintSelf(std::ostream & os, Indent indent) const override
161 {
162 Superclass::PrintSelf(os, indent);
163
164 using InputPixelPrintType = typename NumericTraits<InputPixelType>::PrintType;
165
166 os << indent << "ForegroundValue: " << static_cast<InputPixelPrintType>(m_ForegroundValue) << std::endl;
167
168 using OutputPixelPrintType = typename NumericTraits<OutputPixelType>::PrintType;
169
170 os << indent << "BackgroundValue: " << static_cast<OutputPixelPrintType>(m_BackgroundValue) << std::endl;
171
172 os << indent << "ThresholdValue: " << static_cast<InputPixelPrintType>(m_ThresholdValue) << std::endl;
173 }
174
176 NewAccumulator(SizeValueType size) const override
177 {
178 AccumulatorType accumulator(size);
179
183 return accumulator;
184 }
185
188
191
194}; // end BinaryThresholdProjectionImageFilter
195} // end namespace itk
196
197#endif
ProjectionImageFilter< TInputImage, TOutputImage, Function::BinaryThresholdAccumulator< typename TInputImage::PixelType, typename TOutputImage::PixelType > > Superclass
~BinaryThresholdProjectionImageFilter() override=default
AccumulatorType NewAccumulator(SizeValueType size) const override
void PrintSelf(std::ostream &os, Indent indent) const override
Control indentation during Print() invocation.
Definition itkIndent.h:50
static constexpr T NonpositiveMin()
static constexpr T max(const T &)
Implements transparent reference counting.
#define itkConceptMacro(name, concept)
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
unsigned long SizeValueType
Definition itkIntTypes.h:86