Image Threshold
This function block converts an image into a binary or thresholded grayscale image. Use it to separate foreground from background, enhance contrast for detectors, or prepare images for shape and peak analysis.
π₯ Inputs (sockets)
Image Any Provide the input image (color or grayscale) to be thresholded.
π€ Outputs (sockets)
Image Gray The resulting thresholded grayscale image.
πΉοΈ Controls
Threshold Type Choose the threshold algorithm to apply (standard binary modes or automatic OTSU).
Threshold [Min, Max] Set the minimum and maximum threshold values using a range slider. (Hidden when OTSU is selected because OTSU chooses the optimal threshold automatically.)
π¨ Features
Multiple Threshold ModesIncludes standard binary, inverse, truncation, to-zero, and OTSU automatic thresholding.Range SliderEasy two-value slider for lower/upper threshold control when using manual modes.Automatic ModeOTSU option hides manual sliders and computes the threshold from the image.
π Usage Instructions
Connect an image-producing block to the
Image Anyinput.Select the desired
Threshold Type. If you select OTSU, the slider will be hidden and thresholding is automatic.If using manual modes, adjust
Threshold [Min, Max]until you get a clear separation of the features you care about.Use the
Image Grayoutput for downstream analysis or visualization.
π Evaluation
When the block runs, it converts the input to grayscale (if needed) and applies the selected threshold method. The processed grayscale image is emitted from the Image Gray output for further processing.
π‘ Tips and Tricks
Preprocess noisy images with
Blurbefore thresholding to reduce spurious pixels and get cleaner binary results.If lighting varies across the scene, try combining
Image ThresholdwithImage ROI Selectto threshold only a relevant area.For color-based separation, use
HSV FilterorRGB Maskfirst, then feed the masked result into this block.When working with very large images, use
Image Resizerto downscale first to speed up interactive tuning.Visualize results with
Show Imagewhile tuning thresholds. For recording examples, send the output toImage LoggerorImage Write.For line-based analysis after thresholding, connect the output to
Histogram On Lineto detect peaks along a row or column.To locate objects after thresholding, combine this block with
Find Objector shape analysis blocks (e.g., contour-related blocks) for robust detection.
π οΈ Troubleshooting
No clear foreground/background separation: try smoothing with
Bluror adjustThreshold [Min, Max].Too many small blobs after thresholding: increase the minimum threshold or preprocess with
Denoising/Blur.OTSU mode gives unexpected result: switch to a manual
Threshold [Min, Max]and tune visually withShow Image.Slider disappears unexpectedly: this is expected when
Threshold Typeis set to OTSU (automatic mode).
Last updated