ITK  4.3.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 {
49 namespace Functor
50 {
51 template< class TInputPixel, class TOutputPixel >
53 {
54 public:
57 
58  inline void Initialize()
59  {
60  m_IsForeground = false;
61  }
62 
63  inline void operator()(const TInputPixel & input)
64  {
65  if ( input == m_ForegroundValue )
66  {
67  m_IsForeground = true;
68  }
69  }
70 
71  inline TOutputPixel GetValue()
72  {
73  if ( m_IsForeground )
74  {
75  return (TOutputPixel)m_ForegroundValue;
76  }
77  else
78  {
79  return m_BackgroundValue;
80  }
81  }
82 
84 
85  TInputPixel m_ForegroundValue;
86 
87  TOutputPixel m_BackgroundValue;
88 };
89 } // end namespace Function
90 
91 template< class TInputImage, class TOutputImage >
92 class ITK_EXPORT BinaryProjectionImageFilter:
93  public ProjectionImageFilter< TInputImage, TOutputImage,
94  Functor::BinaryAccumulator<
95  typename TInputImage::PixelType,
96  typename TOutputImage::PixelType > >
97 {
98 public:
100  typedef ProjectionImageFilter< TInputImage, TOutputImage,
102  typename TInputImage::PixelType,
103  typename TOutputImage::PixelType > > Superclass;
104 
107 
110 
112  itkNewMacro(Self);
113 
115  typedef TInputImage InputImageType;
116  typedef TOutputImage OutputImageType;
117 
119  typedef typename InputImageType::PixelType InputPixelType;
120  typedef typename OutputImageType::PixelType OutputPixelType;
121 
122  typedef typename Superclass::AccumulatorType AccumulatorType;
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 
147  itkConceptMacro( InputPixelTypeGreaterThanComparable,
149  itkConceptMacro( InputHasNumericTraitsCheck,
151 
153 #endif
154 
155 protected:
157  {
158  m_ForegroundValue = NumericTraits< InputPixelType >::max();
160  }
161 
163 
164  void PrintSelf(std::ostream & os, Indent indent) const
165  {
166  Superclass::PrintSelf(os, indent);
167 
169  InputPixelPrintType;
170 
171  os << indent << "ForegroundValue: "
172  << static_cast< InputPixelPrintType >( m_ForegroundValue )
173  << std::endl;
174 
176  OutputPixelPrintType;
177 
178  os << indent << "BackgroundValue: "
179  << static_cast< OutputPixelPrintType >( m_BackgroundValue )
180  << std::endl;
181  }
182 
183  virtual AccumulatorType NewAccumulator( SizeValueType size ) const
184  {
185  AccumulatorType accumulator(size);
186 
187  accumulator.m_ForegroundValue = m_ForegroundValue;
188  accumulator.m_BackgroundValue = m_BackgroundValue;
189  return accumulator;
190  }
191 
194 
197 
198 private:
199  BinaryProjectionImageFilter(const Self &); //purposely not implemented
200  void operator=(const Self &); //purposely not implemented
201 }; // end BinaryProjectionImageFilter
202 } //end namespace itk
203 
204 #endif
205