Image Arithmetic Operation

You are currently viewing the documentation for the latest version (2.2.0). To access a different version, click the "Switch version" button located in the upper-right corner of the page.

■ If you are not sure which version of the product you are currently using, please feel free to contact Mech-Mind Technical Support.

Description

This Step is used to perform pixel-wise arithmetic operations (addition, subtraction, multiplication, or division) or combination operations (maximum, minimum, inversion) on the input grayscale images. The result can be adjusted using a multiplier and an addend. If the input consists of two images, the two images must have the same size.

Usage Scenario

This Step is mainly used to perform pixel-by-pixel operation on the grayscale image and generate a new image. For example, two grayscale images can be synthesized pixel-wise by adding, taking the maximum value, or taking the minimum value; the grayscale difference between the two images can be highlighted by subtraction; the grayscale variation relationship can be adjusted by multiplication or division; and the relationship between light and darkness can be reversed by inverting the relationship for image preprocessing before subsequent processing.

Basic Concepts

  • Grayscale image

    In a grayscale image, each pixel value represents brightness, ranging from 0 to 255, where 0 is the darkest and 255 is the brightest.

  • Pixel-level operations

    Pixel-level operations involve processing pixels at corresponding positions in the input image(s) individually to generate a new image. For operation types that require two input images, the two images must be of the same size; if the operation result exceeds the grayscale range, it will be clipped to 0–255.

Workflow

The process of configuring this Step is shown below:

workflow
  1. Select the Operation to perform in the Parameters section.

  2. Configure the input. Connect the Step ports in the graphical programming workspace or select the input under Input in the parameter configuration panel.

  3. Adjust the Multiplier and Addend parameters as needed to further adjust the operation result.

  4. Run the Step, and view output.

Input Description

Input item Description

Grayscale Image 1

The first grayscale image used for the operation.

Grayscale Image 2

The second grayscale image used for the operation.

Grayscale Image

The image used for gray value inversion.

Only visible when Operation is set to Invert.

Parameter Description

Parameter Description

Operation

This parameter is used to select the type of pixel-level operation to be performed.

  • Add: Adds the pixel values of the two input images pixel by pixel to generate a new image. If the sum of pixel values exceeds 255, the resulting pixel value is set to 255.

  • Subtract: Subtracts the pixel values of the two input images pixel by pixel to generate a new image. If the difference of pixel values is less than 0, the resulting pixel value is set to 0.

  • Multiply: Multiplies the pixel values of the two input images pixel by pixel to generate a new image. If the product of pixel values exceeds 255, the resulting pixel value is set to 255.

  • Divide: Divides the pixel values of the two input images pixel by pixel to generate a new image. If the divisor is 0, the resulting pixel value is set to 0.

  • Maximum: Takes the maximum pixel value of the two input images pixel by pixel to generate a new image.

  • Minimum: Takes the minimum pixel value of the two input images pixel by pixel to generate a new image.

  • Invert: Inverts the pixel values of the input image. Inverted pixel value = 255 - Original pixel value.

Only one grayscale image is needed for inverting the image. For other types, please ensure that the two input images are of the same size.

Multiplier

The parameter is used to adjust each pixel value of the image after the operation. Final pixel value = Pixel value after operation × Multiplier + Addend. When the multiplier and addend work together, if the final pixel value falls outside the range of 0–255, the result will be clipped to this range.

This Step is mainly used to adjust the scaling of the operation result. Increasing the multiplier typically enhances contrast (differences between light and dark), while decreasing it reduces contrast.

Default value: 1.0

Addend

The parameter is used to adjust each pixel value of the image after the operation. Final pixel value = Pixel value after operation × Multiplier + Addend. When the multiplier and addend work together, if the final pixel value falls outside the range of 0–255, the result will be clipped to this range.

Primarily used to shift pixel values globally. Increasing the addend brightens the overall image, while decreasing it darkens the image.

Default value: 0

Output Description

The image generated after the operation.

Troubleshooting

  • For common errors, see Error Code List.

  • If the error code is inconsistent with the error message, please contact Technical Support for help.

Inconsistent Input Image Sizes

Symptom:

After the Step is run, it prompts that the input single-channel images should be of the same size.

Possible Cause:

The two input grayscale images are of different sizes, making pixel-by-pixel operation impossible.

Solution:

Check the dimensions of the two input grayscale images to ensure that they are identical before running the Step.

Is this page helpful?

You can give a feedback in any of the following ways:

We Value Your Privacy

We use cookies to provide you with the best possible experience on our website. By continuing to use the site, you acknowledge that you agree to the use of cookies. If you decline, a single cookie will be used to ensure you're not tracked or remembered when you visit this website.