Medical Imaging Interaction Toolkit  2018.4.99-a3d2e8fb
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
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
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 // MITKIMAGESTATISTICSHOLDER_H
#define MITKCORE_EXPORT
itk::Object::Pointer m_TimeSelectorForExtremaObject
double ScalarType
itk::Object::Pointer m_HistogramGeneratorObject
std::vector< unsigned int > m_CountOfMaxValuedVoxels
std::vector< unsigned int > m_CountOfMinValuedVoxels
virtual mitk::ScalarType GetScalarValue2ndMaxNoRecompute(unsigned int t=0)
Get the second largest value for scalar images, but do not recompute it first.
DataCollection - Class to facilitate loading/accessing structured data.
virtual mitk::ScalarType GetScalarValueMaxNoRecompute(unsigned int t=0)
Get the largest value for scalar images, but do not recompute it first.
virtual unsigned int GetCountOfMaxValuedVoxelsNoRecompute(unsigned int t=0)
Get the count of voxels with the largest scalar value in the dataset.
Image class for storing images.
Definition: mitkImage.h:72
static T max(T x, T y)
Definition: svm.cpp:56
mitk::Image::Pointer image
virtual mitk::ScalarType GetScalarValueMinNoRecompute(unsigned int t=0) const
Get the smallest value for scalar images, but do not recompute it first.
Class holding the statistics informations about a single mitk::Image.
virtual unsigned int GetCountOfMinValuedVoxelsNoRecompute(unsigned int t=0) const
Get the count of voxels with the smallest scalar value in the dataset.
std::vector< ScalarType > m_ScalarMax
itk::Statistics::Histogram< double > HistogramType
std::vector< ScalarType > m_Scalar2ndMin
std::vector< ScalarType > m_Scalar2ndMax
virtual mitk::ScalarType GetScalarValue2ndMinNoRecompute(unsigned int t=0) const
Get the second smallest value for scalar images, but do not recompute it first.
std::vector< ScalarType > m_ScalarMin