ITK  4.6.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 
160 
161  void PrintSelf(std::ostream & os, Indent indent) const
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 
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  BinaryProjectionImageFilter(const Self &); //purposely not implemented
197  void operator=(const Self &); //purposely not implemented
198 }; // end BinaryProjectionImageFilter
199 } //end namespace itk
200 
201 #endif
ProjectionImageFilter< TInputImage, TOutputImage, Functor::BinaryAccumulator< typename TInputImage::PixelType, typename TOutputImage::PixelType > > Superclass
Base class for all process objects that output image data.
unsigned long SizeValueType
Definition: itkIntTypes.h:143
virtual AccumulatorType NewAccumulator(SizeValueType size) const
Implements an accumulation of an image along a selected direction.
static T max(const T &)
void operator()(const TInputPixel &input)
void PrintSelf(std::ostream &os, Indent indent) const
void PrintSelf(std::ostream &os, Indent indent) const
Control indentation during Print() invocation.
Definition: itkIndent.h:49
Define additional traits for native types such as int or float.
#define itkConceptMacro(name, concept)