ITK  6.0.0
Insight Toolkit
itkBinaryProjectionImageFilter.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 itkBinaryProjectionImageFilter_h
19#define itkBinaryProjectionImageFilter_h
20
22#include "itkConceptChecking.h"
23
24namespace itk
25{
47namespace Functor
48{
49template <typename TInputPixel, typename TOutputPixel>
51{
52public:
54 ~BinaryAccumulator() = default;
55
56 inline void
58 {
59 m_IsForeground = false;
60 }
61
62 inline void
63 operator()(const TInputPixel & input)
64 {
65 if (input == m_ForegroundValue)
66 {
67 m_IsForeground = true;
68 }
69 }
70
71 inline TOutputPixel
73 {
75 {
76 return (TOutputPixel)m_ForegroundValue;
77 }
78 else
79 {
80 return m_BackgroundValue;
81 }
82 }
83
85
86 TInputPixel m_ForegroundValue;
87
88 TOutputPixel m_BackgroundValue;
89};
90} // namespace Functor
91
92template <typename TInputImage, typename TOutputImage>
94 : public ProjectionImageFilter<
95 TInputImage,
96 TOutputImage,
97 Functor::BinaryAccumulator<typename TInputImage::PixelType, typename TOutputImage::PixelType>>
98{
99public:
100 ITK_DISALLOW_COPY_AND_MOVE(BinaryProjectionImageFilter);
101
104 TInputImage,
105 TOutputImage,
107
110
112 itkOverrideGetNameOfClassMacro(BinaryProjectionImageFilter);
113
115 itkNewMacro(Self);
116
118 using InputImageType = TInputImage;
119 using OutputImageType = TOutputImage;
120
122 using InputPixelType = typename InputImageType::PixelType;
123 using OutputPixelType = typename OutputImageType::PixelType;
124
125 using typename Superclass::AccumulatorType;
126
130 itkSetMacro(ForegroundValue, InputPixelType);
131
134 itkGetConstMacro(ForegroundValue, InputPixelType);
135
140 itkSetMacro(BackgroundValue, OutputPixelType);
141
146 itkGetConstMacro(BackgroundValue, OutputPixelType);
147
148#ifdef ITK_USE_CONCEPT_CHECKING
149 // Begin concept checking
150 itkConceptMacro(InputPixelTypeGreaterThanComparable, (Concept::EqualityComparable<InputPixelType>));
151 itkConceptMacro(InputHasNumericTraitsCheck, (Concept::HasNumericTraits<InputPixelType>));
152 // End concept checking
153#endif
154
155protected:
157 {
160 }
161
162 ~BinaryProjectionImageFilter() override = default;
163
164 void
165 PrintSelf(std::ostream & os, Indent indent) const override
166 {
167 Superclass::PrintSelf(os, indent);
168
169 using InputPixelPrintType = typename NumericTraits<InputPixelType>::PrintType;
170
171 os << indent << "ForegroundValue: " << static_cast<InputPixelPrintType>(m_ForegroundValue) << std::endl;
172
173 using OutputPixelPrintType = typename NumericTraits<OutputPixelType>::PrintType;
174
175 os << indent << "BackgroundValue: " << static_cast<OutputPixelPrintType>(m_BackgroundValue) << std::endl;
176 }
177
179 NewAccumulator(SizeValueType size) const override
180 {
181 AccumulatorType accumulator(size);
182
185 return accumulator;
186 }
187
190
193}; // end BinaryProjectionImageFilter
194} // end namespace itk
195
196#endif
typename OutputImageType::PixelType OutputPixelType
~BinaryProjectionImageFilter() override=default
void PrintSelf(std::ostream &os, Indent indent) const override
AccumulatorType NewAccumulator(SizeValueType size) const override
typename InputImageType::PixelType InputPixelType
void operator()(const TInputPixel &input)
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