Medical Imaging Interaction Toolkit  2018.4.99-a3d2e8fb
Medical Imaging Interaction Toolkit
mitkImageStatisticsCalculator.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 
13 #ifndef MITKIMAGESTATISTICSCALCULATOR
14 #define MITKIMAGESTATISTICSCALCULATOR
15 
17 #include <mitkImage.h>
18 #include <mitkMaskGenerator.h>
20 
21 namespace mitk
22 {
24  {
25  public:
28  typedef itk::Object Superclass;
31 
33  itkNewMacro(Self);
34  itkTypeMacro(ImageStatisticsCalculator_v2, itk::Object);
35 
36  typedef double statisticsValueType;
37  typedef std::map<std::string, statisticsValueType> statisticsMapType;
38  typedef itk::Statistics::Histogram<double> HistogramType;
39  typedef unsigned short MaskPixelType;
41 
44  void SetInputImage(const mitk::Image* image);
45 
48  void SetMask(mitk::MaskGenerator* mask);
49 
53  void SetSecondaryMask(mitk::MaskGenerator* mask);
54 
57  void SetNBinsForHistogramStatistics(unsigned int nBins);
58 
62  unsigned int GetNBinsForHistogramStatistics() const;
63 
66  void SetBinSizeForHistogramStatistics(double binSize);
67 
71  double GetBinSizeForHistogramStatistics() const;
72 
77  ImageStatisticsContainer* GetStatistics(LabelIndex label=1);
78 
79  protected:
81  m_nBinsForHistogramStatistics = 100;
82  m_binSizeForHistogramStatistics = 10;
83  m_UseBinSizeOverNBins = false;
84  };
85 
86 
87  private:
88  //Calculates statistics for each timestep for image
89  template < typename TPixel, unsigned int VImageDimension > void InternalCalculateStatisticsUnmasked(
90  typename itk::Image< TPixel, VImageDimension >* image, const TimeGeometry* timeGeometry, TimeStepType timeStep);
91 
92  template < typename TPixel, unsigned int VImageDimension > void InternalCalculateStatisticsMasked(
93  typename itk::Image< TPixel, VImageDimension >* image, const TimeGeometry* timeGeometry,
94  unsigned int timeStep);
95 
96  template < typename TPixel, unsigned int VImageDimension >
97  double GetVoxelVolume(typename itk::Image<TPixel, VImageDimension>* image) const;
98 
99  bool IsUpdateRequired(LabelIndex label) const;
100 
102  mitk::Image::Pointer m_ImageTimeSlice;
103  mitk::Image::ConstPointer m_InternalImageForStatistics;
104 
105  mitk::MaskGenerator::Pointer m_MaskGenerator;
106  mitk::Image::Pointer m_InternalMask;
107 
108  mitk::MaskGenerator::Pointer m_SecondaryMaskGenerator;
109  mitk::Image::Pointer m_SecondaryMask;
110 
111  unsigned int m_nBinsForHistogramStatistics;
112  double m_binSizeForHistogramStatistics;
113  bool m_UseBinSizeOverNBins;
114 
115  std::map<LabelIndex,ImageStatisticsContainer::Pointer> m_StatisticContainers;
116  };
117 
118 }
119 #endif // MITKIMAGESTATISTICSCALCULATOR
120 
Base Class for all Mask Generators. Mask generators are classes that provide functionality for the cr...
DataCollection - Class to facilitate loading/accessing structured data.
#define MITKIMAGESTATISTICS_EXPORT
itk::Statistics::Histogram< double > HistogramType
Image class for storing images.
Definition: mitkImage.h:72
std::vcl_size_t TimeStepType
mitk::Image::Pointer image
ImageStatisticsContainer::LabelIndex LabelIndex
std::map< std::string, statisticsValueType > statisticsMapType
mitk::Image::Pointer mask
itk::SmartPointer< const Self > ConstPointer
Container class for storing a StatisticsObject for each timestep.