Purpose

This module performs arithmetic operations on two images.

The output is the processed image according to the selected function and constant.

This module only supports scalar types for most functions. The functions Add, Multiply, Subtract, Equal, NotEqual, EqualMask, NotEqualMask and MaskConstantIn also support the default extended types: Complex, Vector2, Vector3, Vector6, Matrix2 and Matrix3.

Usage

Select the arithmetic operation you want to apply to the two input images. Some operations (see below) require the specification of a further constant.

Tips

The example network demonstrates how two images can be added by the Arithmetic2 operator.

Windows

Default Panel

../../../Modules/ML/MLBasicModules/mhelp/Images/Screenshots/Arithmetic2._default.png

Input Fields

input0

name: input0, type: Image

input1

name: input1, type: Image

Output Fields

output0

name: output0, type: Image

Parameter Fields

Visible Fields

Function

name: function, type: Enum, default: Add, deprecated name: Function

Defines the operation which is applied to the two input images.

Values:

Title Name Deprecated Name Description
Add Add Add (IMG1+IMG2) The input image 1 increased by input image 2 is passed to the output.
Multiply Multiply Multiply (IMG1*IMG2) The input image 1 multiplied by input image 2 is passed to the output.
Subtract Subtract Subtract (IMG1-IMG2) The input image 1 decreased by input image 2 is passed to the output.
Divide Divide Divide (IMG1/IMG2) The input image 1 divided by input image 2 is passed to the output.
Max Max Max (IMG1, IMG2) The maximum value of input images 1 and 2 is passed to the output.
Min Min Min (IMG1, IMG2) The minimum value of input images 1 and 2 is passed to the output.
Abs Max AbsMax   The value of input images 1 and 2, which is the maximum absolute value, is passed to the output.
Abs Min AbsMin   The value of input images 1 and 2, which is the minimum absolute value, is passed to the output.
Or Or OR (IMG1 or IMG2)

Apply a logical OR operation on the images. The OR operation is performed bitwise.

This is an integer operation, so that floating points will be calculated as integer.

And And AND (IMG1 and IMG2)

Apply a logical AND operation on the images. The AND operation is performed bitwise.

This is an integer operation, so that floating points will be calculated as integer.

Xor Xor XOR (IMG1 xor IMG2)

Apply a logical XOR operation on the images. The XOR operation is performed bitwise.

This is an integer operation, so that floating points will be calculated as integer.

Difference Difference Difference (|IMG1-IMG2|) The absolute difference between input image 1 and 2 is passed to the output.
Equal Equal EQ (i1 == i2 ? C : 0) The output image will have the value Constant, if image 1 equals image 2. Otherwise it will be zero.
Not Equal NotEqual NEQ (i1 != i2 ? C : 0) The output image will have the value Constant, if image 1 not equals image 2. Otherwise it will be zero.
Equal Mask EqualMask EQ2 ((i1 && i2 && i1==i2) ? C : 0) The output image will have the value Constant, if image 1 equals image 2 and both images are not zero. Otherwise it will be zero.
Not Equal Mask NotEqualMask NEQ2 ((i1 && i2 && i1!=i2 ) ? C : 0) The output image will have the value Constant, if image 1 not equals image 2 and both images are not zero. Otherwise it will be zero.
Mask Constant In MaskConstantIn MaskIn (IMG2 ? C : IMG1),Mask The output image data will be copied from image 1 where image 2 is zero. Where image 2 is non-zero, the value Constant will be written. This can be used to perform a “mask in” operation writing a different value than the one in the original mask and can be useful when both images have different data types.

Output Image Size

name: outputImageSize, type: Enum, default: InvalidateOutputIfSizesDiffer

Defines how the module should react if the image sizes of the input images differ.

Values:

Title Name Description
Adapt Output Image Size AdaptOutputImageSize

The module adapts the output image size to the input image sizes.

If the field autoReplicate is set to False (the default), the smallest input image size is used as the output iamge size, otherwise the largest input image size is used.

Invalidate Output If Sizes Differ InvalidateOutputIfSizesDiffer If the input image sizes differ, the output image is invalidated.

Constant

name: constant, type: Double, default: 0, deprecated name: C

Sets a constant value required for some arithmetic operations (see Function).

Hidden Fields

autoReplicate

name: autoReplicate, type: Bool, default: FALSE

Only on automatic panel

If checked, the output image size is taken from the union of the input images, and the input images are replicated periodically in order to fill the output image size.

Otherwise, the size of the output image is taken from the intersection of the input images.

This option is obsolete and shouldn’t be used, as it is only guaranteed to work correctly if the image size of the input images is an integral multiple of the page size of the output image. Use the Replicate module instead.