Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitkArithmeticOperation.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 mitkArithmeticOperation_h
14 #define mitkArithmeticOperation_h
15 
16 #include <mitkImage.h>
18 
19 namespace mitk
20 {
36  public:
43 
52  static Image::Pointer Add(Image::Pointer & imageA, Image::Pointer & imageB, bool outputAsDouble = true);
53 
62  static Image::Pointer Subtract(Image::Pointer & imageA, Image::Pointer & imageB, bool outputAsDouble = true);
63 
72  static Image::Pointer Multiply(Image::Pointer & imageA, Image::Pointer & imageB, bool outputAsDouble = true);
73 
82  static Image::Pointer Divide(Image::Pointer & imageA, Image::Pointer & imageB, bool outputAsDouble = true);
84 
91 
99  static Image::Pointer Add(Image::Pointer & imageA, double value, bool outputAsDouble = true);
100 
108  static Image::Pointer Subtract(Image::Pointer & imageA, double value, bool outputAsDouble = true);
109 
117  static Image::Pointer Multiply(Image::Pointer & imageA, double value, bool outputAsDouble = true);
118 
126  static Image::Pointer Divide(Image::Pointer & imageA, double value, bool outputAsDouble = true);
128 
135 
143  static Image::Pointer Add(double value, Image::Pointer & imageB, bool outputAsDouble = true);
144 
152  static Image::Pointer Subtract(double value, Image::Pointer & imageB, bool outputAsDouble = true);
153 
161  static Image::Pointer Multiply(double value, Image::Pointer & imageB, bool outputAsDouble = true);
162 
170  static Image::Pointer Divide(double value, Image::Pointer & imageB, bool outputAsDouble = true);
172 
178 
185  static Image::Pointer Tan(Image::Pointer & imageA, bool outputAsDouble = true);
186 
193  static Image::Pointer Atan(Image::Pointer & imageA, bool outputAsDouble = true);
194 
201  static Image::Pointer Cos(Image::Pointer & imageA, bool outputAsDouble = true);
202 
209  static Image::Pointer Acos(Image::Pointer & imageA, bool outputAsDouble = true);
210 
217  static Image::Pointer Sin(Image::Pointer & imageA, bool outputAsDouble = true);
218 
225  static Image::Pointer Asin(Image::Pointer & imageA, bool outputAsDouble = true);
226 
233  static Image::Pointer Square(Image::Pointer & imageA, bool outputAsDouble = true);
234 
241  static Image::Pointer Sqrt(Image::Pointer & imageA, bool outputAsDouble = true);
242 
249  static Image::Pointer Abs(Image::Pointer & imageA, bool outputAsDouble = true);
250 
257  static Image::Pointer Exp(Image::Pointer & imageA, bool outputAsDouble = true);
258 
265  static Image::Pointer ExpNeg(Image::Pointer & imageA, bool outputAsDouble = true);
266 
273  static Image::Pointer Log10(Image::Pointer & imageA, bool outputAsDouble = true);
275  };
276 
290  public:
295  {
299  Div,
305  Tan,
307  Cos,
309  Sin,
313  Abs,
314  Exp,
316  Log10
317  };
318 
329  void CallExecuteTwoImageFilter(mitk::Image::Pointer imageA, mitk::Image::Pointer imageB);
330 
340  template <typename TPixel1, unsigned int VImageDimension1, typename TPixel2, unsigned int VImageDimension2>
341  void ExecuteTwoImageFilter(itk::Image<TPixel1, VImageDimension1>* imageA, itk::Image<TPixel2, VImageDimension2>* imageB);
342 
353  template<typename DefaultFunctorType, typename DoubleFunctorType, typename Image1Type, typename Image2Type, typename DoubleImageType>
354  void ExecuteTwoImageFilterWithFunctor(Image1Type* imageA, Image2Type* imageB);
355 
357  mitk::Image::Pointer m_ResultImage;
361  bool m_GenerateDoubleOutput = false;
362  };
363 
364 
365 }
366 #endif
#define MITKBASICIMAGEPROCESSING_EXPORT
Provides static methods for voxel-wise arithmetic operations on images.
static Image::Pointer Multiply(Image::Pointer &imageA, Image::Pointer &imageB, bool outputAsDouble=true)
Voxel-wise multiplication of two images: result = imageA * imageB.
static Image::Pointer Abs(Image::Pointer &imageA, bool outputAsDouble=true)
Compute the absolute value of each voxel: result = |imageA|.
static Image::Pointer Add(Image::Pointer &imageA, double value, bool outputAsDouble=true)
Add a scalar value to each voxel: result = imageA + value.
static Image::Pointer Cos(Image::Pointer &imageA, bool outputAsDouble=true)
Compute the cosine of each voxel: result = cos(imageA).
static Image::Pointer Subtract(double value, Image::Pointer &imageB, bool outputAsDouble=true)
Subtract each voxel from a scalar: result = value - imageB.
static Image::Pointer Divide(double value, Image::Pointer &imageB, bool outputAsDouble=true)
Divide a scalar by each voxel: result = value / imageB.
static Image::Pointer Acos(Image::Pointer &imageA, bool outputAsDouble=true)
Compute the arccosine of each voxel: result = acos(imageA).
static Image::Pointer Asin(Image::Pointer &imageA, bool outputAsDouble=true)
Compute the arcsine of each voxel: result = asin(imageA).
static Image::Pointer Tan(Image::Pointer &imageA, bool outputAsDouble=true)
Compute the tangent of each voxel: result = tan(imageA).
static Image::Pointer Sin(Image::Pointer &imageA, bool outputAsDouble=true)
Compute the sine of each voxel: result = sin(imageA).
static Image::Pointer Add(Image::Pointer &imageA, Image::Pointer &imageB, bool outputAsDouble=true)
Voxel-wise addition of two images: result = imageA + imageB.
static Image::Pointer Add(double value, Image::Pointer &imageB, bool outputAsDouble=true)
Add a scalar value to each voxel (commutative): result = value + imageB.
static Image::Pointer ExpNeg(Image::Pointer &imageA, bool outputAsDouble=true)
Compute the negative exponential of each voxel: result = exp(-imageA).
static Image::Pointer Divide(Image::Pointer &imageA, Image::Pointer &imageB, bool outputAsDouble=true)
Voxel-wise division of two images: result = imageA / imageB.
static Image::Pointer Log10(Image::Pointer &imageA, bool outputAsDouble=true)
Compute the base-10 logarithm of each voxel: result = log10(imageA).
static Image::Pointer Multiply(Image::Pointer &imageA, double value, bool outputAsDouble=true)
Multiply each voxel by a scalar value: result = imageA * value.
static Image::Pointer Subtract(Image::Pointer &imageA, double value, bool outputAsDouble=true)
Subtract a scalar value from each voxel: result = imageA - value.
static Image::Pointer Sqrt(Image::Pointer &imageA, bool outputAsDouble=true)
Compute the square root of each voxel: result = sqrt(imageA).
static Image::Pointer Subtract(Image::Pointer &imageA, Image::Pointer &imageB, bool outputAsDouble=true)
Voxel-wise subtraction of two images: result = imageA - imageB.
static Image::Pointer Exp(Image::Pointer &imageA, bool outputAsDouble=true)
Compute the exponential of each voxel: result = exp(imageA).
static Image::Pointer Atan(Image::Pointer &imageA, bool outputAsDouble=true)
Compute the arctangent of each voxel: result = atan(imageA).
static Image::Pointer Multiply(double value, Image::Pointer &imageB, bool outputAsDouble=true)
Multiply a scalar by each voxel (commutative): result = value * imageB.
static Image::Pointer Divide(Image::Pointer &imageA, double value, bool outputAsDouble=true)
Divide each voxel by a scalar value: result = imageA / value.
static Image::Pointer Square(Image::Pointer &imageA, bool outputAsDouble=true)
Compute the square of each voxel: result = imageA^2.
Internal helper class for executing two-image arithmetic operations with ITK filters.
void ExecuteTwoImageFilter(itk::Image< TPixel1, VImageDimension1 > *imageA, itk::Image< TPixel2, VImageDimension2 > *imageB)
Internal templated method that executes the two-image filter with matched pixel types.
OperationsEnum m_Algorithm
The algorithm/operation to execute.
OperationsEnum
Enumeration of all supported arithmetic operations.
@ PowValue
Raise image to scalar power (or scalar to image power)
@ ExpNeg
Negative exponential (e^{-x})
@ DivValue
Divide image by scalar value (or scalar by image)
@ SubValue
Subtract scalar value from image (or image from scalar)
@ MultValue
Multiply image by scalar value.
void CallExecuteTwoImageFilter(mitk::Image::Pointer imageA, mitk::Image::Pointer imageB)
Execute a two-image filter operation using ITK access macros.
void ExecuteTwoImageFilterWithFunctor(Image1Type *imageA, Image2Type *imageB)
Internal templated method that applies a functor-based binary filter to two images.
mitk::Image::Pointer m_ResultImage
The result image produced by the most recent filter execution.
Find image slices visible on a given plane.