Medical Imaging Interaction Toolkit  2021.10.00
Medical Imaging Interaction Toolkit
mitkExtendedStatisticsImageFilter.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 #ifndef __mitkExtendedStatisticsImageFilter
13 #define __mitkExtendedStatisticsImageFilter
14 
15 #include "itkStatisticsImageFilter.h"
16 #include <mbilog.h>
17 #include <mitkLogMacros.h>
18 
19 namespace itk
20 {
33  template< class TInputImage >
34  class ExtendedStatisticsImageFilter : public StatisticsImageFilter< TInputImage >
35  {
36  public:
39  typedef StatisticsImageFilter< TInputImage > Superclass;
42  typedef typename Superclass::RealType RealType;
43  typedef typename Superclass::RealObjectType RealObjectType;
44  typedef typename Superclass::PixelType PixelType;
45 
47  typedef itk::Statistics::Histogram< RealType > HistogramType;
48  typedef typename HistogramType::Pointer HistogramPointer;
49 
50  itkFactorylessNewMacro( Self );
51  itkCloneMacro( Self );
52  itkTypeMacro( ExtendedStatisticsImageFilter, StatisticsImageFilter );
53 
57  double GetSkewness() const
58  {
59  return this->GetSkewnessOutput()->Get();
60  }
61 
65  double GetMedian() const
66  {
67  return this->GetMedianOutput()->Get();
68  }
69 
73  double GetKurtosis() const
74  {
75  return this->GetKurtosisOutput()->Get();
76  }
77 
78  /* \brief Return the computed MPP.
79  */
80  double GetMPP() const
81  {
82  return this->GetMPPOutput()->Get();
83  }
84 
88  double GetUniformity() const
89  {
90  return this->GetUniformityOutput()->Get();
91  }
92 
96  double GetEntropy() const
97  {
98  return this->GetEntropyOutput()->Get();
99  }
100 
104  double GetUPP() const
105  {
106  return this->GetUPPOutput()->Get();
107  }
108 
109 
113  const typename HistogramType::Pointer
115  {
116  if (m_HistogramCalculated)
117  {
118  return m_Histogram;
119  }
120  else
121  {
122  return nullptr;
123  }
124  }
125 
126 
128  void SetHistogramParameters(const int numBins, RealType lowerBound,
129  RealType upperBound);
130 
131  protected:
132 
134 
136 
137  void BeforeThreadedGenerateData() override;
138 
140  void ThreadedGenerateData(const typename StatisticsImageFilter<TInputImage>::RegionType &
141  outputRegionForThread,
142  ThreadIdType threadId) override;
143 
147  void AfterThreadedGenerateData() override;
148 
149 
150  RealObjectType* GetSkewnessOutput();
151 
152  const RealObjectType* GetSkewnessOutput() const;
153 
154  RealObjectType* GetKurtosisOutput();
155 
156  const RealObjectType* GetKurtosisOutput() const;
157 
158  RealObjectType* GetMPPOutput();
159 
160  const RealObjectType* GetMPPOutput() const;
161 
162  RealObjectType* GetEntropyOutput();
163 
164  const RealObjectType* GetEntropyOutput() const;
165 
166  RealObjectType* GetUniformityOutput();
167 
168  const RealObjectType* GetUniformityOutput() const;
169 
170  RealObjectType* GetUPPOutput();
171 
172  const RealObjectType* GetUPPOutput() const;
173 
174  RealObjectType* GetMedianOutput();
175 
176  const RealObjectType* GetMedianOutput() const;
177 
178  using Superclass::MakeOutput;
179  DataObject::Pointer MakeOutput( ProcessObject::DataObjectPointerArraySizeType idx ) override;
180 
181 private:
182  Array< RealType > m_ThreadSum;
183  Array< RealType > m_SumOfSquares;
184  Array< RealType > m_SumOfCubes;
185  Array< RealType > m_SumOfQuadruples;
186  Array< SizeValueType > m_Count;
187  Array< SizeValueType > m_PositivePixelCount;
188  Array< RealType > m_ThreadSumOfPositivePixels;
189  Array< PixelType > m_ThreadMin;
190  Array< PixelType > m_ThreadMax;
191  std::vector< HistogramPointer > m_HistogramPerThread;
192  HistogramPointer m_Histogram;
193  bool m_UseHistogram;
194  bool m_HistogramCalculated;
195  RealType m_LowerBound, m_UpperBound;
196  int m_NumBins;
197 
198 
199  }; // end of class
200 
201 } // end namespace itk
202 
203 #ifndef ITK_MANUAL_INSTANTIATION
204 #include "mitkExtendedStatisticsImageFilter.hxx"
205 #endif
206 
207 #endif
double GetMedian() const
Return the computed Median.
RealObjectType * GetMedianOutput()
DataObject::Pointer MakeOutput(ProcessObject::DataObjectPointerArraySizeType idx) override
const HistogramType::Pointer GetHistogram()
Return the computed Histogram.
double GetKurtosis() const
Return the computed Kurtosis.
RealObjectType * GetEntropyOutput()
void ThreadedGenerateData(const typename StatisticsImageFilter< TInputImage >::RegionType &outputRegionForThread, ThreadIdType threadId) override
RealObjectType * GetSkewnessOutput()
double GetSkewness() const
Return the computed Skewness.
RealObjectType * GetUniformityOutput()
void BeforeThreadedGenerateData() override
void SetHistogramParameters(const int numBins, RealType lowerBound, RealType upperBound)
RealObjectType * GetKurtosisOutput()
void AfterThreadedGenerateData() override
double GetUPP() const
Return the computed UPP.
itk::Statistics::Histogram< RealType > HistogramType
double GetEntropy() const
Return the computed Entropy.
Extension of the itkStatisticsImageFilter that also calculates the Skewness and Kurtosis.
StatisticsImageFilter< TInputImage > Superclass
double GetUniformity() const
Return the computed Uniformity.