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 
24 namespace itk
25 {
50 namespace Function
51 {
52 template <typename TInputPixel, typename TOutputPixel>
54 {
55 public:
57  ~BinaryThresholdAccumulator() = default;
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  {
77  if (m_IsForeground)
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 
93 template <typename TInputImage, typename TOutputImage>
95  : public ProjectionImageFilter<
96  TInputImage,
97  TOutputImage,
98  Function::BinaryThresholdAccumulator<typename TInputImage::PixelType, typename TOutputImage::PixelType>>
99 {
100 public:
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);
136  itkSetMacro(BackgroundValue, OutputPixelType);
137  itkGetConstMacro(BackgroundValue, OutputPixelType);
142  itkSetMacro(ThresholdValue, InputPixelType);
143  itkGetConstMacro(ThresholdValue, InputPixelType);
146 #ifdef ITK_USE_CONCEPT_CHECKING
147  // Begin concept checking
148  itkConceptMacro(InputPixelTypeGreaterThanComparable, (Concept::GreaterThanComparable<InputPixelType>));
149  itkConceptMacro(InputHasNumericTraitsCheck, (Concept::HasNumericTraits<InputPixelType>));
150  // End concept checking
151 #endif
152 
153 protected:
155  {
159  }
160 
161  ~BinaryThresholdProjectionImageFilter() override = default;
162 
163  void
164  PrintSelf(std::ostream & os, Indent indent) const override
165  {
166  Superclass::PrintSelf(os, indent);
167 
168  using InputPixelPrintType = typename NumericTraits<InputPixelType>::PrintType;
169 
170  os << indent << "ForegroundValue: " << static_cast<InputPixelPrintType>(m_ForegroundValue) << std::endl;
171 
172  using OutputPixelPrintType = typename NumericTraits<OutputPixelType>::PrintType;
173 
174  os << indent << "BackgroundValue: " << static_cast<OutputPixelPrintType>(m_BackgroundValue) << std::endl;
175 
176  os << indent << "ThresholdValue: " << static_cast<InputPixelPrintType>(m_ThresholdValue) << std::endl;
177  }
178 
180  NewAccumulator(SizeValueType size) const override
181  {
182  AccumulatorType accumulator(size);
183 
184  accumulator.m_ForegroundValue = m_ForegroundValue;
185  accumulator.m_BackgroundValue = m_BackgroundValue;
186  accumulator.m_ThresholdValue = m_ThresholdValue;
187  return accumulator;
188  }
189 
192 
195 
198 }; // end BinaryThresholdProjectionImageFilter
199 } // end namespace itk
200 
201 #endif
itk::ProjectionImageFilter::AccumulatorType
TAccumulator AccumulatorType
Definition: itkProjectionImageFilter.h:84
itkProjectionImageFilter.h
itk::Concept::HasNumericTraits
Definition: itkConceptChecking.h:717
itk::ProjectionImageFilter::PrintSelf
void PrintSelf(std::ostream &os, Indent indent) const override
itk::Concept::GreaterThanComparable
Definition: itkConceptChecking.h:285
itk::NumericTraits::NonpositiveMin
static constexpr T NonpositiveMin()
Definition: itkNumericTraits.h:99
itk::Function::BinaryThresholdAccumulator::m_ThresholdValue
TInputPixel m_ThresholdValue
Definition: itkBinaryThresholdProjectionImageFilter.h:87
itkConceptChecking.h
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::Function::BinaryThresholdAccumulator
Definition: itkBinaryThresholdProjectionImageFilter.h:53
itk::Function::BinaryThresholdAccumulator::Initialize
void Initialize()
Definition: itkBinaryThresholdProjectionImageFilter.h:60
itk::BinaryThresholdProjectionImageFilter::m_ForegroundValue
OutputPixelType m_ForegroundValue
Definition: itkBinaryThresholdProjectionImageFilter.h:191
itk::ProjectionImageFilter
Implements an accumulation of an image along a selected direction.
Definition: itkProjectionImageFilter.h:57
itk::ImageSource
Base class for all process objects that output image data.
Definition: itkImageSource.h:67
itk::Function::BinaryThresholdAccumulator::operator()
void operator()(const TInputPixel &input)
Definition: itkBinaryThresholdProjectionImageFilter.h:66
itk::Function::BinaryThresholdAccumulator::m_IsForeground
bool m_IsForeground
Definition: itkBinaryThresholdProjectionImageFilter.h:85
itk::BinaryThresholdProjectionImageFilter::OutputPixelType
typename OutputImageType::PixelType OutputPixelType
Definition: itkBinaryThresholdProjectionImageFilter.h:124
itk::BinaryThresholdProjectionImageFilter::BinaryThresholdProjectionImageFilter
BinaryThresholdProjectionImageFilter()
Definition: itkBinaryThresholdProjectionImageFilter.h:154
itk::Function::BinaryThresholdAccumulator::BinaryThresholdAccumulator
BinaryThresholdAccumulator(SizeValueType)
Definition: itkBinaryThresholdProjectionImageFilter.h:56
itk::BinaryThresholdProjectionImageFilter::m_ThresholdValue
InputPixelType m_ThresholdValue
Definition: itkBinaryThresholdProjectionImageFilter.h:197
itk::ImageToImageFilter::InputImageType
TInputImage InputImageType
Definition: itkImageToImageFilter.h:129
itk::BinaryThresholdProjectionImageFilter::PrintSelf
void PrintSelf(std::ostream &os, Indent indent) const override
Definition: itkBinaryThresholdProjectionImageFilter.h:164
itk::BinaryThresholdProjectionImageFilter::NewAccumulator
AccumulatorType NewAccumulator(SizeValueType size) const override
Definition: itkBinaryThresholdProjectionImageFilter.h:180
itk::NumericTraits
Define additional traits for native types such as int or float.
Definition: itkNumericTraits.h:60
itk::NumericTraits::max
static constexpr T max(const T &)
Definition: itkNumericTraits.h:169
itk::Function::BinaryThresholdAccumulator::~BinaryThresholdAccumulator
~BinaryThresholdAccumulator()=default
itkConceptMacro
#define itkConceptMacro(name, concept)
Definition: itkConceptChecking.h:65
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itk::Function::BinaryThresholdAccumulator::m_BackgroundValue
TOutputPixel m_BackgroundValue
Definition: itkBinaryThresholdProjectionImageFilter.h:89
itk::ProcessObject
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Definition: itkProcessObject.h:139
itk::BinaryThresholdProjectionImageFilter
BinaryThreshold projection.
Definition: itkBinaryThresholdProjectionImageFilter.h:94
itk::BinaryThresholdProjectionImageFilter::~BinaryThresholdProjectionImageFilter
~BinaryThresholdProjectionImageFilter() override=default
itk::BinaryThresholdProjectionImageFilter::m_BackgroundValue
OutputPixelType m_BackgroundValue
Definition: itkBinaryThresholdProjectionImageFilter.h:194
itk::BinaryThresholdProjectionImageFilter::InputPixelType
typename InputImageType::PixelType InputPixelType
Definition: itkBinaryThresholdProjectionImageFilter.h:123
itk::Function::BinaryThresholdAccumulator::m_ForegroundValue
TOutputPixel m_ForegroundValue
Definition: itkBinaryThresholdProjectionImageFilter.h:88
itk::Function::BinaryThresholdAccumulator::GetValue
TOutputPixel GetValue()
Definition: itkBinaryThresholdProjectionImageFilter.h:75
itk::SizeValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:86
itk::ImageSource::OutputImageType
TOutputImage OutputImageType
Definition: itkImageSource.h:90