ITK  4.13.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< typename 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< typename TInputImage, typename TOutputImage >
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  // Begin concept checking
106  // End concept checking
107 #endif
108 
109 protected:
111  virtual ~MedianProjectionImageFilter() ITK_OVERRIDE {}
112 
113 private:
114  ITK_DISALLOW_COPY_AND_ASSIGN(MedianProjectionImageFilter);
115 }; // end MedianProjectionImageFilter
116 } //end namespace itk
117 
118 #endif
ProjectionImageFilter< TInputImage, TOutputImage, Functor::MedianAccumulator< typename TInputImage::PixelType > > Superclass
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.
void operator()(const TInputPixel &input)