ITK  4.13.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:
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:
98  typedef ProjectionImageFilter< TInputImage, TOutputImage,
100  typename TInputImage::PixelType,
101  typename TOutputImage::PixelType > > Superclass;
102 
105 
108 
110  itkNewMacro(Self);
111 
113  typedef TInputImage InputImageType;
114  typedef TOutputImage OutputImageType;
115 
117  typedef typename InputImageType::PixelType InputPixelType;
118  typedef typename OutputImageType::PixelType OutputPixelType;
119 
121 
125  itkSetMacro(ForegroundValue, InputPixelType);
126 
129  itkGetConstMacro(ForegroundValue, InputPixelType);
130 
135  itkSetMacro(BackgroundValue, OutputPixelType);
136 
141  itkGetConstMacro(BackgroundValue, OutputPixelType);
142 
143 #ifdef ITK_USE_CONCEPT_CHECKING
144  // Begin concept checking
145  itkConceptMacro( InputPixelTypeGreaterThanComparable,
147  itkConceptMacro( InputHasNumericTraitsCheck,
149  // End concept checking
150 #endif
151 
152 protected:
154  {
157  }
158 
159  virtual ~BinaryProjectionImageFilter() ITK_OVERRIDE {}
160 
161  void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE
162  {
163  Superclass::PrintSelf(os, indent);
164 
166  InputPixelPrintType;
167 
168  os << indent << "ForegroundValue: "
169  << static_cast< InputPixelPrintType >( m_ForegroundValue )
170  << std::endl;
171 
173  OutputPixelPrintType;
174 
175  os << indent << "BackgroundValue: "
176  << static_cast< OutputPixelPrintType >( m_BackgroundValue )
177  << std::endl;
178  }
179 
180  virtual AccumulatorType NewAccumulator( SizeValueType size ) const ITK_OVERRIDE
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 
195 private:
196  ITK_DISALLOW_COPY_AND_ASSIGN(BinaryProjectionImageFilter);
197 }; // end BinaryProjectionImageFilter
198 } //end namespace itk
199 
200 #endif
ProjectionImageFilter< TInputImage, TOutputImage, Functor::BinaryAccumulator< typename TInputImage::PixelType, typename TOutputImage::PixelType > > Superclass
void PrintSelf(std::ostream &os, Indent indent) const override
Base class for all process objects that output image data.
unsigned long SizeValueType
Definition: itkIntTypes.h:143
Implements an accumulation of an image along a selected direction.
static ITK_CONSTEXPR_FUNC T max(const T &)
void PrintSelf(std::ostream &os, Indent indent) const override
void operator()(const TInputPixel &input)
static ITK_CONSTEXPR_FUNC T NonpositiveMin()
virtual AccumulatorType NewAccumulator(SizeValueType size) const override
Control indentation during Print() invocation.
Definition: itkIndent.h:49
Define additional traits for native types such as int or float.
#define itkConceptMacro(name, concept)