Medical Imaging Interaction Toolkit  2026.06.00
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 {
43  {
44  public:
47  typedef itk::Object Superclass;
50 
52  itkNewMacro(Self);
53  itkTypeMacro(ImageStatisticsCalculator, itk::Object);
54 
56  typedef double statisticsValueType;
58  typedef std::map<std::string, statisticsValueType> statisticsMapType;
60  typedef itk::Statistics::Histogram<double> HistogramType;
62  typedef unsigned short MaskPixelType;
65 
71  void SetInputImage(const mitk::Image* image);
72 
81 
92 
101  void SetNBinsForHistogramStatistics(unsigned int nBins);
102 
110  unsigned int GetNBinsForHistogramStatistics() const;
111 
120  void SetBinSizeForHistogramStatistics(double binSize);
121 
130 
140 
141  protected:
143  m_nBinsForHistogramStatistics = 100;
144  m_binSizeForHistogramStatistics = 10;
145  m_UseBinSizeOverNBins = false;
146  };
147 
148 
149  private:
150  //Calculates statistics for each timestep for image
151  template < typename TPixel, unsigned int VImageDimension >
152  void InternalCalculateStatisticsUnmasked(const itk::Image< TPixel, VImageDimension >* image, TimeStepType timeStep);
153 
154  template < typename TPixel, unsigned int VImageDimension >
155  void InternalCalculateStatisticsMasked(const itk::Image< TPixel, VImageDimension >* image, TimeStepType timeStep);
156 
157  template < typename TPixel, unsigned int VImageDimension >
158  double GetVoxelVolume(const itk::Image<TPixel, VImageDimension>* image) const;
159 
160  bool IsUpdateRequired() const;
161 
162  mitk::Image::ConstPointer m_Image;
163  mitk::Image::ConstPointer m_ImageTimeSlice;
164  mitk::Image::ConstPointer m_InternalImageForStatistics;
165 
166  mitk::MaskGenerator::Pointer m_MaskGenerator;
167  mitk::Image::ConstPointer m_InternalMask;
168 
169  mitk::MaskGenerator::Pointer m_SecondaryMaskGenerator;
170  mitk::Image::ConstPointer m_SecondaryMask;
171 
172  unsigned int m_nBinsForHistogramStatistics;
173  double m_binSizeForHistogramStatistics;
174  bool m_UseBinSizeOverNBins;
175 
176  ImageStatisticsContainer::Pointer m_StatisticContainer;
177  };
178 
179 }
180 #endif
#define MITKIMAGESTATISTICS_EXPORT
Computes image statistics, optionally restricted by one or two masks.
void SetNBinsForHistogramStatistics(unsigned int nBins)
Set the number of histogram bins for histogram statistics.
itk::SmartPointer< const Self > ConstPointer
void SetInputImage(const mitk::Image *image)
Set the image for which statistics are to be computed.
double statisticsValueType
Type for individual statistics values.
void SetBinSizeForHistogramStatistics(double binSize)
Set the bin size for histogram statistics.
itk::Statistics::Histogram< double > HistogramType
Histogram type used for pixel value distribution.
double GetBinSizeForHistogramStatistics() const
Get the histogram bin size.
unsigned int GetNBinsForHistogramStatistics() const
Get the number of histogram bins.
unsigned short MaskPixelType
Pixel type used for mask images.
void SetMask(mitk::MaskGenerator *mask)
Set the primary mask generator for restricting statistics computation.
void SetSecondaryMask(mitk::MaskGenerator *mask)
Set a secondary mask generator for additional region restriction.
std::map< std::string, statisticsValueType > statisticsMapType
Map type associating statistic names with their values.
ImageStatisticsContainer * GetStatistics()
Get the computed statistics container.
ImageStatisticsContainer::LabelValueType LabelIndex
Type used for label indexing in statistics containers.
Container class for storing a StatisticsObject for each time step.
MultiLabelSegmentation::LabelValueType LabelValueType
Image class for storing multi-dimensional medical image data.
Definition: mitkImage.h:76
Abstract base class for all mask generators used in image statistics.
Find image slices visible on a given plane.
std::size_t TimeStepType
Type for time step indices (non-negative integers starting from 0).