Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitkVolumeCalculator.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 mitkVolumeCalculator_h
14 #define mitkVolumeCalculator_h
15 
16 #include <itkImage.h>
17 #include <itkObject.h>
18 #include <itkObjectFactory.h>
19 
20 #include <mitkImage.h>
21 #include <mitkImageTimeSelector.h>
22 #include <MitkCoreExports.h>
23 
24 namespace mitk
25 {
36  class MITKCORE_EXPORT VolumeCalculator : public itk::Object
37  {
38  public:
40 
41  itkFactorylessNewMacro(Self);
42 
43  itkCloneMacro(Self);
44 
45  itkSetObjectMacro(Image, Image);
46 
50  itkSetMacro(Threshold, int);
51 
60  itkGetMacro(Volume, float);
61 
65  itkGetMacro(VoxelCount, unsigned long int);
66 
77  std::vector<float> GetVolumes();
78 
85  void ComputeVolume();
86 
94 
102  static float ComputeVolume(Vector3D spacing, unsigned int voxelCount);
103 
104  protected:
106  ~VolumeCalculator() override;
107 
108  template <typename TPixel, unsigned int VImageDimension>
109  void InternalCompute(const itk::Image<TPixel, VImageDimension> *itkImage);
110 
111  Image::ConstPointer m_Image;
113  float m_Volume;
114  unsigned long int m_VoxelCount;
115  std::vector<float> m_Volumes;
116  ImageTimeSelector::Pointer m_TimeSelector;
117  };
118 
119 } // namespace mitk
120 
121 #endif
#define MITKCORE_EXPORT
Image class for storing multi-dimensional medical image data.
Definition: mitkImage.h:76
Calculates the volume of a mitk::Image.
void ComputeVolume()
Compute the volume by iterating over all voxels above the threshold.
~VolumeCalculator() override
ImageTimeSelector::Pointer m_TimeSelector
std::vector< float > m_Volumes
void InternalCompute(const itk::Image< TPixel, VImageDimension > *itkImage)
void ComputeVolumeFromImageStatistics()
Compute the volume using image statistics (count of max-valued voxels).
static float ComputeVolume(Vector3D spacing, unsigned int voxelCount)
Compute a volume from spacing and voxel count.
mitkClassMacroItkParent(VolumeCalculator, itk::Object)
unsigned long int m_VoxelCount
Image::ConstPointer m_Image
std::vector< float > GetVolumes()
Return the volumes for 4D images.
Find image slices visible on a given plane.