ITK  5.0.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 
60  ~MedianAccumulator()= default;
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  auto medianIterator = m_Values.begin() + m_Values.size() / 2;
75  std::nth_element( m_Values.begin(), medianIterator, m_Values.end() );
76  return *medianIterator;
77  }
78 
79  std::vector< TInputPixel > m_Values;
80 };
81 } // end namespace Function
82 
83 template< typename TInputImage, typename TOutputImage >
85  ProjectionImageFilter< TInputImage, TOutputImage,
86  Functor::MedianAccumulator< typename TInputImage::PixelType > >
87 {
88 public:
89  ITK_DISALLOW_COPY_AND_ASSIGN(MedianProjectionImageFilter);
90 
92  using Superclass = ProjectionImageFilter< TInputImage, TOutputImage,
94  typename TInputImage::PixelType > >;
95 
98 
101 
103  itkNewMacro(Self);
104 
105 #ifdef ITK_USE_CONCEPT_CHECKING
106  // Begin concept checking
107  // End concept checking
108 #endif
109 
110 protected:
111  MedianProjectionImageFilter() = default;
112  ~MedianProjectionImageFilter() override = default;
113 }; // end MedianProjectionImageFilter
114 } //end namespace itk
115 
116 #endif
unsigned long SizeValueType
Definition: itkIntTypes.h:83
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Base class for all process objects that output image data.
Implements an accumulation of an image along a selected direction.
~MedianProjectionImageFilter() override=default
void operator()(const TInputPixel &input)