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 Imagesocket, the block converts color images to grayscale if necessary.The chosen
Threshold Typedetermines how local threshold values are computed across the image.The
Kernel Sizedetermines the size of the local area used to compute each threshold.The block outputs a binary grayscale image on the
Image Graysocket that highlights foreground regions according to the selected parameters.
π Usage instructions
Connect a camera or image source to
Input Image.Select the
Threshold Typethat best fits your scene (try both options).Adjust
Kernel Sizeto match the scale of local illumination changes or object details.Use the
Thresholdcontrol to tune final brightness of the binary output.Inspect the result on the
Image Grayoutput and iterate parameters as needed.
π‘ Tips and Tricks
If the input is noisy, add a
Blurblock before this block to reduce spurious pixels.For scenes with complex color variations, use
HSV FilterorImage Color Matchto isolate the target color region before thresholding.If you only need to threshold a sub-region, crop first with
Image ROI Selectand feed the cropped image into this block to speed tuning and reduce false detections.To ensure downstream blocks get the right size, use
Image Resizebefore thresholding when working with very large images.Visualize results using
Show Imageso you can interactively inspect thresholding output while adjusting controls.Combine with
Histogram On Lineto inspect pixel value distributions along a line and refine theKernel SizeandThresholdsettings.
π οΈ Troubleshooting
If the output is almost entirely black or white, try increasing or decreasing the
Thresholdvalue and adjustingKernel Size.If edges are broken or fragmented, try adding
Bluror using a largerKernel Sizeto stabilize local threshold estimations.If only part of the object is detected, crop the area with
Image ROI Selector refine colors withHSV Filterbefore thresholding.
Last updated