Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitkStatisticsImageFilter.h
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #ifndef mitkStatisticsImageFilter_h
14 #define mitkStatisticsImageFilter_h
15 
16 // This file is based on ITK's itkStatisticsImageFilter.h
17 
18 #include <mitkCommon.h>
19 
20 #include <itkArray.h>
21 #include <itkCompensatedSummation.h>
22 #include <itkHistogram.h>
23 #include <itkImageSink.h>
24 #include <itkNumericTraits.h>
25 #include <itkSimpleDataObjectDecorator.h>
26 
27 #include <mutex>
28 
29 namespace mitk
30 {
47  template <typename TInputImage>
48  class StatisticsImageFilter : public itk::ImageSink<TInputImage>
49  {
50  public:
52  using Superclass = itk::ImageSink<TInputImage>;
55 
56  itkFactorylessNewMacro(Self);
57 
58  itkTypeMacro(StatisticsImageFilter, itk::ImageSink);
59 
60  using RegionType = typename TInputImage::RegionType;
61  using PixelType = typename TInputImage::PixelType;
62 
63  using RealType = typename itk::NumericTraits<PixelType>::RealType;
64 
65  using HistogramType = typename itk::Statistics::Histogram<RealType>;
67 
68  using DataObjectPointer = typename itk::DataObject::Pointer;
69 
70  template <typename T>
71  using SimpleDataObjectDecorator = itk::SimpleDataObjectDecorator<T>;
72 
75  using ProcessObject = itk::ProcessObject;
76 
94 
101  void SetHistogramParameters(unsigned int size, RealType lowerBound, RealType upperBound);
102 
103  using DataObjectIdentifierType = itk::ProcessObject::DataObjectIdentifierType;
104  using Superclass::MakeOutput;
105 
108 
109  protected:
112 
130 
131  void BeforeStreamedGenerateData() override;
133  void AfterStreamedGenerateData() override;
134 
135  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
136 
137  private:
138  HistogramPointer CreateInitializedHistogram() const;
139 
140  bool m_ComputeHistogram;
141  unsigned int m_HistogramSize;
142  RealType m_HistogramLowerBound;
143  RealType m_HistogramUpperBound;
144  HistogramPointer m_Histogram;
145 
146  itk::CompensatedSummation<RealType> m_Sum;
147  itk::CompensatedSummation<RealType> m_SumOfPositivePixels;
148  itk::CompensatedSummation<RealType> m_SumOfSquares;
149  itk::CompensatedSummation<RealType> m_SumOfCubes;
150  itk::CompensatedSummation<RealType> m_SumOfQuadruples;
151 
152  itk::SizeValueType m_Count;
153  itk::SizeValueType m_CountOfPositivePixels;
154  PixelType m_Min;
155  PixelType m_Max;
156 
157  std::mutex m_Mutex;
158  };
159 }
160 
161 #ifndef ITK_MANUAL_INSTANTIATION
162 #include <mitkStatisticsImageFilter.tpp>
163 #endif
164 
165 #endif
Compute comprehensive image statistics including moments, histogram, entropy, and median.
itkSetDecoratedOutputMacro(Entropy, RealType)
itkSetDecoratedOutputMacro(Mean, RealType)
itkSetDecoratedOutputMacro(Sum, RealType)
itkSetDecoratedOutputMacro(Skewness, RealType)
itkSetDecoratedOutputMacro(Maximum, PixelType)
itkGetDecoratedOutputMacro(Maximum, PixelType)
itkSetDecoratedOutputMacro(Median, RealType)
itkSetDecoratedOutputMacro(MPP, RealType)
itkGetDecoratedOutputMacro(SumOfSquares, RealType)
typename itk::NumericTraits< PixelType >::RealType RealType
SimpleDataObjectDecorator< PixelType > PixelObjectType
typename TInputImage::PixelType PixelType
itkGetDecoratedOutputMacro(Sum, RealType)
itkSetDecoratedOutputMacro(Sigma, RealType)
itk::SimpleDataObjectDecorator< T > SimpleDataObjectDecorator
itkGetDecoratedOutputMacro(SumOfCubes, RealType)
void SetHistogramParameters(unsigned int size, RealType lowerBound, RealType upperBound)
Set the histogram parameters.
SimpleDataObjectDecorator< RealType > RealObjectType
itkGetDecoratedOutputMacro(Minimum, PixelType)
itkGetDecoratedOutputMacro(Kurtosis, RealType)
void ThreadedStreamedGenerateData(const RegionType &) override
itkSetDecoratedOutputMacro(SumOfSquares, RealType)
itkGetDecoratedOutputMacro(Sigma, RealType)
typename itk::Statistics::Histogram< RealType > HistogramType
itkSetDecoratedOutputMacro(SumOfCubes, RealType)
itkGetDecoratedOutputMacro(Entropy, RealType)
itkGetDecoratedOutputMacro(Mean, RealType)
typename itk::DataObject::Pointer DataObjectPointer
itkGetDecoratedOutputMacro(Median, RealType)
void PrintSelf(std::ostream &os, itk::Indent indent) const override
itkGetDecoratedOutputMacro(Variance, RealType)
itkGetDecoratedOutputMacro(Skewness, RealType)
void BeforeStreamedGenerateData() override
itkSetDecoratedOutputMacro(Minimum, PixelType)
void AfterStreamedGenerateData() override
itkSetDecoratedOutputMacro(UPP, RealType)
DataObjectPointer MakeOutput(const DataObjectIdentifierType &name) override
itkSetDecoratedOutputMacro(SumOfQuadruples, RealType)
itkGetDecoratedOutputMacro(MPP, RealType)
itkSetDecoratedOutputMacro(Variance, RealType)
itkSetDecoratedOutputMacro(Histogram, HistogramPointer)
itkGetDecoratedOutputMacro(Histogram, HistogramPointer)
itkGetDecoratedOutputMacro(SumOfQuadruples, RealType)
itkSetDecoratedOutputMacro(Uniformity, RealType)
itk::ProcessObject::DataObjectIdentifierType DataObjectIdentifierType
itkGetDecoratedOutputMacro(UPP, RealType)
itkGetDecoratedOutputMacro(Uniformity, RealType)
itk::ImageSink< TInputImage > Superclass
itkSetDecoratedOutputMacro(Kurtosis, RealType)
typename TInputImage::RegionType RegionType
Find image slices visible on a given plane.