ITK  4.4.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 {
49 namespace Functor
50 {
51 template< class TInputPixel >
53 {
54 public:
56  {
57  m_Values.reserve(size);
58  }
59 
61 
62  inline void Initialize()
63  {
64  m_Values.clear();
65  }
66 
67  inline void operator()(const TInputPixel & input)
68  {
69  m_Values.push_back(input);
70  }
71 
72  inline TInputPixel GetValue()
73  {
74  typedef typename std::vector< TInputPixel >::iterator ContainerIterator;
75  ContainerIterator medianIterator = m_Values.begin() + m_Values.size() / 2;
76  std::nth_element( m_Values.begin(), medianIterator, m_Values.end() );
77  return *medianIterator;
78  }
79 
80  std::vector< TInputPixel > m_Values;
81 };
82 } // end namespace Function
83 
84 template< class TInputImage, class TOutputImage >
85 class ITK_EXPORT MedianProjectionImageFilter:public
86  ProjectionImageFilter< TInputImage, TOutputImage,
87  Functor::MedianAccumulator< typename TInputImage::PixelType > >
88 {
89 public:
91  typedef ProjectionImageFilter< TInputImage, TOutputImage,
93  typename TInputImage::PixelType > > Superclass;
94 
97 
100 
102  itkNewMacro(Self);
103 
104 #ifdef ITK_USE_CONCEPT_CHECKING
105 
108 #endif
109 
110 protected:
113 
114 private:
115  MedianProjectionImageFilter(const Self &); //purposely not implemented
116  void operator=(const Self &); //purposely not implemented
117 }; // end MedianProjectionImageFilter
118 } //end namespace itk
119 
120 #endif
121