Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 #ifndef MITKIMAGESTATISTICSHOLDER_H
17 #define MITKIMAGESTATISTICSHOLDER_H
18 
19 #include "mitkImage.h"
20 #include "mitkImageTimeSelector.h"
21 #include <MitkCoreExports.h>
22 
23 #ifndef __itkHistogram_h
24 #include <itkHistogram.h>
25 #endif
26 
27 namespace mitk
28 {
40  {
41  public:
44 
46  virtual ~ImageStatisticsHolder();
47 
48  typedef itk::Statistics::Histogram<double> HistogramType;
49 
50  virtual const HistogramType *GetScalarHistogram(int t = 0, unsigned int = 0);
51 
52  //##Documentation
53  //## \brief Get the minimum for scalar images. Recomputation performed only when necessary.
54  virtual ScalarType GetScalarValueMin(int t = 0, unsigned int component = 0);
55 
56  //##Documentation
57  //## \brief Get the maximum for scalar images. Recomputation performed only when necessary.
58  virtual ScalarType GetScalarValueMax(int t = 0, unsigned int component = 0);
59 
60  //##Documentation
61  //## \brief Get the second smallest value for scalar images. Recomputation performed only when necessary.
62  virtual ScalarType GetScalarValue2ndMin(int t = 0, unsigned int component = 0);
63 
64  //##Documentation
65  //## \brief Get the smallest value for scalar images, but do not recompute it first
66  virtual mitk::ScalarType GetScalarValueMinNoRecompute(unsigned int t = 0) const
67  {
68  if (t < m_ScalarMin.size())
69  return m_ScalarMin[t];
70  else
72  }
73 
74  //##Documentation
75  //## \brief Get the second smallest value for scalar images, but do not recompute it first
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  virtual ScalarType GetScalarValue2ndMax(int t = 0, unsigned int component = 0);
87 
88  //##Documentation
89  //## \brief Get the largest value for scalar images, but do not recompute it first
90  virtual mitk::ScalarType GetScalarValueMaxNoRecompute(unsigned int t = 0)
91  {
92  if (t < m_ScalarMax.size())
93  return m_ScalarMax[t];
94  else
95  return itk::NumericTraits<ScalarType>::NonpositiveMin();
96  }
97 
98  //##Documentation
99  //## \brief Get the second largest value for scalar images, but do not recompute it first
101  {
102  if (t < m_Scalar2ndMax.size())
103  return m_Scalar2ndMax[t];
104  else
105  return itk::NumericTraits<ScalarType>::NonpositiveMin();
106  }
107 
108  //##Documentation
109  //## \brief Get the count of voxels with the smallest scalar value in the dataset
110  mitk::ScalarType GetCountOfMinValuedVoxels(int t = 0, unsigned int component = 0);
111 
112  //##Documentation
113  //## \brief Get the count of voxels with the largest scalar value in the dataset
114  mitk::ScalarType GetCountOfMaxValuedVoxels(int t = 0, unsigned int component = 0);
115 
116  //##Documentation
117  //## \brief Get the count of voxels with the largest scalar value in the dataset
118  virtual unsigned int GetCountOfMaxValuedVoxelsNoRecompute(unsigned int t = 0)
119  {
120  if (t < m_CountOfMaxValuedVoxels.size())
121  return m_CountOfMaxValuedVoxels[t];
122  else
123  return 0;
124  }
125 
126  //##Documentation
127  //## \brief Get the count of voxels with the smallest scalar value in the dataset
128  virtual unsigned int GetCountOfMinValuedVoxelsNoRecompute(unsigned int t = 0) const
129  {
130  if (t < m_CountOfMinValuedVoxels.size())
131  return m_CountOfMinValuedVoxels[t];
132  else
133  return 0;
134  }
135 
136  bool IsValidTimeStep(int t) const;
137 
138  template <typename ItkImageType>
139  friend void _ComputeExtremaInItkImage(const ItkImageType *itkImage,
140  mitk::ImageStatisticsHolder *statisticsHolder,
141  int t);
142 
143  template <typename ItkImageType>
144  friend void _ComputeExtremaInItkVectorImage(const ItkImageType *itkImage,
145  mitk::ImageStatisticsHolder *statisticsHolder,
146  int t,
147  unsigned int component);
148 
149  protected:
150  virtual void ResetImageStatistics();
151 
152  virtual void ComputeImageStatistics(int t = 0, unsigned int component = 0);
153 
154  virtual void Expand(unsigned int timeSteps);
155 
156  ImageTimeSelector::Pointer GetTimeSelector();
157 
159 
161 
163  mutable std::vector<unsigned int> m_CountOfMinValuedVoxels;
164  mutable std::vector<unsigned int> m_CountOfMaxValuedVoxels;
165  mutable std::vector<ScalarType> m_ScalarMin;
166  mutable std::vector<ScalarType> m_ScalarMax;
167  mutable std::vector<ScalarType> m_Scalar2ndMin;
168  mutable std::vector<ScalarType> m_Scalar2ndMax;
169 
170  itk::TimeStamp m_LastRecomputeTimeStamp;
171  };
172 
173 } // end namespace
174 #endif // MITKIMAGESTATISTICSHOLDER_H
itk::SmartPointer< Self > Pointer
#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 GetScalarValueMinNoRecompute(unsigned int t=0) const
Get the smallest value for scalar images, but do not recompute it first.
virtual mitk::ScalarType GetScalarValue2ndMinNoRecompute(unsigned int t=0) const
Get the second smallest value for scalar images, but do not recompute it first.
virtual unsigned int GetCountOfMinValuedVoxelsNoRecompute(unsigned int t=0) const
Get the count of voxels with the smallest scalar value in the dataset.
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:76
static T max(T x, T y)
Definition: svm.cpp:70
Class holding the statistics informations about a single mitk::Image.
std::vector< ScalarType > m_ScalarMax
itk::Statistics::Histogram< double > HistogramType
std::vector< ScalarType > m_Scalar2ndMin
std::vector< ScalarType > m_Scalar2ndMax
std::vector< ScalarType > m_ScalarMin