Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitk::VolumeCalculator Class Reference

Calculates the volume of a mitk::Image. More...

#include <mitkVolumeCalculator.h>

Inheritance diagram for mitk::VolumeCalculator:
Collaboration diagram for mitk::VolumeCalculator:

Public Member Functions

 mitkClassMacroItkParent (VolumeCalculator, itk::Object)
 
Pointer Clone () const
 
virtual void SetImage (Image *_arg)
 
virtual void SetThreshold (int _arg)
 Sets threshold; all voxels with a value equal to or greater than this are accepted. More...
 
virtual float GetVolume ()
 Return the calculated volume. More...
 
virtual unsigned long int GetVoxelCount ()
 Return the number of accepted voxels (those at or above the threshold). More...
 
std::vector< float > GetVolumes ()
 Return the volumes for 4D images. More...
 
void ComputeVolume ()
 Compute the volume by iterating over all voxels above the threshold. More...
 
void ComputeVolumeFromImageStatistics ()
 Compute the volume using image statistics (count of max-valued voxels). More...
 

Static Public Member Functions

static Pointer New ()
 
static float ComputeVolume (Vector3D spacing, unsigned int voxelCount)
 Compute a volume from spacing and voxel count. More...
 

Protected Member Functions

 VolumeCalculator ()
 
 ~VolumeCalculator () override
 
template<typename TPixel , unsigned int VImageDimension>
void InternalCompute (const itk::Image< TPixel, VImageDimension > *itkImage)
 

Protected Attributes

Image::ConstPointer m_Image
 
int m_Threshold
 
float m_Volume
 
unsigned long int m_VoxelCount
 
std::vector< float > m_Volumes
 
ImageTimeSelector::Pointer m_TimeSelector
 

Detailed Description

Calculates the volume of a mitk::Image.

The volume is given in milliliters (cubic cm for 3D, square cm for 2D) or as a voxel count. Voxels are counted if their gray value is equal to or greater than a threshold (see SetThreshold). The default threshold is 0.

The filter works for 2D, 3D, and 3D+t images. In the 3D+t case, a vector of volumes is provided (see GetVolumes()).

Definition at line 36 of file mitkVolumeCalculator.h.

Constructor & Destructor Documentation

◆ VolumeCalculator()

mitk::VolumeCalculator::VolumeCalculator ( )
protected

◆ ~VolumeCalculator()

mitk::VolumeCalculator::~VolumeCalculator ( )
overrideprotected

Member Function Documentation

◆ Clone()

Pointer mitk::VolumeCalculator::Clone ( ) const

◆ ComputeVolume() [1/2]

void mitk::VolumeCalculator::ComputeVolume ( )

Compute the volume by iterating over all voxels above the threshold.

For 4D images, the per-time-step volumes are stored and can be retrieved via GetVolumes().

◆ ComputeVolume() [2/2]

static float mitk::VolumeCalculator::ComputeVolume ( Vector3D  spacing,
unsigned int  voxelCount 
)
static

Compute a volume from spacing and voxel count.

Parameters
[in]spacingThe voxel spacing in each dimension.
[in]voxelCountThe number of voxels.
Returns
The computed volume in cubic cm.

◆ ComputeVolumeFromImageStatistics()

void mitk::VolumeCalculator::ComputeVolumeFromImageStatistics ( )

Compute the volume using image statistics (count of max-valued voxels).

This is a faster alternative to ComputeVolume() when only the maximum-valued voxels are of interest.

◆ GetVolume()

virtual float mitk::VolumeCalculator::GetVolume ( )
virtual

Return the calculated volume.

For 2D images the result is in square cm, for 3D images in cubic cm. For 4D data, use GetVolumes() instead.

See also
GetVolumes()

◆ GetVolumes()

std::vector<float> mitk::VolumeCalculator::GetVolumes ( )

Return the volumes for 4D images.

Each entry in the returned vector represents the volume for one time step in cubic cm.

Note
For 2D+t images the result is also returned in cubic cm.
Returns
A vector of volumes, one per time step.

◆ GetVoxelCount()

virtual unsigned long int mitk::VolumeCalculator::GetVoxelCount ( )
virtual

Return the number of accepted voxels (those at or above the threshold).

◆ InternalCompute()

template<typename TPixel , unsigned int VImageDimension>
void mitk::VolumeCalculator::InternalCompute ( const itk::Image< TPixel, VImageDimension > *  itkImage)
protected

◆ mitkClassMacroItkParent()

mitk::VolumeCalculator::mitkClassMacroItkParent ( VolumeCalculator  ,
itk::Object   
)

◆ New()

static Pointer mitk::VolumeCalculator::New ( )
static

◆ SetImage()

virtual void mitk::VolumeCalculator::SetImage ( Image *  _arg)
virtual

◆ SetThreshold()

virtual void mitk::VolumeCalculator::SetThreshold ( int  _arg)
virtual

Sets threshold; all voxels with a value equal to or greater than this are accepted.

Member Data Documentation

◆ m_Image

Image::ConstPointer mitk::VolumeCalculator::m_Image
protected

Definition at line 111 of file mitkVolumeCalculator.h.

◆ m_Threshold

int mitk::VolumeCalculator::m_Threshold
protected

Definition at line 112 of file mitkVolumeCalculator.h.

◆ m_TimeSelector

ImageTimeSelector::Pointer mitk::VolumeCalculator::m_TimeSelector
protected

Definition at line 116 of file mitkVolumeCalculator.h.

◆ m_Volume

float mitk::VolumeCalculator::m_Volume
protected

Definition at line 113 of file mitkVolumeCalculator.h.

◆ m_Volumes

std::vector<float> mitk::VolumeCalculator::m_Volumes
protected

Definition at line 115 of file mitkVolumeCalculator.h.

◆ m_VoxelCount

unsigned long int mitk::VolumeCalculator::m_VoxelCount
protected

Definition at line 114 of file mitkVolumeCalculator.h.


The documentation for this class was generated from the following file: