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 Modes Includes standard binary, inverse, truncation, to-zero, and OTSU automatic thresholding.

  • Range Slider Easy two-value slider for lower/upper threshold control when using manual modes.

  • Automatic Mode OTSU option hides manual sliders and computes the threshold from the image.

πŸ“ Usage Instructions

  1. Connect an image-producing block to the Image Any input.

  2. Select the desired Threshold Type. If you select OTSU, the slider will be hidden and thresholding is automatic.

  3. If using manual modes, adjust Threshold [Min, Max] until you get a clear separation of the features you care about.

  4. Use the Image Gray output 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 Blur before thresholding to reduce spurious pixels and get cleaner binary results.

  • If lighting varies across the scene, try combining Image Threshold with Image ROI Select to threshold only a relevant area.

  • For color-based separation, use HSV Filter or RGB Mask first, then feed the masked result into this block.

  • When working with very large images, use Image Resizer to downscale first to speed up interactive tuning.

  • Visualize results with Show Image while tuning thresholds. For recording examples, send the output to Image Logger or Image Write.

  • For line-based analysis after thresholding, connect the output to Histogram On Line to detect peaks along a row or column.

  • To locate objects after thresholding, combine this block with Find Object or shape analysis blocks (e.g., contour-related blocks) for robust detection.

πŸ› οΈ Troubleshooting

  • No clear foreground/background separation: try smoothing with Blur or adjust Threshold [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 with Show Image.

  • Slider disappears unexpectedly: this is expected when Threshold Type is set to OTSU (automatic mode).

Last updated