ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkStatisticsImageFilter.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 itkStatisticsImageFilter_h
19 #define itkStatisticsImageFilter_h
20 
21 #include "itkImageToImageFilter.h"
22 #include "itkNumericTraits.h"
23 #include "itkArray.h"
25 #include <mutex>
27 
28 namespace itk
29 {
53 template< typename TInputImage >
54 class ITK_TEMPLATE_EXPORT StatisticsImageFilter:
55  public ImageToImageFilter< TInputImage, TInputImage >
56 {
57 public:
58  ITK_DISALLOW_COPY_AND_ASSIGN(StatisticsImageFilter);
59 
65 
67  itkNewMacro(Self);
68 
71 
73  using InputImagePointer = typename TInputImage::Pointer;
74 
76  using SizeType = typename TInputImage::SizeType;
78  using PixelType = typename TInputImage::PixelType;
79 
81  static constexpr unsigned int ImageDimension = TInputImage::ImageDimension;
82 
85 
88 
92 
95  { return this->GetMinimumOutput()->Get(); }
96  PixelObjectType * GetMinimumOutput();
98 
99  const PixelObjectType * GetMinimumOutput() const;
100 
103  { return this->GetMaximumOutput()->Get(); }
104  PixelObjectType * GetMaximumOutput();
106 
107  const PixelObjectType * GetMaximumOutput() const;
108 
111  { return this->GetMeanOutput()->Get(); }
112  RealObjectType * GetMeanOutput();
114 
115  const RealObjectType * GetMeanOutput() const;
116 
119  { return this->GetSigmaOutput()->Get(); }
120  RealObjectType * GetSigmaOutput();
122 
123  const RealObjectType * GetSigmaOutput() const;
124 
127  { return this->GetVarianceOutput()->Get(); }
128  RealObjectType * GetVarianceOutput();
130 
131  const RealObjectType * GetVarianceOutput() const;
132 
134  RealType GetSum() const
135  { return this->GetSumOutput()->Get(); }
136  RealObjectType * GetSumOutput();
138 
139  const RealObjectType * GetSumOutput() const;
140 
143  { return this->GetSumOfSquaresOutput()->Get(); }
144  RealObjectType * GetSumOfSquaresOutput();
146 
147  const RealObjectType * GetSumOfSquaresOutput() const;
148 
152  using Superclass::MakeOutput;
153  DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) override;
154 
155 #ifdef ITK_USE_CONCEPT_CHECKING
156  // Begin concept checking
157  itkConceptMacro( InputHasNumericTraitsCheck,
159  // End concept checking
160 #endif
161 
162 protected:
164  ~StatisticsImageFilter() override = default;
165  void PrintSelf(std::ostream & os, Indent indent) const override;
166 
170  void AllocateOutputs() override;
171 
173  void BeforeThreadedGenerateData() override;
174 
177  void AfterThreadedGenerateData() override;
178 
179  void DynamicThreadedGenerateData( const RegionType &) override;
180 
181  // Override since the filter needs all the data for the algorithm
182  void GenerateInputRequestedRegion() override;
183 
184  // Override since the filter produces all of its output
185  void EnlargeOutputRequestedRegion(DataObject *data) override;
186 
187 private:
190 
191  SizeValueType m_Count{1};
194 
195  std::mutex m_Mutex;
196 }; // end of class
197 } // end namespace itk
198 
199 #ifndef ITK_MANUAL_INSTANTIATION
200 #include "itkStatisticsImageFilter.hxx"
201 #endif
202 
203 #endif
Light weight base class for most itk classes.
DataObjectPointerArray::size_type DataObjectPointerArraySizeType
Define numeric traits for std::vector.
unsigned long SizeValueType
Definition: itkIntTypes.h:83
typename TInputImage::IndexType IndexType
typename NumericTraits< PixelType >::RealType RealType
typename TInputImage::Pointer InputImagePointer
typename TInputImage::PixelType PixelType
typename TInputImage::RegionType RegionType
Decorates any &quot;simple&quot; data type (data types without smart pointers) with a DataObject API...
Compute min, max, variance and mean of an Image.
CompensatedSummation< RealType > m_SumOfSquares
Base class for filters that take an image as input and produce an image as output.
Control indentation during Print() invocation.
Definition: itkIndent.h:49
typename TInputImage::SizeType SizeType
SmartPointer< Self > Pointer
#define itkConceptMacro(name, concept)
CompensatedSummation< RealType > m_ThreadSum
Base class for all data objects in ITK.