ITK  4.2.0
Insight Segmentation and Registration Toolkit
itkMedianProjectionImageFilter.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 __itkMedianProjectionImageFilter_h
19 #define __itkMedianProjectionImageFilter_h
20 
22 #include "itkConceptChecking.h"
23 
24 #include <vector>
25 #include <algorithm>
26 
27 namespace itk
28 {
50 namespace Functor
51 {
52 template< class TInputPixel >
54 {
55 public:
57  {
58  m_Values.reserve(size);
59  }
60 
62 
63  inline void Initialize()
64  {
65  m_Values.clear();
66  }
67 
68  inline void operator()(const TInputPixel & input)
69  {
70  m_Values.push_back(input);
71  }
72 
73  inline TInputPixel GetValue()
74  {
75  typedef typename std::vector< TInputPixel >::iterator ContainerIterator;
76  ContainerIterator medianIterator = m_Values.begin() + m_Values.size() / 2;
77  std::nth_element( m_Values.begin(), medianIterator, m_Values.end() );
78  return *medianIterator;
79  }
80 
81  std::vector< TInputPixel > m_Values;
82 };
83 } // end namespace Function
84 
85 template< class TInputImage, class TOutputImage >
86 class ITK_EXPORT MedianProjectionImageFilter:public
87  ProjectionImageFilter< TInputImage, TOutputImage,
88  Functor::MedianAccumulator< typename TInputImage::PixelType > >
89 {
90 public:
92  typedef ProjectionImageFilter< TInputImage, TOutputImage,
94  typename TInputImage::PixelType > > Superclass;
95 
98 
101 
103  itkNewMacro(Self);
104 
105 #ifdef ITK_USE_CONCEPT_CHECKING
106 
109 #endif
110 protected:
113 private:
114  MedianProjectionImageFilter(const Self &); //purposely not implemented
115  void operator=(const Self &); //purposely not implemented
116 }; // end MedianProjectionImageFilter
117 } //end namespace itk
119 
120 #endif
121