ITK  5.2.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  * http://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  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 
95 template <typename TInputImage, typename TOutputImage>
97  : public ProjectionImageFilter<
98  TInputImage,
99  TOutputImage,
100  Function::BinaryThresholdAccumulator<typename TInputImage::PixelType, typename TOutputImage::PixelType>>
101 {
102 public:
103  ITK_DISALLOW_COPY_AND_MOVE(BinaryThresholdProjectionImageFilter);
104 
107  TInputImage,
108  TOutputImage,
110 
113 
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 
129 
132  itkSetMacro(ForegroundValue, OutputPixelType);
133  itkGetConstMacro(ForegroundValue, OutputPixelType);
135 
138  itkSetMacro(BackgroundValue, OutputPixelType);
139  itkGetConstMacro(BackgroundValue, OutputPixelType);
141 
144  itkSetMacro(ThresholdValue, InputPixelType);
145  itkGetConstMacro(ThresholdValue, InputPixelType);
147 
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 
155 protected:
157  {
161  }
162 
163  ~BinaryThresholdProjectionImageFilter() override = default;
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 
186  accumulator.m_ForegroundValue = m_ForegroundValue;
187  accumulator.m_BackgroundValue = m_BackgroundValue;
188  accumulator.m_ThresholdValue = m_ThresholdValue;
189  return accumulator;
190  }
191 
194 
197 
200 }; // end BinaryThresholdProjectionImageFilter
201 } // end namespace itk
202 
203 #endif
itk::ProjectionImageFilter::AccumulatorType
TAccumulator AccumulatorType
Definition: itkProjectionImageFilter.h:84
itkProjectionImageFilter.h
itk::Concept::HasNumericTraits
Definition: itkConceptChecking.h:714
itk::ProjectionImageFilter::PrintSelf
void PrintSelf(std::ostream &os, Indent indent) const override
itk::Concept::GreaterThanComparable
Definition: itkConceptChecking.h:284
itk::NumericTraits::NonpositiveMin
static constexpr T NonpositiveMin()
Definition: itkNumericTraits.h:97
itk::Function::BinaryThresholdAccumulator::m_ThresholdValue
TInputPixel m_ThresholdValue
Definition: itkBinaryThresholdProjectionImageFilter.h:89
itkConceptChecking.h
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::BinaryThresholdProjectionImageFilter::AccumulatorType
typename Superclass::AccumulatorType AccumulatorType
Definition: itkBinaryThresholdProjectionImageFilter.h:128
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:193
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:87
itk::BinaryThresholdProjectionImageFilter::OutputPixelType
typename OutputImageType::PixelType OutputPixelType
Definition: itkBinaryThresholdProjectionImageFilter.h:126
itk::BinaryThresholdProjectionImageFilter::BinaryThresholdProjectionImageFilter
BinaryThresholdProjectionImageFilter()
Definition: itkBinaryThresholdProjectionImageFilter.h:156
itk::Function::BinaryThresholdAccumulator::BinaryThresholdAccumulator
BinaryThresholdAccumulator(SizeValueType)
Definition: itkBinaryThresholdProjectionImageFilter.h:56
itk::BinaryThresholdProjectionImageFilter::m_ThresholdValue
InputPixelType m_ThresholdValue
Definition: itkBinaryThresholdProjectionImageFilter.h:199
itk::ImageToImageFilter::InputImageType
TInputImage InputImageType
Definition: itkImageToImageFilter.h:129
itk::BinaryThresholdProjectionImageFilter::PrintSelf
void PrintSelf(std::ostream &os, Indent indent) const override
Definition: itkBinaryThresholdProjectionImageFilter.h:166
itk::BinaryThresholdProjectionImageFilter::NewAccumulator
AccumulatorType NewAccumulator(SizeValueType size) const override
Definition: itkBinaryThresholdProjectionImageFilter.h:182
itk::NumericTraits
Define additional traits for native types such as int or float.
Definition: itkNumericTraits.h:58
itk::NumericTraits::max
static constexpr T max(const T &)
Definition: itkNumericTraits.h:167
itk::NumericTraits::ZeroValue
static T ZeroValue()
Definition: itkNumericTraits.h:148
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: itkAnnulusOperator.h:24
itk::Function::BinaryThresholdAccumulator::m_BackgroundValue
TOutputPixel m_BackgroundValue
Definition: itkBinaryThresholdProjectionImageFilter.h:91
itk::ProcessObject
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Definition: itkProcessObject.h:138
itk::BinaryThresholdProjectionImageFilter
BinaryThreshold projection.
Definition: itkBinaryThresholdProjectionImageFilter.h:96
itk::BinaryThresholdProjectionImageFilter::~BinaryThresholdProjectionImageFilter
~BinaryThresholdProjectionImageFilter() override=default
itk::BinaryThresholdProjectionImageFilter::m_BackgroundValue
OutputPixelType m_BackgroundValue
Definition: itkBinaryThresholdProjectionImageFilter.h:196
itk::BinaryThresholdProjectionImageFilter::InputPixelType
typename InputImageType::PixelType InputPixelType
Definition: itkBinaryThresholdProjectionImageFilter.h:125
itk::Function::BinaryThresholdAccumulator::m_ForegroundValue
TOutputPixel m_ForegroundValue
Definition: itkBinaryThresholdProjectionImageFilter.h:90
itk::Function::BinaryThresholdAccumulator::GetValue
TOutputPixel GetValue()
Definition: itkBinaryThresholdProjectionImageFilter.h:75
itk::SizeValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:83
itk::ImageSource::OutputImageType
TOutputImage OutputImageType
Definition: itkImageSource.h:90