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

Provides static methods for voxel-wise arithmetic operations on images. More...

#include <mitkArithmeticOperation.h>

Static Public Member Functions

Two-Image Arithmetic Operations

Perform voxel-wise arithmetic between two images. Both images must have the same dimensionality.

static Image::Pointer Add (Image::Pointer &imageA, Image::Pointer &imageB, bool outputAsDouble=true)
 Voxel-wise addition of two images: result = imageA + imageB. More...
 
static Image::Pointer Subtract (Image::Pointer &imageA, Image::Pointer &imageB, bool outputAsDouble=true)
 Voxel-wise subtraction of two images: result = imageA - imageB. More...
 
static Image::Pointer Multiply (Image::Pointer &imageA, Image::Pointer &imageB, bool outputAsDouble=true)
 Voxel-wise multiplication of two images: result = imageA * imageB. More...
 
static Image::Pointer Divide (Image::Pointer &imageA, Image::Pointer &imageB, bool outputAsDouble=true)
 Voxel-wise division of two images: result = imageA / imageB. More...
 
Image-Scalar Arithmetic Operations

Perform voxel-wise arithmetic between an image and a scalar value. The scalar is applied to each voxel: result(x) = imageA(x) op value.

static Image::Pointer Add (Image::Pointer &imageA, double value, bool outputAsDouble=true)
 Add a scalar value to each voxel: result = imageA + value. More...
 
static Image::Pointer Subtract (Image::Pointer &imageA, double value, bool outputAsDouble=true)
 Subtract a scalar value from each voxel: result = imageA - value. More...
 
static Image::Pointer Multiply (Image::Pointer &imageA, double value, bool outputAsDouble=true)
 Multiply each voxel by a scalar value: result = imageA * value. More...
 
static Image::Pointer Divide (Image::Pointer &imageA, double value, bool outputAsDouble=true)
 Divide each voxel by a scalar value: result = imageA / value. More...
 
Scalar-Image Arithmetic Operations

Perform voxel-wise arithmetic with a scalar on the left side: result(x) = value op imageB(x). The order matters for subtraction and division.

static Image::Pointer Add (double value, Image::Pointer &imageB, bool outputAsDouble=true)
 Add a scalar value to each voxel (commutative): result = value + imageB. More...
 
static Image::Pointer Subtract (double value, Image::Pointer &imageB, bool outputAsDouble=true)
 Subtract each voxel from a scalar: result = value - imageB. More...
 
static Image::Pointer Multiply (double value, Image::Pointer &imageB, bool outputAsDouble=true)
 Multiply a scalar by each voxel (commutative): result = value * imageB. More...
 
static Image::Pointer Divide (double value, Image::Pointer &imageB, bool outputAsDouble=true)
 Divide a scalar by each voxel: result = value / imageB. More...
 
Unary Mathematical Operations

Apply a mathematical function to each voxel of the input image.

static Image::Pointer Tan (Image::Pointer &imageA, bool outputAsDouble=true)
 Compute the tangent of each voxel: result = tan(imageA). More...
 
static Image::Pointer Atan (Image::Pointer &imageA, bool outputAsDouble=true)
 Compute the arctangent of each voxel: result = atan(imageA). More...
 
static Image::Pointer Cos (Image::Pointer &imageA, bool outputAsDouble=true)
 Compute the cosine of each voxel: result = cos(imageA). More...
 
static Image::Pointer Acos (Image::Pointer &imageA, bool outputAsDouble=true)
 Compute the arccosine of each voxel: result = acos(imageA). More...
 
static Image::Pointer Sin (Image::Pointer &imageA, bool outputAsDouble=true)
 Compute the sine of each voxel: result = sin(imageA). More...
 
static Image::Pointer Asin (Image::Pointer &imageA, bool outputAsDouble=true)
 Compute the arcsine of each voxel: result = asin(imageA). More...
 
static Image::Pointer Square (Image::Pointer &imageA, bool outputAsDouble=true)
 Compute the square of each voxel: result = imageA^2. More...
 
static Image::Pointer Sqrt (Image::Pointer &imageA, bool outputAsDouble=true)
 Compute the square root of each voxel: result = sqrt(imageA). More...
 
static Image::Pointer Abs (Image::Pointer &imageA, bool outputAsDouble=true)
 Compute the absolute value of each voxel: result = |imageA|. More...
 
static Image::Pointer Exp (Image::Pointer &imageA, bool outputAsDouble=true)
 Compute the exponential of each voxel: result = exp(imageA). More...
 
static Image::Pointer ExpNeg (Image::Pointer &imageA, bool outputAsDouble=true)
 Compute the negative exponential of each voxel: result = exp(-imageA). More...
 
static Image::Pointer Log10 (Image::Pointer &imageA, bool outputAsDouble=true)
 Compute the base-10 logarithm of each voxel: result = log10(imageA). More...
 

Detailed Description

Provides static methods for voxel-wise arithmetic operations on images.

The ArithmeticOperation class offers a comprehensive set of static methods for performing element-wise arithmetic on mitk::Image objects. Operations include basic arithmetic (add, subtract, multiply, divide) between two images or between an image and a scalar, as well as unary mathematical functions (trigonometric, exponential, logarithmic, etc.).

All operations support an optional flag to produce output with double pixel type. Two-image operations require both images to have the same dimensionality (1D, 2D, 3D, or 4D are supported).

See also
TransformationOperation, MaskCleaningOperation

Definition at line 35 of file mitkArithmeticOperation.h.

Member Function Documentation

◆ Abs()

static Image::Pointer mitk::ArithmeticOperation::Abs ( Image::Pointer &  imageA,
bool  outputAsDouble = true 
)
static

Compute the absolute value of each voxel: result = |imageA|.

Parameters
[in]imageAThe input image.
[in]outputAsDoubleIf true, the output image has double pixel type.
Returns
A new image with the absolute value of each voxel.

◆ Acos()

static Image::Pointer mitk::ArithmeticOperation::Acos ( Image::Pointer &  imageA,
bool  outputAsDouble = true 
)
static

Compute the arccosine of each voxel: result = acos(imageA).

Parameters
[in]imageAThe input image.
[in]outputAsDoubleIf true, the output image has double pixel type.
Returns
A new image with the arccosine applied to each voxel.

◆ Add() [1/3]

static Image::Pointer mitk::ArithmeticOperation::Add ( double  value,
Image::Pointer &  imageB,
bool  outputAsDouble = true 
)
static

Add a scalar value to each voxel (commutative): result = value + imageB.

Parameters
[in]valueThe scalar value.
[in]imageBThe input image.
[in]outputAsDoubleIf true, the output image has double pixel type.
Returns
A new image with the scalar added to each voxel.

◆ Add() [2/3]

static Image::Pointer mitk::ArithmeticOperation::Add ( Image::Pointer &  imageA,
double  value,
bool  outputAsDouble = true 
)
static

Add a scalar value to each voxel: result = imageA + value.

Parameters
[in]imageAThe input image.
[in]valueThe scalar value to add.
[in]outputAsDoubleIf true, the output image has double pixel type.
Returns
A new image with the scalar added to each voxel.

◆ Add() [3/3]

static Image::Pointer mitk::ArithmeticOperation::Add ( Image::Pointer &  imageA,
Image::Pointer &  imageB,
bool  outputAsDouble = true 
)
static

Voxel-wise addition of two images: result = imageA + imageB.

Parameters
[in]imageAFirst input image.
[in]imageBSecond input image (must have same dimensions as imageA).
[in]outputAsDoubleIf true, the output image has double pixel type (currently unused in two-image operations).
Returns
A new image containing the voxel-wise sum.
Exceptions
mitk::Exceptionif the images have different dimensionalities.

◆ Asin()

static Image::Pointer mitk::ArithmeticOperation::Asin ( Image::Pointer &  imageA,
bool  outputAsDouble = true 
)
static

Compute the arcsine of each voxel: result = asin(imageA).

Parameters
[in]imageAThe input image.
[in]outputAsDoubleIf true, the output image has double pixel type.
Returns
A new image with the arcsine applied to each voxel.

◆ Atan()

static Image::Pointer mitk::ArithmeticOperation::Atan ( Image::Pointer &  imageA,
bool  outputAsDouble = true 
)
static

Compute the arctangent of each voxel: result = atan(imageA).

Parameters
[in]imageAThe input image.
[in]outputAsDoubleIf true, the output image has double pixel type.
Returns
A new image with the arctangent applied to each voxel.

◆ Cos()

static Image::Pointer mitk::ArithmeticOperation::Cos ( Image::Pointer &  imageA,
bool  outputAsDouble = true 
)
static

Compute the cosine of each voxel: result = cos(imageA).

Parameters
[in]imageAThe input image.
[in]outputAsDoubleIf true, the output image has double pixel type.
Returns
A new image with the cosine applied to each voxel.

◆ Divide() [1/3]

static Image::Pointer mitk::ArithmeticOperation::Divide ( double  value,
Image::Pointer &  imageB,
bool  outputAsDouble = true 
)
static

Divide a scalar by each voxel: result = value / imageB.

Parameters
[in]valueThe scalar numerator.
[in]imageBThe input image (denominator).
[in]outputAsDoubleIf true, the output image has double pixel type.
Returns
A new image where each voxel is value divided by the original voxel.

◆ Divide() [2/3]

static Image::Pointer mitk::ArithmeticOperation::Divide ( Image::Pointer &  imageA,
double  value,
bool  outputAsDouble = true 
)
static

Divide each voxel by a scalar value: result = imageA / value.

Parameters
[in]imageAThe input image.
[in]valueThe scalar divisor.
[in]outputAsDoubleIf true, the output image has double pixel type.
Returns
A new image with each voxel divided by the scalar.

◆ Divide() [3/3]

static Image::Pointer mitk::ArithmeticOperation::Divide ( Image::Pointer &  imageA,
Image::Pointer &  imageB,
bool  outputAsDouble = true 
)
static

Voxel-wise division of two images: result = imageA / imageB.

Parameters
[in]imageAFirst input image (numerator).
[in]imageBSecond input image (denominator, must have same dimensions as imageA).
[in]outputAsDoubleIf true, the output image has double pixel type (currently unused in two-image operations).
Returns
A new image containing the voxel-wise quotient.
Exceptions
mitk::Exceptionif the images have different dimensionalities.

◆ Exp()

static Image::Pointer mitk::ArithmeticOperation::Exp ( Image::Pointer &  imageA,
bool  outputAsDouble = true 
)
static

Compute the exponential of each voxel: result = exp(imageA).

Parameters
[in]imageAThe input image.
[in]outputAsDoubleIf true, the output image has double pixel type.
Returns
A new image with the exponential applied to each voxel.

◆ ExpNeg()

static Image::Pointer mitk::ArithmeticOperation::ExpNeg ( Image::Pointer &  imageA,
bool  outputAsDouble = true 
)
static

Compute the negative exponential of each voxel: result = exp(-imageA).

Parameters
[in]imageAThe input image.
[in]outputAsDoubleIf true, the output image has double pixel type.
Returns
A new image with the negative exponential applied to each voxel.

◆ Log10()

static Image::Pointer mitk::ArithmeticOperation::Log10 ( Image::Pointer &  imageA,
bool  outputAsDouble = true 
)
static

Compute the base-10 logarithm of each voxel: result = log10(imageA).

Parameters
[in]imageAThe input image.
[in]outputAsDoubleIf true, the output image has double pixel type.
Returns
A new image with the base-10 logarithm applied to each voxel.

◆ Multiply() [1/3]

static Image::Pointer mitk::ArithmeticOperation::Multiply ( double  value,
Image::Pointer &  imageB,
bool  outputAsDouble = true 
)
static

Multiply a scalar by each voxel (commutative): result = value * imageB.

Parameters
[in]valueThe scalar multiplier.
[in]imageBThe input image.
[in]outputAsDoubleIf true, the output image has double pixel type.
Returns
A new image with each voxel multiplied by the scalar.

◆ Multiply() [2/3]

static Image::Pointer mitk::ArithmeticOperation::Multiply ( Image::Pointer &  imageA,
double  value,
bool  outputAsDouble = true 
)
static

Multiply each voxel by a scalar value: result = imageA * value.

Parameters
[in]imageAThe input image.
[in]valueThe scalar multiplier.
[in]outputAsDoubleIf true, the output image has double pixel type.
Returns
A new image with each voxel multiplied by the scalar.

◆ Multiply() [3/3]

static Image::Pointer mitk::ArithmeticOperation::Multiply ( Image::Pointer &  imageA,
Image::Pointer &  imageB,
bool  outputAsDouble = true 
)
static

Voxel-wise multiplication of two images: result = imageA * imageB.

Parameters
[in]imageAFirst input image.
[in]imageBSecond input image (must have same dimensions as imageA).
[in]outputAsDoubleIf true, the output image has double pixel type (currently unused in two-image operations).
Returns
A new image containing the voxel-wise product.
Exceptions
mitk::Exceptionif the images have different dimensionalities.

◆ Sin()

static Image::Pointer mitk::ArithmeticOperation::Sin ( Image::Pointer &  imageA,
bool  outputAsDouble = true 
)
static

Compute the sine of each voxel: result = sin(imageA).

Parameters
[in]imageAThe input image.
[in]outputAsDoubleIf true, the output image has double pixel type.
Returns
A new image with the sine applied to each voxel.

◆ Sqrt()

static Image::Pointer mitk::ArithmeticOperation::Sqrt ( Image::Pointer &  imageA,
bool  outputAsDouble = true 
)
static

Compute the square root of each voxel: result = sqrt(imageA).

Parameters
[in]imageAThe input image.
[in]outputAsDoubleIf true, the output image has double pixel type.
Returns
A new image with the square root applied to each voxel.

◆ Square()

static Image::Pointer mitk::ArithmeticOperation::Square ( Image::Pointer &  imageA,
bool  outputAsDouble = true 
)
static

Compute the square of each voxel: result = imageA^2.

Parameters
[in]imageAThe input image.
[in]outputAsDoubleIf true, the output image has double pixel type.
Returns
A new image with each voxel squared.

◆ Subtract() [1/3]

static Image::Pointer mitk::ArithmeticOperation::Subtract ( double  value,
Image::Pointer &  imageB,
bool  outputAsDouble = true 
)
static

Subtract each voxel from a scalar: result = value - imageB.

Parameters
[in]valueThe scalar value (minuend).
[in]imageBThe input image (subtrahend).
[in]outputAsDoubleIf true, the output image has double pixel type.
Returns
A new image where each voxel is value minus the original voxel.

◆ Subtract() [2/3]

static Image::Pointer mitk::ArithmeticOperation::Subtract ( Image::Pointer &  imageA,
double  value,
bool  outputAsDouble = true 
)
static

Subtract a scalar value from each voxel: result = imageA - value.

Parameters
[in]imageAThe input image.
[in]valueThe scalar value to subtract.
[in]outputAsDoubleIf true, the output image has double pixel type.
Returns
A new image with the scalar subtracted from each voxel.

◆ Subtract() [3/3]

static Image::Pointer mitk::ArithmeticOperation::Subtract ( Image::Pointer &  imageA,
Image::Pointer &  imageB,
bool  outputAsDouble = true 
)
static

Voxel-wise subtraction of two images: result = imageA - imageB.

Parameters
[in]imageAFirst input image.
[in]imageBSecond input image (must have same dimensions as imageA).
[in]outputAsDoubleIf true, the output image has double pixel type (currently unused in two-image operations).
Returns
A new image containing the voxel-wise difference.
Exceptions
mitk::Exceptionif the images have different dimensionalities.

◆ Tan()

static Image::Pointer mitk::ArithmeticOperation::Tan ( Image::Pointer &  imageA,
bool  outputAsDouble = true 
)
static

Compute the tangent of each voxel: result = tan(imageA).

Parameters
[in]imageAThe input image.
[in]outputAsDoubleIf true, the output image has double pixel type.
Returns
A new image with the tangent applied to each voxel.

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