Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitkImageStatisticsHolder.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 mitkImageStatisticsHolder_h
13 #define mitkImageStatisticsHolder_h
14 
15 #include <mitkImage.h>
16 #include <mitkImageTimeSelector.h>
17 #include <MitkCoreExports.h>
18 
19 #ifndef __itkHistogram_h
20 #include <itkHistogram.h>
21 #endif
22 
23 namespace mitk
24 {
40  {
41  public:
48 
51 
52  typedef itk::Statistics::Histogram<double> HistogramType;
53 
60  virtual const HistogramType *GetScalarHistogram(int t = 0, unsigned int = 0);
61 
69  virtual ScalarType GetScalarValueMin(int t = 0, unsigned int component = 0);
70 
78  virtual ScalarType GetScalarValueMax(int t = 0, unsigned int component = 0);
79 
88  virtual ScalarType GetScalarValue2ndMin(int t = 0, unsigned int component = 0);
89 
96  virtual mitk::ScalarType GetScalarValueMinNoRecompute(unsigned int t = 0) const
97  {
98  if (t < m_ScalarMin.size())
99  return m_ScalarMin[t];
100  else
101  return itk::NumericTraits<ScalarType>::max();
102  }
103 
111  virtual mitk::ScalarType GetScalarValue2ndMinNoRecompute(unsigned int t = 0) const
112  {
113  if (t < m_Scalar2ndMin.size())
114  return m_Scalar2ndMin[t];
115  else
116  return itk::NumericTraits<ScalarType>::max();
117  }
118 
127  virtual ScalarType GetScalarValue2ndMax(int t = 0, unsigned int component = 0);
128 
136  virtual mitk::ScalarType GetScalarValueMaxNoRecompute(unsigned int t = 0)
137  {
138  if (t < m_ScalarMax.size())
139  return m_ScalarMax[t];
140  else
141  return itk::NumericTraits<ScalarType>::NonpositiveMin();
142  }
143 
151  {
152  if (t < m_Scalar2ndMax.size())
153  return m_Scalar2ndMax[t];
154  else
155  return itk::NumericTraits<ScalarType>::NonpositiveMin();
156  }
157 
165  mitk::ScalarType GetCountOfMinValuedVoxels(int t = 0, unsigned int component = 0);
166 
174  mitk::ScalarType GetCountOfMaxValuedVoxels(int t = 0, unsigned int component = 0);
175 
182  virtual unsigned int GetCountOfMaxValuedVoxelsNoRecompute(unsigned int t = 0)
183  {
184  if (t < m_CountOfMaxValuedVoxels.size())
185  return m_CountOfMaxValuedVoxels[t];
186  else
187  return 0;
188  }
189 
196  virtual unsigned int GetCountOfMinValuedVoxelsNoRecompute(unsigned int t = 0) const
197  {
198  if (t < m_CountOfMinValuedVoxels.size())
199  return m_CountOfMinValuedVoxels[t];
200  else
201  return 0;
202  }
203 
210  bool IsValidTimeStep(int t) const;
211 
212  template <typename ItkImageType>
213  friend void _ComputeExtremaInItkImage(const ItkImageType *itkImage,
214  mitk::ImageStatisticsHolder *statisticsHolder,
215  int t);
216 
217  template <typename ItkImageType>
218  friend void _ComputeExtremaInItkVectorImage(const ItkImageType *itkImage,
219  mitk::ImageStatisticsHolder *statisticsHolder,
220  int t,
221  unsigned int component);
222 
223  protected:
225  virtual void ResetImageStatistics();
226 
233  virtual void ComputeImageStatistics(int t = 0, unsigned int component = 0);
234 
240  virtual void Expand(unsigned int timeSteps);
241 
247  ImageTimeSelector::Pointer GetTimeSelector();
248 
250 
251  mutable itk::Object::Pointer m_HistogramGeneratorObject;
252 
253  mutable itk::Object::Pointer m_TimeSelectorForExtremaObject;
254  mutable std::vector<unsigned int> m_CountOfMinValuedVoxels;
255  mutable std::vector<unsigned int> m_CountOfMaxValuedVoxels;
256  mutable std::vector<ScalarType> m_ScalarMin;
257  mutable std::vector<ScalarType> m_ScalarMax;
258  mutable std::vector<ScalarType> m_Scalar2ndMin;
259  mutable std::vector<ScalarType> m_Scalar2ndMax;
260 
261  itk::TimeStamp m_LastRecomputeTimeStamp;
262  };
263 
264 } // end namespace
265 #endif
#define MITKCORE_EXPORT
Class holding the statistics information about a single mitk::Image.
std::vector< ScalarType > m_ScalarMax
virtual unsigned int GetCountOfMinValuedVoxelsNoRecompute(unsigned int t=0) const
Get the count of voxels with the smallest scalar value without triggering recomputation.
virtual mitk::ScalarType GetScalarValue2ndMaxNoRecompute(unsigned int t=0)
Get the second largest scalar value without triggering recomputation.
std::vector< ScalarType > m_Scalar2ndMax
virtual mitk::ScalarType GetScalarValue2ndMinNoRecompute(unsigned int t=0) const
Get the second smallest scalar value without triggering recomputation.
virtual mitk::ScalarType GetScalarValueMinNoRecompute(unsigned int t=0) const
Get the smallest scalar value without triggering recomputation.
std::vector< ScalarType > m_Scalar2ndMin
virtual void ComputeImageStatistics(int t=0, unsigned int component=0)
Compute image statistics for the specified time step and component.
virtual ScalarType GetScalarValueMin(int t=0, unsigned int component=0)
Get the minimum scalar value. Recomputation performed only when necessary.
itk::Statistics::Histogram< double > HistogramType
virtual ScalarType GetScalarValueMax(int t=0, unsigned int component=0)
Get the maximum scalar value. Recomputation performed only when necessary.
ImageTimeSelector::Pointer GetTimeSelector()
Get an ImageTimeSelector configured with the associated image as input.
itk::Object::Pointer m_TimeSelectorForExtremaObject
std::vector< ScalarType > m_ScalarMin
std::vector< unsigned int > m_CountOfMaxValuedVoxels
virtual unsigned int GetCountOfMaxValuedVoxelsNoRecompute(unsigned int t=0)
Get the count of voxels with the largest scalar value without triggering recomputation.
itk::Object::Pointer m_HistogramGeneratorObject
friend void _ComputeExtremaInItkImage(const ItkImageType *itkImage, mitk::ImageStatisticsHolder *statisticsHolder, int t)
ImageStatisticsHolder(mitk::Image *image)
Constructor.
mitk::ScalarType GetCountOfMinValuedVoxels(int t=0, unsigned int component=0)
Get the count of voxels with the smallest scalar value. Recomputation performed only when necessary.
mitk::ScalarType GetCountOfMaxValuedVoxels(int t=0, unsigned int component=0)
Get the count of voxels with the largest scalar value. Recomputation performed only when necessary.
virtual void Expand(unsigned int timeSteps)
Expand internal statistics storage to accommodate the given number of time steps.
virtual mitk::ScalarType GetScalarValueMaxNoRecompute(unsigned int t=0)
Get the largest scalar value without triggering recomputation.
friend void _ComputeExtremaInItkVectorImage(const ItkImageType *itkImage, mitk::ImageStatisticsHolder *statisticsHolder, int t, unsigned int component)
bool IsValidTimeStep(int t) const
Check whether the given time step is valid for the associated image.
virtual ~ImageStatisticsHolder()
Destructor.
std::vector< unsigned int > m_CountOfMinValuedVoxels
virtual ScalarType GetScalarValue2ndMax(int t=0, unsigned int component=0)
Get the second largest scalar value. Recomputation performed only when necessary.
virtual const HistogramType * GetScalarHistogram(int t=0, unsigned int=0)
Get the scalar histogram for the specified time step.
virtual void ResetImageStatistics()
Reset all cached statistics values to their initial state.
virtual ScalarType GetScalarValue2ndMin(int t=0, unsigned int component=0)
Get the second smallest scalar value. Recomputation performed only when necessary.
Image class for storing multi-dimensional medical image data.
Definition: mitkImage.h:76
Find image slices visible on a given plane.
double ScalarType
Scalar type used throughout MITK for geometric computations.