ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkBinaryThresholdProjectionImageFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
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 {
49 namespace Function
50 {
51 template< typename TInputPixel, typename TOutputPixel >
53 {
54 public:
56  ~BinaryThresholdAccumulator()= default;
57 
58  inline void Initialize()
59  {
60  m_IsForeground = false;
61  }
62 
63  inline void operator()(const TInputPixel & input)
64  {
65  if ( input >= m_ThresholdValue )
66  {
67  m_IsForeground = true;
68  }
69  }
70 
71  inline TOutputPixel GetValue()
72  {
73  if ( m_IsForeground )
74  {
75  return m_ForegroundValue;
76  }
77  else
78  {
79  return m_BackgroundValue;
80  }
81  }
82 
84 
85  TInputPixel m_ThresholdValue;
86  TOutputPixel m_ForegroundValue;
87  TOutputPixel m_BackgroundValue;
88 };
89 } // end namespace Function
90 
91 template< typename TInputImage, typename TOutputImage >
93  public ProjectionImageFilter< TInputImage, TOutputImage,
94  Function::BinaryThresholdAccumulator<
95  typename TInputImage::PixelType,
96  typename TOutputImage::PixelType > >
97 {
98 public:
99  ITK_DISALLOW_COPY_AND_ASSIGN(BinaryThresholdProjectionImageFilter);
100 
102  using Superclass = ProjectionImageFilter< TInputImage, TOutputImage,
104  typename TInputImage::PixelType,
105  typename TOutputImage::PixelType > >;
106 
109 
112 
114  itkNewMacro(Self);
115 
117  using InputImageType = TInputImage;
118  using OutputImageType = TOutputImage;
119 
121  using InputPixelType = typename InputImageType::PixelType;
122  using OutputPixelType = typename OutputImageType::PixelType;
123 
125 
128  itkSetMacro(ForegroundValue, OutputPixelType);
129  itkGetConstMacro(ForegroundValue, OutputPixelType);
131 
134  itkSetMacro(BackgroundValue, OutputPixelType);
135  itkGetConstMacro(BackgroundValue, OutputPixelType);
137 
140  itkSetMacro(ThresholdValue, InputPixelType);
141  itkGetConstMacro(ThresholdValue, InputPixelType);
143 
144 #ifdef ITK_USE_CONCEPT_CHECKING
145  // Begin concept checking
146  itkConceptMacro( InputPixelTypeGreaterThanComparable,
148  itkConceptMacro( InputHasNumericTraitsCheck,
150  // End concept checking
151 #endif
152 
153 protected:
155  {
159  }
160 
161  ~BinaryThresholdProjectionImageFilter() override = default;
162 
163  void PrintSelf(std::ostream & os, Indent indent) const override
164  {
165  Superclass::PrintSelf(os, indent);
166 
167  using InputPixelPrintType = typename NumericTraits<InputPixelType>::PrintType;
168 
169  os << indent << "ForegroundValue: "
170  << static_cast< InputPixelPrintType >( m_ForegroundValue )
171  << std::endl;
172 
173  using OutputPixelPrintType = typename NumericTraits<OutputPixelType>::PrintType;
174 
175  os << indent << "BackgroundValue: "
176  << static_cast< OutputPixelPrintType >( m_BackgroundValue )
177  << std::endl;
178 
179  os << indent << "ThresholdValue: "
180  << static_cast< InputPixelPrintType >( m_ThresholdValue )
181  << std::endl;
182  }
183 
185  {
186  AccumulatorType accumulator(size);
187 
188  accumulator.m_ForegroundValue = m_ForegroundValue;
189  accumulator.m_BackgroundValue = m_BackgroundValue;
190  accumulator.m_ThresholdValue = m_ThresholdValue;
191  return accumulator;
192  }
193 
196 
199 
202 }; // end BinaryThresholdProjectionImageFilter
203 } //end namespace itk
204 
205 #endif
Define numeric traits for std::vector.
unsigned long SizeValueType
Definition: itkIntTypes.h:83
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Base class for all process objects that output image data.
Implements an accumulation of an image along a selected direction.
void PrintSelf(std::ostream &os, Indent indent) const override
TOutputImage OutputImageType
AccumulatorType NewAccumulator(SizeValueType size) const override
Control indentation during Print() invocation.
Definition: itkIndent.h:49
~BinaryThresholdProjectionImageFilter() override=default
#define itkConceptMacro(name, concept)
void PrintSelf(std::ostream &os, Indent indent) const override