ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkBinaryProjectionImageFilter.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 itkBinaryProjectionImageFilter_h
19 #define itkBinaryProjectionImageFilter_h
20 
22 #include "itkConceptChecking.h"
23 
24 namespace itk
25 {
47 namespace Functor
48 {
49 template< typename TInputPixel, typename TOutputPixel >
51 {
52 public:
54  ~BinaryAccumulator()= default;
55 
56  inline void Initialize()
57  {
58  m_IsForeground = false;
59  }
60 
61  inline void operator()(const TInputPixel & input)
62  {
63  if ( input == m_ForegroundValue )
64  {
65  m_IsForeground = true;
66  }
67  }
68 
69  inline TOutputPixel GetValue()
70  {
71  if ( m_IsForeground )
72  {
73  return (TOutputPixel)m_ForegroundValue;
74  }
75  else
76  {
77  return m_BackgroundValue;
78  }
79  }
80 
82 
83  TInputPixel m_ForegroundValue;
84 
85  TOutputPixel m_BackgroundValue;
86 };
87 } // end namespace Function
88 
89 template< typename TInputImage, typename TOutputImage >
91  public ProjectionImageFilter< TInputImage, TOutputImage,
92  Functor::BinaryAccumulator<
93  typename TInputImage::PixelType,
94  typename TOutputImage::PixelType > >
95 {
96 public:
97  ITK_DISALLOW_COPY_AND_ASSIGN(BinaryProjectionImageFilter);
98 
100  using Superclass = ProjectionImageFilter< TInputImage, TOutputImage,
102  typename TInputImage::PixelType,
103  typename TOutputImage::PixelType > >;
104 
107 
110 
112  itkNewMacro(Self);
113 
115  using InputImageType = TInputImage;
116  using OutputImageType = TOutputImage;
117 
119  using InputPixelType = typename InputImageType::PixelType;
120  using OutputPixelType = typename OutputImageType::PixelType;
121 
123 
127  itkSetMacro(ForegroundValue, InputPixelType);
128 
131  itkGetConstMacro(ForegroundValue, InputPixelType);
132 
137  itkSetMacro(BackgroundValue, OutputPixelType);
138 
143  itkGetConstMacro(BackgroundValue, OutputPixelType);
144 
145 #ifdef ITK_USE_CONCEPT_CHECKING
146  // Begin concept checking
147  itkConceptMacro( InputPixelTypeGreaterThanComparable,
149  itkConceptMacro( InputHasNumericTraitsCheck,
151  // End concept checking
152 #endif
153 
154 protected:
156  {
159  }
160 
161  ~BinaryProjectionImageFilter() 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 
181  {
182  AccumulatorType accumulator(size);
183 
184  accumulator.m_ForegroundValue = m_ForegroundValue;
185  accumulator.m_BackgroundValue = m_BackgroundValue;
186  return accumulator;
187  }
188 
191 
194 }; // end BinaryProjectionImageFilter
195 } //end namespace itk
196 
197 #endif
typename OutputImageType::PixelType OutputPixelType
typename Superclass::AccumulatorType AccumulatorType
Define numeric traits for std::vector.
unsigned long SizeValueType
Definition: itkIntTypes.h:83
void PrintSelf(std::ostream &os, Indent indent) const override
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
typename InputImageType::PixelType InputPixelType
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
void operator()(const TInputPixel &input)
Control indentation during Print() invocation.
Definition: itkIndent.h:49
#define itkConceptMacro(name, concept)
AccumulatorType NewAccumulator(SizeValueType size) const override
~BinaryProjectionImageFilter() override=default