ITK  5.1.0
Insight 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 "itkImageSink.h"
22 #include "itkNumericTraits.h"
23 #include "itkArray.h"
25 #include <mutex>
27 
28 namespace itk
29 {
54 template <typename TInputImage>
55 class ITK_TEMPLATE_EXPORT StatisticsImageFilter : public ImageSink<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 
94  itkGetDecoratedOutputMacro(Minimum, PixelType);
95 
97  itkGetDecoratedOutputMacro(Maximum, PixelType);
98 
100  itkGetDecoratedOutputMacro(Mean, RealType);
101 
103  itkGetDecoratedOutputMacro(Sigma, RealType);
104 
106  itkGetDecoratedOutputMacro(Variance, RealType);
107 
109  itkGetDecoratedOutputMacro(Sum, RealType);
110 
112  itkGetDecoratedOutputMacro(SumOfSquares, RealType);
113 
114  // Change the acces from protected to public to expose streaming option
115  using Superclass::SetNumberOfStreamDivisions;
116  using Superclass::GetNumberOfStreamDivisions;
117 
121  using Superclass::MakeOutput;
123  MakeOutput(const DataObjectIdentifierType & name) override;
124 
125 #ifdef ITK_USE_CONCEPT_CHECKING
126  // Begin concept checking
127  itkConceptMacro(InputHasNumericTraitsCheck, (Concept::HasNumericTraits<PixelType>));
128  // End concept checking
129 #endif
130 
131 protected:
133  ~StatisticsImageFilter() override = default;
134  void
135  PrintSelf(std::ostream & os, Indent indent) const override;
136 
138  void
139  BeforeStreamedGenerateData() override;
140 
143  void
144  AfterStreamedGenerateData() override;
145 
146  void
147  ThreadedStreamedGenerateData(const RegionType &) override;
148 
149  itkSetDecoratedOutputMacro(Minimum, PixelType);
150  itkSetDecoratedOutputMacro(Maximum, PixelType);
151  itkSetDecoratedOutputMacro(Mean, RealType);
152  itkSetDecoratedOutputMacro(Sigma, RealType);
153  itkSetDecoratedOutputMacro(Variance, RealType);
154  itkSetDecoratedOutputMacro(Sum, RealType);
155  itkSetDecoratedOutputMacro(SumOfSquares, RealType);
156 
157 private:
159  CompensatedSummation<RealType> m_SumOfSquares{ 1 };
160 
161  SizeValueType m_Count{ 1 };
162  PixelType m_ThreadMin{ 1 };
163  PixelType m_ThreadMax{ 1 };
164 
165  std::mutex m_Mutex;
166 }; // end of class
167 } // end namespace itk
168 
169 #ifndef ITK_MANUAL_INSTANTIATION
170 # include "itkStatisticsImageFilter.hxx"
171 #endif
172 
173 #endif
itk::SimpleDataObjectDecorator
Decorates any "simple" data type (data types without smart pointers) with a DataObject API.
Definition: itkSimpleDataObjectDecorator.h:66
itk::CompensatedSummation< RealType >
itk::Concept::HasNumericTraits
Definition: itkConceptChecking.h:712
itk::StatisticsImageFilter::RealType
typename NumericTraits< PixelType >::RealType RealType
Definition: itkStatisticsImageFilter.h:84
itk::StatisticsImageFilter::IndexType
typename TInputImage::IndexType IndexType
Definition: itkStatisticsImageFilter.h:77
itk::StatisticsImageFilter::SizeType
typename TInputImage::SizeType SizeType
Definition: itkStatisticsImageFilter.h:76
itk::ProcessObject::DataObjectIdentifierType
DataObject::DataObjectIdentifierType DataObjectIdentifierType
Definition: itkProcessObject.h:158
itk::StreamingProcessObject
Base class interface to process data on multiple requested input chunks.
Definition: itkStreamingProcessObject.h:40
itk::ImageSink::InputImagePointer
typename InputImageType::Pointer InputImagePointer
Definition: itkImageSink.h:74
itk::GTest::TypedefsAndConstructors::Dimension2::SizeType
ImageBaseType::SizeType SizeType
Definition: itkGTestTypedefsAndConstructors.h:49
itk::StatisticsImageFilter::m_Mutex
std::mutex m_Mutex
Definition: itkStatisticsImageFilter.h:165
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itkCompensatedSummation.h
itk::StatisticsImageFilter::RegionType
typename TInputImage::RegionType RegionType
Definition: itkStatisticsImageFilter.h:75
itk::GTest::TypedefsAndConstructors::Dimension2::IndexType
ImageBaseType::IndexType IndexType
Definition: itkGTestTypedefsAndConstructors.h:50
itk::ImageToImageFilter
Base class for filters that take an image as input and produce an image as output.
Definition: itkImageToImageFilter.h:108
itkImageSink.h
itk::GTest::TypedefsAndConstructors::Dimension2::RegionType
ImageBaseType::RegionType RegionType
Definition: itkGTestTypedefsAndConstructors.h:54
itk::NumericTraits
Define additional traits for native types such as int or float.
Definition: itkNumericTraits.h:58
itkArray.h
itk::StatisticsImageFilter::PixelType
typename TInputImage::PixelType PixelType
Definition: itkStatisticsImageFilter.h:78
itkConceptMacro
#define itkConceptMacro(name, concept)
Definition: itkConceptChecking.h:64
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkArray.h:26
itk::StatisticsImageFilter
Compute min, max, variance and mean of an Image.
Definition: itkStatisticsImageFilter.h:55
itkNumericTraits.h
itkSimpleDataObjectDecorator.h
itk::DataObject::Pointer
SmartPointer< Self > Pointer
Definition: itkDataObject.h:296
itk::ImageSink
Definition: itkImageSink.h:53
itk::SizeValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:83
itk::ImageSink::DataObjectIdentifierType
typename Superclass::DataObjectIdentifierType DataObjectIdentifierType
Definition: itkImageSink.h:82