ITK  5.2.0
Insight Toolkit
itkStandardDeviationProjectionImageFilter.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  * 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 itkStandardDeviationProjectionImageFilter_h
19 #define itkStandardDeviationProjectionImageFilter_h
20 
22 #include "itkConceptChecking.h"
23 
24 namespace itk
25 {
47 namespace Functor
48 {
49 template <typename TInputPixel, typename TAccumulate>
51 {
52 public:
54 
56  {
57  m_Size = size;
58  m_Values.reserve(size);
59  }
60 
62 
63  inline void
65  {
67  m_Values.clear();
68  }
69 
70  inline void
71  operator()(const TInputPixel & input)
72  {
73  m_Sum = m_Sum + input;
74  m_Values.push_back(input);
75  }
76 
77  inline RealType
79  {
80  // to avoid division by zero
81  if (m_Size <= 1)
82  {
84  }
85 
87  typename std::vector<TInputPixel>::iterator it;
89  for (it = m_Values.begin(); it != m_Values.end(); it++)
90  {
91  squaredSum += itk::Math::sqr(*it - mean);
92  }
93  return std::sqrt(squaredSum / (m_Size - 1));
94  }
95 
96  TAccumulate m_Sum;
98  std::vector<TInputPixel> m_Values;
99 };
100 } // namespace Functor
101 
102 template <typename TInputImage,
103  typename TOutputImage,
106  : public ProjectionImageFilter<TInputImage,
107  TOutputImage,
108  Functor::StandardDeviationAccumulator<typename TInputImage::PixelType, TAccumulate>>
109 {
110 public:
111  ITK_DISALLOW_COPY_AND_MOVE(StandardDeviationProjectionImageFilter);
112 
114 
115  using Superclass =
116  ProjectionImageFilter<TInputImage,
117  TOutputImage,
119 
120  using InputImageType = TInputImage;
121  using InputPixelType = typename InputImageType::PixelType;
122 
125 
128 
130  itkNewMacro(Self);
131 
132 #ifdef ITK_USE_CONCEPT_CHECKING
133  // Begin concept checking
134  itkConceptMacro(InputPixelToOutputPixelTypeGreaterAdditiveOperatorCheck,
136  itkConceptMacro(InputHasNumericTraitsCheck, (Concept::HasNumericTraits<InputPixelType>));
137 
138  itkConceptMacro(AccumulateHasNumericTraitsCheck, (Concept::HasNumericTraits<TAccumulate>));
139 
140  // End concept checking
141 #endif
142 
143 protected:
145  ~StandardDeviationProjectionImageFilter() override = default;
146 }; // end StandardDeviationProjectionImageFilter
147 } // end namespace itk
148 
149 #endif
itkProjectionImageFilter.h
itk::Concept::HasNumericTraits
Definition: itkConceptChecking.h:714
itk::StandardDeviationProjectionImageFilter::InputPixelType
typename InputImageType::PixelType InputPixelType
Definition: itkStandardDeviationProjectionImageFilter.h:121
itk::Functor::StandardDeviationAccumulator::m_Values
std::vector< TInputPixel > m_Values
Definition: itkStandardDeviationProjectionImageFilter.h:98
itk::StandardDeviationProjectionImageFilter::StandardDeviationProjectionImageFilter
StandardDeviationProjectionImageFilter()=default
itkConceptChecking.h
itk::NumericTraits::AccumulateType
double AccumulateType
Definition: itkNumericTraits.h:74
itk::Functor::StandardDeviationAccumulator::RealType
typename NumericTraits< TInputPixel >::RealType RealType
Definition: itkStandardDeviationProjectionImageFilter.h:53
itk::SmartPointer< Self >
itk::Functor::StandardDeviationAccumulator::m_Sum
TAccumulate m_Sum
Definition: itkStandardDeviationProjectionImageFilter.h:96
itk::Functor::StandardDeviationAccumulator::GetValue
RealType GetValue()
Definition: itkStandardDeviationProjectionImageFilter.h:78
itk::ProjectionImageFilter
Implements an accumulation of an image along a selected direction.
Definition: itkProjectionImageFilter.h:57
itk::ImageSource
Base class for all process objects that output image data.
Definition: itkImageSource.h:67
itk::Functor::StandardDeviationAccumulator
Definition: itkStandardDeviationProjectionImageFilter.h:50
itk::StandardDeviationProjectionImageFilter::~StandardDeviationProjectionImageFilter
~StandardDeviationProjectionImageFilter() override=default
itk::Functor::StandardDeviationAccumulator::~StandardDeviationAccumulator
~StandardDeviationAccumulator()=default
itk::ImageToImageFilter::InputImageType
TInputImage InputImageType
Definition: itkImageToImageFilter.h:129
itk::NumericTraits::ZeroValue
static T ZeroValue()
Definition: itkNumericTraits.h:148
itk::Functor::StandardDeviationAccumulator::Initialize
void Initialize()
Definition: itkStandardDeviationProjectionImageFilter.h:64
itk::Concept::AdditiveOperators
Definition: itkConceptChecking.h:358
itkConceptMacro
#define itkConceptMacro(name, concept)
Definition: itkConceptChecking.h:65
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::ProcessObject
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Definition: itkProcessObject.h:138
itk::Functor::StandardDeviationAccumulator::operator()
void operator()(const TInputPixel &input)
Definition: itkStandardDeviationProjectionImageFilter.h:71
itk::NumericTraits::RealType
double RealType
Definition: itkNumericTraits.h:84
itk::Functor::StandardDeviationAccumulator::m_Size
SizeValueType m_Size
Definition: itkStandardDeviationProjectionImageFilter.h:97
itk::StandardDeviationProjectionImageFilter
Mean projection.
Definition: itkStandardDeviationProjectionImageFilter.h:105
itk::Functor::StandardDeviationAccumulator::StandardDeviationAccumulator
StandardDeviationAccumulator(SizeValueType size)
Definition: itkStandardDeviationProjectionImageFilter.h:55
itk::SizeValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:83