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

Collection of static utility functions for classification and image processing. More...

#include <mitkCLUtil.h>

Public Types

enum  MorphologicalDimensions { Axial , Coronal , Sagittal , All }
 Specifies the anatomical plane for morphological operations. More...
 

Static Public Member Functions

static void CreateCheckerboardMask (mitk::Image::Pointer image, mitk::Image::Pointer &outimage)
 Create a checkerboard mask from the given image. More...
 
static void InterpolateCheckerboardPrediction (mitk::Image::Pointer checkerboard_prediction, mitk::Image::Pointer &checkerboard_mask, mitk::Image::Pointer &outimage)
 Interpolate a prediction using a checkerboard pattern. More...
 
static void CountVoxel (mitk::Image::Pointer image, std::map< unsigned int, unsigned int > &map)
 Count voxels per label in an image. More...
 
static void CountVoxel (mitk::Image::Pointer image, unsigned int label, unsigned int &count)
 Count the number of voxels with a specific label value. More...
 
static void CountVoxel (mitk::Image::Pointer image, unsigned int &count)
 Count the total number of non-zero voxels. More...
 
static void SumVoxelForLabel (mitk::Image::Pointer image, const mitk::Image::Pointer &source, unsigned int label, double &val)
 Sum intensity values from a source image for voxels matching a given label. More...
 
static void SqSumVoxelForLabel (mitk::Image::Pointer image, const mitk::Image::Pointer &source, unsigned int label, double &val)
 Sum squared intensity values from a source image for voxels matching a given label. More...
 
static void LogicalAndImages (const Image::Pointer &image1, const Image::Pointer &image2, Image::Pointer &outimage)
 Compute the logical AND of two binary images. More...
 
static void GaussianFilter (mitk::Image::Pointer image, mitk::Image::Pointer &smoothed, double sigma)
 Apply a Gaussian smoothing filter to an image. More...
 
static void DifferenceOfGaussianFilter (mitk::Image::Pointer image, mitk::Image::Pointer &smoothed, double sigma1, double sigma2)
 Compute the Difference of Gaussians (DoG) of an image. More...
 
static void LaplacianOfGaussianFilter (mitk::Image::Pointer image, mitk::Image::Pointer &smoothed, double sigma1)
 Compute the Laplacian of Gaussian (LoG) of an image. More...
 
static void HessianOfGaussianFilter (mitk::Image::Pointer image, std::vector< mitk::Image::Pointer > &out, double sigma)
 Compute the Hessian of Gaussian for an image. More...
 
static void LocalHistogram (mitk::Image::Pointer image, std::vector< mitk::Image::Pointer > &out, int Bins, int NeighbourhoodSize)
 Compute local histograms for each voxel in an image. More...
 
template<typename TMatrixElementType >
static mitk::Image::Pointer Transform (const Eigen::Matrix< TMatrixElementType, Eigen::Dynamic, Eigen::Dynamic > &matrix, const mitk::Image::Pointer &mask)
 Transform an Eigen matrix back to an MITK image using a mask. More...
 
template<typename TMatrixElementType >
static Eigen::Matrix< TMatrixElementType, Eigen::Dynamic, Eigen::Dynamic > Transform (const mitk::Image::Pointer &img, const mitk::Image::Pointer &mask)
 Transform an MITK image into an Eigen column matrix using a mask. More...
 
static void DilateBinary (mitk::Image::Pointer &sourceImage, mitk::Image::Pointer &resultImage, int radius, MorphologicalDimensions d)
 Dilate a binary image using a ball structuring element. More...
 
static void ErodeBinary (mitk::Image::Pointer &sourceImage, mitk::Image::Pointer &resultImage, int radius, MorphologicalDimensions d)
 Erode a binary image using a ball structuring element. More...
 
static void ClosingBinary (mitk::Image::Pointer &sourceImage, mitk::Image::Pointer &resultImage, int radius, MorphologicalDimensions d)
 Perform morphological closing on a binary image. More...
 
static void MergeLabels (mitk::Image::Pointer &img, const std::map< unsigned int, unsigned int > &map)
 Merge labels in a label image according to a mapping. More...
 
static void ConnectedComponentsImage (mitk::Image::Pointer &image, mitk::Image::Pointer &mask, mitk::Image::Pointer &outimage, unsigned int &num_components)
 Compute connected components of a label image. More...
 
static void GrabLabel (mitk::Image::Pointer &image, mitk::Image::Pointer &outimage, unsigned int label)
 Extract a single label from a label image into a binary mask. More...
 
static void InsertLabel (mitk::Image::Pointer &image, mitk::Image::Pointer &maskImage, unsigned int label)
 Insert a label value into an output image at positions defined by a mask. More...
 
static void ErodeGrayscale (mitk::Image::Pointer &image, unsigned int radius, mitk::CLUtil::MorphologicalDimensions d, mitk::Image::Pointer &outimage)
 Perform grayscale erosion using a ball structuring element. More...
 
static void DilateGrayscale (mitk::Image::Pointer &image, unsigned int radius, mitk::CLUtil::MorphologicalDimensions d, mitk::Image::Pointer &outimage)
 Perform grayscale dilation using a ball structuring element. More...
 
static void FillHoleGrayscale (mitk::Image::Pointer &image, mitk::Image::Pointer &outimage)
 Fill holes in a grayscale image. More...
 
static void ProbabilityMap (const mitk::Image::Pointer &sourceImage, double mean, double std_dev, mitk::Image::Pointer &resultImage)
 Create a probability map based on Gaussian distribution parameters. More...
 
template<class TImageType >
static void itkCountVoxel (TImageType *image, std::map< unsigned int, unsigned int > &map)
 
template<class TImageType >
static void itkCountVoxel (TImageType *image, typename TImageType::PixelType label, unsigned int &count)
 
template<typename TImageType >
static void itkCountVoxel (TImageType *mask, unsigned int &n_numSamples)
 
template<class TImageType1 , class TImageType2 >
static void itkSampleLabel (TImageType1 *image, TImageType2 *output, double acceptrate, unsigned int label)
 
template<class TImageType >
static void itkSampleLabel (TImageType *image, mitk::Image::Pointer &output, unsigned int n_samples_drawn)
 

Detailed Description

Collection of static utility functions for classification and image processing.

CLUtil provides convenience methods for voxel counting, morphological operations, image filtering (Gaussian, DoG, LoG, Hessian), label manipulation, and conversion between Eigen matrices and MITK images.

See also
AbstractGlobalImageFeature
AbstractClassifier

Definition at line 39 of file mitkCLUtil.h.

Member Enumeration Documentation

◆ MorphologicalDimensions

Specifies the anatomical plane for morphological operations.

Enumerator
Axial 

Axial (transverse) plane.

Coronal 

Coronal (frontal) plane.

Sagittal 

Sagittal plane.

All 

All three dimensions (3D operation).

Definition at line 45 of file mitkCLUtil.h.

Member Function Documentation

◆ ClosingBinary()

static void mitk::CLUtil::ClosingBinary ( mitk::Image::Pointer &  sourceImage,
mitk::Image::Pointer &  resultImage,
int  radius,
MorphologicalDimensions  d 
)
static

Perform morphological closing on a binary image.

Parameters
sourceImageThe input binary image.
resultImageThe closed output image.
radiusRadius of the structuring element in voxels.
dThe anatomical dimension(s) for the operation.

◆ ConnectedComponentsImage()

static void mitk::CLUtil::ConnectedComponentsImage ( mitk::Image::Pointer &  image,
mitk::Image::Pointer &  mask,
mitk::Image::Pointer &  outimage,
unsigned int &  num_components 
)
static

Compute connected components of a label image.

Parameters
imageThe input label image.
maskOptional mask restricting the region. Can be nullptr.
outimageThe output image with unique labels per connected component.
num_componentsThe number of connected components found.

◆ CountVoxel() [1/3]

static void mitk::CLUtil::CountVoxel ( mitk::Image::Pointer  image,
std::map< unsigned int, unsigned int > &  map 
)
static

Count voxels per label in an image.

Parameters
[in]imageThe label image.
[out]mapMap from label value to voxel count.

Referenced by Transform().

◆ CountVoxel() [2/3]

static void mitk::CLUtil::CountVoxel ( mitk::Image::Pointer  image,
unsigned int &  count 
)
static

Count the total number of non-zero voxels.

Parameters
[in]imageThe input image.
[out]countThe total count of voxels with value > 0.

◆ CountVoxel() [3/3]

static void mitk::CLUtil::CountVoxel ( mitk::Image::Pointer  image,
unsigned int  label,
unsigned int &  count 
)
static

Count the number of voxels with a specific label value.

Parameters
[in]imageThe label image.
[in]labelThe label value to count.
[out]countThe number of voxels with the given label.

◆ CreateCheckerboardMask()

static void mitk::CLUtil::CreateCheckerboardMask ( mitk::Image::Pointer  image,
mitk::Image::Pointer &  outimage 
)
static

Create a checkerboard mask from the given image.

Parameters
[in]imageThe input image.
[out]outimageThe resulting checkerboard mask.

◆ DifferenceOfGaussianFilter()

static void mitk::CLUtil::DifferenceOfGaussianFilter ( mitk::Image::Pointer  image,
mitk::Image::Pointer &  smoothed,
double  sigma1,
double  sigma2 
)
static

Compute the Difference of Gaussians (DoG) of an image.

The result is the difference between two Gaussian-smoothed images with sigmas sigma1 and sigma2.

Parameters
[in]imageThe input image.
[out]smoothedThe DoG output image.
[in]sigma1Standard deviation of the first Gaussian.
[in]sigma2Standard deviation of the second Gaussian.

◆ DilateBinary()

static void mitk::CLUtil::DilateBinary ( mitk::Image::Pointer &  sourceImage,
mitk::Image::Pointer &  resultImage,
int  radius,
MorphologicalDimensions  d 
)
static

Dilate a binary image using a ball structuring element.

Parameters
sourceImageThe input binary image.
resultImageThe dilated output image.
radiusRadius of the structuring element in voxels.
dThe anatomical dimension(s) for the operation.

◆ DilateGrayscale()

static void mitk::CLUtil::DilateGrayscale ( mitk::Image::Pointer &  image,
unsigned int  radius,
mitk::CLUtil::MorphologicalDimensions  d,
mitk::Image::Pointer &  outimage 
)
static

Perform grayscale dilation using a ball structuring element.

Parameters
imageThe input image.
radiusRadius of the structuring element in voxels.
dThe anatomical dimension(s) for the operation.
outimageThe dilated output image.

◆ ErodeBinary()

static void mitk::CLUtil::ErodeBinary ( mitk::Image::Pointer &  sourceImage,
mitk::Image::Pointer &  resultImage,
int  radius,
MorphologicalDimensions  d 
)
static

Erode a binary image using a ball structuring element.

Parameters
sourceImageThe input binary image.
resultImageThe eroded output image.
radiusRadius of the structuring element in voxels.
dThe anatomical dimension(s) for the operation.

◆ ErodeGrayscale()

static void mitk::CLUtil::ErodeGrayscale ( mitk::Image::Pointer &  image,
unsigned int  radius,
mitk::CLUtil::MorphologicalDimensions  d,
mitk::Image::Pointer &  outimage 
)
static

Perform grayscale erosion using a ball structuring element.

Parameters
imageThe input image.
radiusRadius of the structuring element in voxels.
dThe anatomical dimension(s) for the operation.
outimageThe eroded output image.

◆ FillHoleGrayscale()

static void mitk::CLUtil::FillHoleGrayscale ( mitk::Image::Pointer &  image,
mitk::Image::Pointer &  outimage 
)
static

Fill holes in a grayscale image.

Parameters
imageThe input image.
outimageThe output image with holes filled.

◆ GaussianFilter()

static void mitk::CLUtil::GaussianFilter ( mitk::Image::Pointer  image,
mitk::Image::Pointer &  smoothed,
double  sigma 
)
static

Apply a Gaussian smoothing filter to an image.

Parameters
[in]imageThe input image.
[out]smoothedThe smoothed output image.
[in]sigmaStandard deviation of the Gaussian kernel.

◆ GrabLabel()

static void mitk::CLUtil::GrabLabel ( mitk::Image::Pointer &  image,
mitk::Image::Pointer &  outimage,
unsigned int  label 
)
static

Extract a single label from a label image into a binary mask.

Parameters
imageThe input label image.
outimageThe output binary image (1 where label matches, 0 otherwise).
labelThe label value to extract.

◆ HessianOfGaussianFilter()

static void mitk::CLUtil::HessianOfGaussianFilter ( mitk::Image::Pointer  image,
std::vector< mitk::Image::Pointer > &  out,
double  sigma 
)
static

Compute the Hessian of Gaussian for an image.

Produces multiple output images corresponding to the Hessian matrix components.

Parameters
[in]imageThe input image.
[out]outVector of output images for each Hessian component.
[in]sigmaStandard deviation of the Gaussian.

◆ InsertLabel()

static void mitk::CLUtil::InsertLabel ( mitk::Image::Pointer &  image,
mitk::Image::Pointer &  maskImage,
unsigned int  label 
)
static

Insert a label value into an output image at positions defined by a mask.

Parameters
imageThe output image to insert the label into (created if null).
maskImageThe mask defining where to insert the label.
labelThe label value to insert.

◆ InterpolateCheckerboardPrediction()

static void mitk::CLUtil::InterpolateCheckerboardPrediction ( mitk::Image::Pointer  checkerboard_prediction,
mitk::Image::Pointer &  checkerboard_mask,
mitk::Image::Pointer &  outimage 
)
static

Interpolate a prediction using a checkerboard pattern.

Parameters
[in]checkerboard_predictionThe prediction computed on the checkerboard pattern.
[in,out]checkerboard_maskThe checkerboard mask.
[out]outimageThe interpolated full prediction.

◆ itkCountVoxel() [1/3]

template<class TImageType >
static void mitk::CLUtil::itkCountVoxel ( TImageType *  image,
std::map< unsigned int, unsigned int > &  map 
)
inlinestatic

Definition at line 355 of file mitkCLUtil.h.

◆ itkCountVoxel() [2/3]

template<class TImageType >
static void mitk::CLUtil::itkCountVoxel ( TImageType *  image,
typename TImageType::PixelType  label,
unsigned int &  count 
)
inlinestatic

Definition at line 368 of file mitkCLUtil.h.

◆ itkCountVoxel() [3/3]

template<typename TImageType >
static void mitk::CLUtil::itkCountVoxel ( TImageType *  mask,
unsigned int &  n_numSamples 
)
inlinestatic

Definition at line 379 of file mitkCLUtil.h.

◆ itkSampleLabel() [1/2]

template<class TImageType >
static void mitk::CLUtil::itkSampleLabel ( TImageType *  image,
mitk::Image::Pointer &  output,
unsigned int  n_samples_drawn 
)
inlinestatic

Definition at line 410 of file mitkCLUtil.h.

References mitk::CastToMitkImage().

◆ itkSampleLabel() [2/2]

template<class TImageType1 , class TImageType2 >
static void mitk::CLUtil::itkSampleLabel ( TImageType1 *  image,
TImageType2 *  output,
double  acceptrate,
unsigned int  label 
)
inlinestatic

Definition at line 391 of file mitkCLUtil.h.

◆ LaplacianOfGaussianFilter()

static void mitk::CLUtil::LaplacianOfGaussianFilter ( mitk::Image::Pointer  image,
mitk::Image::Pointer &  smoothed,
double  sigma1 
)
static

Compute the Laplacian of Gaussian (LoG) of an image.

Parameters
[in]imageThe input image.
[out]smoothedThe LoG output image.
[in]sigma1Standard deviation of the Gaussian.

◆ LocalHistogram()

static void mitk::CLUtil::LocalHistogram ( mitk::Image::Pointer  image,
std::vector< mitk::Image::Pointer > &  out,
int  Bins,
int  NeighbourhoodSize 
)
static

Compute local histograms for each voxel in an image.

Parameters
[in]imageThe input image.
[out]outVector of output images, one per histogram bin.
[in]BinsNumber of histogram bins.
[in]NeighbourhoodSizeSize of the local neighbourhood.

◆ LogicalAndImages()

static void mitk::CLUtil::LogicalAndImages ( const Image::Pointer &  image1,
const Image::Pointer &  image2,
Image::Pointer &  outimage 
)
static

Compute the logical AND of two binary images.

Parameters
[in]image1First binary image.
[in]image2Second binary image.
[out]outimageThe resulting AND image.

◆ MergeLabels()

static void mitk::CLUtil::MergeLabels ( mitk::Image::Pointer &  img,
const std::map< unsigned int, unsigned int > &  map 
)
static

Merge labels in a label image according to a mapping.

Parameters
imgThe label image to modify in place.
mapMap of source label to target label. Each occurrence of a source label is replaced by its target.

◆ ProbabilityMap()

static void mitk::CLUtil::ProbabilityMap ( const mitk::Image::Pointer &  sourceImage,
double  mean,
double  std_dev,
mitk::Image::Pointer &  resultImage 
)
static

Create a probability map based on Gaussian distribution parameters.

Parameters
sourceImageThe input intensity image.
meanThe mean of the Gaussian distribution.
std_devThe standard deviation of the Gaussian distribution.
resultImageThe output probability map image.

◆ SqSumVoxelForLabel()

static void mitk::CLUtil::SqSumVoxelForLabel ( mitk::Image::Pointer  image,
const mitk::Image::Pointer &  source,
unsigned int  label,
double &  val 
)
static

Sum squared intensity values from a source image for voxels matching a given label.

Parameters
[in]imageThe label image.
[in]sourceThe intensity source image.
[in]labelThe label value to select voxels.
[out]valThe sum of squared intensities for the selected voxels.

◆ SumVoxelForLabel()

static void mitk::CLUtil::SumVoxelForLabel ( mitk::Image::Pointer  image,
const mitk::Image::Pointer &  source,
unsigned int  label,
double &  val 
)
static

Sum intensity values from a source image for voxels matching a given label.

Parameters
[in]imageThe label image.
[in]sourceThe intensity source image.
[in]labelThe label value to select voxels.
[out]valThe sum of intensities for the selected voxels.

◆ Transform() [1/2]

template<typename TMatrixElementType >
static mitk::Image::Pointer mitk::CLUtil::Transform ( const Eigen::Matrix< TMatrixElementType, Eigen::Dynamic, Eigen::Dynamic > &  matrix,
const mitk::Image::Pointer &  mask 
)
inlinestatic

Transform an Eigen matrix back to an MITK image using a mask.

Non-zero voxels in the mask are filled with values from the matrix in order.

Template Parameters
TMatrixElementTypeElement type of the Eigen matrix.
Parameters
[in]matrixThe Eigen matrix of shape [n_masked_voxels, 1].
[in]maskThe mask image defining which voxels to populate.
Returns
The resulting MITK image.

Definition at line 186 of file mitkCLUtil.h.

References mitk::CastToItkImage(), CountVoxel(), mitk::GrabItkImageMemory(), MITK_ERROR, and mitk::Image::New().

◆ Transform() [2/2]

template<typename TMatrixElementType >
static Eigen::Matrix<TMatrixElementType, Eigen::Dynamic, Eigen::Dynamic> mitk::CLUtil::Transform ( const mitk::Image::Pointer &  img,
const mitk::Image::Pointer &  mask 
)
inlinestatic

Transform an MITK image into an Eigen column matrix using a mask.

Extracts intensity values from masked (non-zero) voxels and stores them in a single-column Eigen matrix.

Template Parameters
TMatrixElementTypeElement type of the Eigen matrix.
Parameters
imgThe input intensity image.
maskThe mask image defining which voxels to extract.
Returns
An Eigen matrix of shape [n_masked_voxels, 1].

Definition at line 235 of file mitkCLUtil.h.

References mitk::CastToItkImage(), and CountVoxel().


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