Image Adaptive Threshold

This function block converts a grayscale or color image into a clean binary image by applying an adaptive threshold. It is useful when lighting conditions vary across the image and a single global threshold is not sufficient.

πŸ“₯ Inputs

Input Image (input socket) Accepts a color or grayscale image to be thresholded.

πŸ“€ Outputs

Image Gray (output socket) Produces a binary (black & white) grayscale image after adaptive thresholding.

πŸ•ΉοΈ Controls

Threshold Type Choose between adaptive methods (for example, mean or gaussian) to compute local thresholds.

Threshold Adjusts the output intensity value used for the binary result.

Kernel Size Controls the neighborhood size used to compute the local threshold; larger values consider a wider local area.

🎯 Features

  • Automatically handles color inputs by converting them to grayscale first.

  • Adapts threshold locally across the image, making it robust to non-uniform lighting.

  • Simple sliders and dropdown let you tune sensitivity and neighborhood size without technical details.

  • Produces a clean binary image suitable for downstream detection and measurement blocks.

βš™οΈ How it runs

  • When an image is provided to the Input Image socket, the block converts color images to grayscale if necessary.

  • The chosen Threshold Type determines how local threshold values are computed across the image.

  • The Kernel Size determines the size of the local area used to compute each threshold.

  • The block outputs a binary grayscale image on the Image Gray socket that highlights foreground regions according to the selected parameters.

πŸ“ Usage instructions

  1. Connect a camera or image source to Input Image.

  2. Select the Threshold Type that best fits your scene (try both options).

  3. Adjust Kernel Size to match the scale of local illumination changes or object details.

  4. Use the Threshold control to tune final brightness of the binary output.

  5. Inspect the result on the Image Gray output and iterate parameters as needed.

πŸ’‘ Tips and Tricks

  • If the input is noisy, add a Blur block before this block to reduce spurious pixels.

  • For scenes with complex color variations, use HSV Filter or Image Color Match to isolate the target color region before thresholding.

  • If you only need to threshold a sub-region, crop first with Image ROI Select and feed the cropped image into this block to speed tuning and reduce false detections.

  • To ensure downstream blocks get the right size, use Image Resize before thresholding when working with very large images.

  • Visualize results using Show Image so you can interactively inspect thresholding output while adjusting controls.

  • Combine with Histogram On Line to inspect pixel value distributions along a line and refine the Kernel Size and Threshold settings.

πŸ› οΈ Troubleshooting

  • If the output is almost entirely black or white, try increasing or decreasing the Threshold value and adjusting Kernel Size.

  • If edges are broken or fragmented, try adding Blur or using a larger Kernel Size to stabilize local threshold estimations.

  • If only part of the object is detected, crop the area with Image ROI Select or refine colors with HSV Filter before thresholding.

Last updated