Medical Imaging Interaction Toolkit  2023.04.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 {
37  {
38  public:
41 
43  virtual ~ImageStatisticsHolder();
44 
45  typedef itk::Statistics::Histogram<double> HistogramType;
46 
47  virtual const HistogramType *GetScalarHistogram(int t = 0, unsigned int = 0);
48 
49  //##Documentation
50  //## \brief Get the minimum for scalar images. Recomputation performed only when necessary.
51  virtual ScalarType GetScalarValueMin(int t = 0, unsigned int component = 0);
52 
53  //##Documentation
54  //## \brief Get the maximum for scalar images. Recomputation performed only when necessary.
55  virtual ScalarType GetScalarValueMax(int t = 0, unsigned int component = 0);
56 
57  //##Documentation
58  //## \brief Get the second smallest value for scalar images.
59  //## Recomputation performed only when necessary.
60  //## \post The returned value is always a finite value.
61  virtual ScalarType GetScalarValue2ndMin(int t = 0, unsigned int component = 0);
62 
63  //##Documentation
64  //## \brief Get the smallest value for scalar images, but do not recompute it first
65  virtual mitk::ScalarType GetScalarValueMinNoRecompute(unsigned int t = 0) const
66  {
67  if (t < m_ScalarMin.size())
68  return m_ScalarMin[t];
69  else
70  return itk::NumericTraits<ScalarType>::max();
71  }
72 
73  //##Documentation
74  //## \brief Get the second smallest value for scalar images, but do not recompute it first
75  //## \post The returned value is always a finite value.
76  virtual mitk::ScalarType GetScalarValue2ndMinNoRecompute(unsigned int t = 0) const
77  {
78  if (t < m_Scalar2ndMin.size())
79  return m_Scalar2ndMin[t];
80  else
81  return itk::NumericTraits<ScalarType>::max();
82  }
83 
84  //##Documentation
85  //## \brief Get the second largest value for scalar images
86  //## \post The returned value is always a finite value.
87  virtual ScalarType GetScalarValue2ndMax(int t = 0, unsigned int component = 0);
88 
89  //##Documentation
90  //## \brief Get the largest value for scalar images, but do not recompute it first
91  //## \post The returned value is always a finite value.
92  virtual mitk::ScalarType GetScalarValueMaxNoRecompute(unsigned int t = 0)
93  {
94  if (t < m_ScalarMax.size())
95  return m_ScalarMax[t];
96  else
97  return itk::NumericTraits<ScalarType>::NonpositiveMin();
98  }
99 
100  //##Documentation
101  //## \brief Get the second largest value for scalar images, but do not recompute it first
103  {
104  if (t < m_Scalar2ndMax.size())
105  return m_Scalar2ndMax[t];
106  else
107  return itk::NumericTraits<ScalarType>::NonpositiveMin();
108  }
109 
110  //##Documentation
111  //## \brief Get the count of voxels with the smallest scalar value in the dataset
112  mitk::ScalarType GetCountOfMinValuedVoxels(int t = 0, unsigned int component = 0);
113 
114  //##Documentation
115  //## \brief Get the count of voxels with the largest scalar value in the dataset
116  mitk::ScalarType GetCountOfMaxValuedVoxels(int t = 0, unsigned int component = 0);
117 
118  //##Documentation
119  //## \brief Get the count of voxels with the largest scalar value in the dataset
120  virtual unsigned int GetCountOfMaxValuedVoxelsNoRecompute(unsigned int t = 0)
121  {
122  if (t < m_CountOfMaxValuedVoxels.size())
123  return m_CountOfMaxValuedVoxels[t];
124  else
125  return 0;
126  }
127 
128  //##Documentation
129  //## \brief Get the count of voxels with the smallest scalar value in the dataset
130  virtual unsigned int GetCountOfMinValuedVoxelsNoRecompute(unsigned int t = 0) const
131  {
132  if (t < m_CountOfMinValuedVoxels.size())
133  return m_CountOfMinValuedVoxels[t];
134  else
135  return 0;
136  }
137 
138  bool IsValidTimeStep(int t) const;
139 
140  template <typename ItkImageType>
141  friend void _ComputeExtremaInItkImage(const ItkImageType *itkImage,
142  mitk::ImageStatisticsHolder *statisticsHolder,
143  int t);
144 
145  template <typename ItkImageType>
146  friend void _ComputeExtremaInItkVectorImage(const ItkImageType *itkImage,
147  mitk::ImageStatisticsHolder *statisticsHolder,
148  int t,
149  unsigned int component);
150 
151  protected:
152  virtual void ResetImageStatistics();
153 
154  virtual void ComputeImageStatistics(int t = 0, unsigned int component = 0);
155 
156  virtual void Expand(unsigned int timeSteps);
157 
158  ImageTimeSelector::Pointer GetTimeSelector();
159 
161 
162  mutable itk::Object::Pointer m_HistogramGeneratorObject;
163 
164  mutable itk::Object::Pointer m_TimeSelectorForExtremaObject;
165  mutable std::vector<unsigned int> m_CountOfMinValuedVoxels;
166  mutable std::vector<unsigned int> m_CountOfMaxValuedVoxels;
167  mutable std::vector<ScalarType> m_ScalarMin;
168  mutable std::vector<ScalarType> m_ScalarMax;
169  mutable std::vector<ScalarType> m_Scalar2ndMin;
170  mutable std::vector<ScalarType> m_Scalar2ndMax;
171 
172  itk::TimeStamp m_LastRecomputeTimeStamp;
173  };
174 
175 } // end namespace
176 #endif
mitk::ImageStatisticsHolder
Class holding the statistics information about a single mitk::Image.
Definition: mitkImageStatisticsHolder.h:36
mitk::ImageStatisticsHolder::m_HistogramGeneratorObject
itk::Object::Pointer m_HistogramGeneratorObject
Definition: mitkImageStatisticsHolder.h:162
mitk::ImageStatisticsHolder::m_ScalarMax
std::vector< ScalarType > m_ScalarMax
Definition: mitkImageStatisticsHolder.h:168
mitkImage.h
mitk::ImageStatisticsHolder::HistogramType
itk::Statistics::Histogram< double > HistogramType
Definition: mitkImageStatisticsHolder.h:45
mitk::ImageStatisticsHolder::GetCountOfMaxValuedVoxelsNoRecompute
virtual unsigned int GetCountOfMaxValuedVoxelsNoRecompute(unsigned int t=0)
Get the count of voxels with the largest scalar value in the dataset.
Definition: mitkImageStatisticsHolder.h:120
mitkImageTimeSelector.h
mitk::ImageStatisticsHolder::m_LastRecomputeTimeStamp
itk::TimeStamp m_LastRecomputeTimeStamp
Definition: mitkImageStatisticsHolder.h:172
mitk::Image
Image class for storing images.
Definition: mitkImage.h:69
itk::SmartPointer< Self >
mitk::ImageStatisticsHolder::m_Scalar2ndMax
std::vector< ScalarType > m_Scalar2ndMax
Definition: mitkImageStatisticsHolder.h:170
mitk::ImageStatisticsHolder::m_Scalar2ndMin
std::vector< ScalarType > m_Scalar2ndMin
Definition: mitkImageStatisticsHolder.h:169
mitk
DataCollection - Class to facilitate loading/accessing structured data.
Definition: RenderingTests.dox:1
mitk::ImageStatisticsHolder::m_Image
mitk::Image * m_Image
Definition: mitkImageStatisticsHolder.h:160
mitk::ImageStatisticsHolder::GetScalarValue2ndMaxNoRecompute
virtual mitk::ScalarType GetScalarValue2ndMaxNoRecompute(unsigned int t=0)
Get the second largest value for scalar images, but do not recompute it first.
Definition: mitkImageStatisticsHolder.h:102
MitkCoreExports.h
mitk::ImageStatisticsHolder::GetScalarValueMaxNoRecompute
virtual mitk::ScalarType GetScalarValueMaxNoRecompute(unsigned int t=0)
Get the largest value for scalar images, but do not recompute it first.
Definition: mitkImageStatisticsHolder.h:92
mitk::ImageStatisticsHolder::GetScalarValue2ndMinNoRecompute
virtual mitk::ScalarType GetScalarValue2ndMinNoRecompute(unsigned int t=0) const
Get the second smallest value for scalar images, but do not recompute it first.
Definition: mitkImageStatisticsHolder.h:76
mitk::ImageStatisticsHolder::m_ScalarMin
std::vector< ScalarType > m_ScalarMin
Definition: mitkImageStatisticsHolder.h:167
mitk::ImageStatisticsHolder::m_CountOfMinValuedVoxels
std::vector< unsigned int > m_CountOfMinValuedVoxels
Definition: mitkImageStatisticsHolder.h:165
mitk::ImageStatisticsHolder::m_TimeSelectorForExtremaObject
itk::Object::Pointer m_TimeSelectorForExtremaObject
Definition: mitkImageStatisticsHolder.h:164
mitk::ImageStatisticsHolder::GetScalarValueMinNoRecompute
virtual mitk::ScalarType GetScalarValueMinNoRecompute(unsigned int t=0) const
Get the smallest value for scalar images, but do not recompute it first.
Definition: mitkImageStatisticsHolder.h:65
mitk::ImageStatisticsHolder::m_CountOfMaxValuedVoxels
std::vector< unsigned int > m_CountOfMaxValuedVoxels
Definition: mitkImageStatisticsHolder.h:166
mitk::ImageStatisticsHolder::GetCountOfMinValuedVoxelsNoRecompute
virtual unsigned int GetCountOfMinValuedVoxelsNoRecompute(unsigned int t=0) const
Get the count of voxels with the smallest scalar value in the dataset.
Definition: mitkImageStatisticsHolder.h:130
MITKCORE_EXPORT
#define MITKCORE_EXPORT
Definition: MitkCoreExports.h:15
mitk::ScalarType
double ScalarType
Definition: mitkNumericConstants.h:20