ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
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{
46
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
79 return m_BackgroundValue;
80 }
81
83
84 TInputPixel m_ForegroundValue;
85
86 TOutputPixel m_BackgroundValue;
87};
88} // namespace Functor
89
90template <typename TInputImage, typename TOutputImage>
92 : public ProjectionImageFilter<
93 TInputImage,
94 TOutputImage,
95 Functor::BinaryAccumulator<typename TInputImage::PixelType, typename TOutputImage::PixelType>>
96{
97public:
98 ITK_DISALLOW_COPY_AND_MOVE(BinaryProjectionImageFilter);
99
102 TInputImage,
103 TOutputImage,
105
108
110 itkOverrideGetNameOfClassMacro(BinaryProjectionImageFilter);
111
113 itkNewMacro(Self);
114
116 using InputImageType = TInputImage;
117 using OutputImageType = TOutputImage;
118
120 using InputPixelType = typename InputImageType::PixelType;
121 using OutputPixelType = typename OutputImageType::PixelType;
122
123 using typename Superclass::AccumulatorType;
124
128 itkSetMacro(ForegroundValue, InputPixelType);
129
132 itkGetConstMacro(ForegroundValue, InputPixelType);
133
138 itkSetMacro(BackgroundValue, OutputPixelType);
139
144 itkGetConstMacro(BackgroundValue, OutputPixelType);
145
146 itkConceptMacro(InputPixelTypeGreaterThanComparable, (Concept::EqualityComparable<InputPixelType>));
147 itkConceptMacro(InputHasNumericTraitsCheck, (Concept::HasNumericTraits<InputPixelType>));
148
149protected:
155
156 ~BinaryProjectionImageFilter() override = default;
157
158 void
159 PrintSelf(std::ostream & os, Indent indent) const override
160 {
161 Superclass::PrintSelf(os, indent);
162
163 using InputPixelPrintType = typename NumericTraits<InputPixelType>::PrintType;
164
165 os << indent << "ForegroundValue: " << static_cast<InputPixelPrintType>(m_ForegroundValue) << std::endl;
166
167 using OutputPixelPrintType = typename NumericTraits<OutputPixelType>::PrintType;
168
169 os << indent << "BackgroundValue: " << static_cast<OutputPixelPrintType>(m_BackgroundValue) << std::endl;
170 }
171
173 NewAccumulator(SizeValueType size) const override
174 {
175 AccumulatorType accumulator(size);
176
179 return accumulator;
180 }
181
184
187}; // end BinaryProjectionImageFilter
188} // end namespace itk
189
190#endif
typename OutputImageType::PixelType OutputPixelType
Functor::BinaryAccumulator< typename TInputImage::PixelType, typename TOutputImage::PixelType > AccumulatorType
~BinaryProjectionImageFilter() override=default
void PrintSelf(std::ostream &os, Indent indent) const override
AccumulatorType NewAccumulator(SizeValueType size) const override
ProjectionImageFilter< TInputImage, TOutputImage, Functor::BinaryAccumulator< typename TInputImage::PixelType, typename TOutputImage::PixelType > > Superclass
typename InputImageType::PixelType InputPixelType
void operator()(const TInputPixel &input)
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