Subtract Images
This function block computes the pixel-wise difference between two images to highlight changes or defects. It is useful for comparison tasks such as detecting deviations from a reference, visual inspection, and motion/change analysis.
π₯ Inputs
Actual Image Input socket β the image to be compared (source image).
Reference Image Input socket β the image to subtract from the actual image (baseline or reference).
π€ Outputs
Difference Image Output socket β resulting image showing the per-pixel difference between the inputs.
πΉοΈ Controls
This block has no user-facing controls or widgets.
π¨ Features
Produces a visual difference image that emphasizes pixel-level changes between two equally sized images.
Works with color or grayscale images (both inputs must share the same dimensions).
Simple and fast operation suitable as a preprocessing step for downstream detection or logging.
βοΈ Running Mechanism
When both input sockets provide images, the block produces a Difference Image by performing a per-pixel subtraction of the reference from the actual image. The block requires that both images have identical dimensions; if sizes differ, the block will report an error. The difference output can be fed into visualization, thresholding or counting blocks to interpret the result.
π Usage
Connect a source image to the
Actual Imageinput socket.Connect a baseline or reference image to the
Reference Imageinput socket.Make sure both images have the same size. If not, insert the
Image Resizeblock before this block.Use the
Difference Imageoutput for visualization or further processing.
Examples of common workflows:
Visual inspection: connect
Difference ImagetoShow Imageto preview changes.Binary detection: feed
Difference ImageintoImage Thresholdto create a mask of changed areas.Quantification: pass the thresholded mask to
Non-zero of Imageto count changed pixels.Logging: save results with
Image LoggerorImage Writefor record keeping.
π‘ Tips and Tricks
Ensure image alignment and resolution match before subtraction. Use
Image Resizeor geometric alignment blocks if needed.To make subtle differences more visible, apply
Contrast OptimizationorNormalize Imageto theDifference Imagebefore visualization.Convert the difference to a binary mask using
Image Thresholdto isolate meaningful changes. Combine the mask withNon-zero of Imageto get a numeric measure of change.For quick inspection during development, connect the output to
Show Image. For automated runs, save results withImage LoggerorImage Write.If you expect single-channel output, check input channel formats (grayscale vs RGB) upstream and convert consistently.
π οΈ Troubleshooting
Mismatched image sizes Ensure both inputs share the same width and height. Use the
Image Resizeblock to resample one of the images.Very low or no visible difference Apply
Contrast OptimizationorNormalize Imageto amplify small changes, or useImage Thresholdto create a binary mask.Unexpected colors or channels Confirm both inputs are in the same color space (both grayscale or both RGB) before connecting them.
Need a numeric change measure After thresholding the difference, send the mask to
Non-zero of Imageto obtain a count of changed pixels.
Last updated