Medical Imaging Interaction Toolkit  2025.12.02
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_h
14 #define mitkImageStatisticsCalculator_h
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, 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 
49 
54 
57  void SetNBinsForHistogramStatistics(unsigned int nBins);
58 
62  unsigned int GetNBinsForHistogramStatistics() const;
63 
66  void SetBinSizeForHistogramStatistics(double binSize);
67 
72 
77 
78  protected:
80  m_nBinsForHistogramStatistics = 100;
81  m_binSizeForHistogramStatistics = 10;
82  m_UseBinSizeOverNBins = false;
83  };
84 
85 
86  private:
87  //Calculates statistics for each timestep for image
88  template < typename TPixel, unsigned int VImageDimension >
89  void InternalCalculateStatisticsUnmasked(const itk::Image< TPixel, VImageDimension >* image, TimeStepType timeStep);
90 
91  template < typename TPixel, unsigned int VImageDimension >
92  void InternalCalculateStatisticsMasked(const itk::Image< TPixel, VImageDimension >* image, TimeStepType timeStep);
93 
94  template < typename TPixel, unsigned int VImageDimension >
95  double GetVoxelVolume(const itk::Image<TPixel, VImageDimension>* image) const;
96 
97  bool IsUpdateRequired() const;
98 
100  mitk::Image::ConstPointer m_ImageTimeSlice;
101  mitk::Image::ConstPointer m_InternalImageForStatistics;
102 
103  mitk::MaskGenerator::Pointer m_MaskGenerator;
104  mitk::Image::ConstPointer m_InternalMask;
105 
106  mitk::MaskGenerator::Pointer m_SecondaryMaskGenerator;
107  mitk::Image::ConstPointer m_SecondaryMask;
108 
109  unsigned int m_nBinsForHistogramStatistics;
110  double m_binSizeForHistogramStatistics;
111  bool m_UseBinSizeOverNBins;
112 
113  ImageStatisticsContainer::Pointer m_StatisticContainer;
114  };
115 
116 }
117 #endif
#define MITKIMAGESTATISTICS_EXPORT
void SetNBinsForHistogramStatistics(unsigned int nBins)
Set number of bins to be used for histogram statistics. If Bin size is set after number of bins,...
itk::SmartPointer< const Self > ConstPointer
void SetInputImage(const mitk::Image *image)
Set the image for which the statistics are to be computed.
void SetBinSizeForHistogramStatistics(double binSize)
Set bin size to be used for histogram statistics. If nbins is set after bin size, nbins will be used ...
itk::Statistics::Histogram< double > HistogramType
double GetBinSizeForHistogramStatistics() const
Retrieve the bin size for histogram statistics. Careful: The return value does not indicate whether N...
unsigned int GetNBinsForHistogramStatistics() const
Retrieve the number of bins used for histogram statistics. Careful: The return value does not indicat...
void SetMask(mitk::MaskGenerator *mask)
Set the mask generator that creates the mask which is to be used to calculate statistics....
void SetSecondaryMask(mitk::MaskGenerator *mask)
Set this if more than one mask should be applied (for instance if a IgnorePixelValueMask were to be u...
std::map< std::string, statisticsValueType > statisticsMapType
ImageStatisticsContainer * GetStatistics()
Returns the statistics. If these requested statistics are not computed yet the computation is done as...
ImageStatisticsContainer::LabelValueType LabelIndex
Container class for storing a StatisticsObject for each time step.
MultiLabelSegmentation::LabelValueType LabelValueType
Image class for storing images.
Definition: mitkImage.h:70
Base Class for all Mask Generators. Mask generators are classes that provide functionality for the cr...
Find image slices visible on a given plane.
std::size_t TimeStepType