ITK  6.0.0
Insight Toolkit
itkMedianProjectionImageFilter.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright NumFOCUS
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 * https://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
27namespace itk
28{
49namespace Functor
50{
51template <typename TInputPixel>
53{
54public:
55 MedianAccumulator(SizeValueType size) { m_Values.reserve(size); }
56
57 ~MedianAccumulator() = default;
58
59 inline void
61 {
62 m_Values.clear();
63 }
64
65 inline void
66 operator()(const TInputPixel & input)
67 {
68 m_Values.push_back(input);
69 }
70
71 inline TInputPixel
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} // namespace Functor
82
83template <typename TInputImage, typename TOutputImage>
85 : public ProjectionImageFilter<TInputImage, TOutputImage, Functor::MedianAccumulator<typename TInputImage::PixelType>>
86{
87public:
88 ITK_DISALLOW_COPY_AND_MOVE(MedianProjectionImageFilter);
89
91 using Superclass =
93
96
98 itkOverrideGetNameOfClassMacro(MedianProjectionImageFilter);
99
101 itkNewMacro(Self);
102
103#ifdef ITK_USE_CONCEPT_CHECKING
104 // Begin concept checking
105 // End concept checking
106#endif
107
108protected:
110 ~MedianProjectionImageFilter() override = default;
111}; // end MedianProjectionImageFilter
112} // end namespace itk
113
114#endif
void operator()(const TInputPixel &input)
Base class for all process objects that output image data.
~MedianProjectionImageFilter() override=default
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Implements an accumulation of an image along a selected direction.
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
unsigned long SizeValueType
Definition: itkIntTypes.h:86