🟠 Image Binarization

Function Description

This operator is used to convert input grayscale images to binary images (i.e., images containing only black and white pixels). Through set thresholds and methods, pixels in the image are divided based on their grayscale values, with some pixels becoming pure white (pixel value 255) and others becoming pure black (pixel value 0), thereby highlighting image contours or specific regions.

Usage Scenarios

  • Image simplification and preprocessing: Serves as a preprocessing step for subsequent complex algorithms, reducing computational load and excluding unimportant background information.

  • Target segmentation: When target objects have obvious grayscale differences from the background, binarization can quickly separate targets from background, generating mask images.

Input Output

Input

Grayscale image: Single-channel grayscale image to be processed.

Output

Mask image: Mask image generated after binarization processing, which is a single-channel binary image.

Parameter Description

Binarization Method

Parameter Description

Select the specific algorithm used when performing binarization.

Parameter Adjustment

  • Standard binarization: Most basic method. Pixels with grayscale values greater than or equal to the binarization threshold become white (255), those less than the threshold become black (0). Suitable for simple scenarios with uniform lighting and very obvious contrast between target and background.

  • Inverse binarization: Logic opposite to standard binarization. Pixels with grayscale values greater than or equal to the binarization threshold become black (0), those less than the threshold become white (255). Suitable for scenarios needing to extract darker targets from bright backgrounds.

  • Otsu method adaptive threshold: An adaptive threshold method. It automatically analyzes the grayscale histogram of the entire image and calculates a threshold that maximizes inter-class variance between foreground and background, suitable for uneven lighting and other scenarios.

  • The triangle principle: Another adaptive threshold method. It also automatically calculates thresholds, suitable for images with grayscale histograms having only one main peak, such as images with mostly dark background and one brighter target.

Binarization Threshold

Parameter Description

Sets a grayscale value boundary line used to judge whether each pixel should become black or white.

Available when selecting "Standard binarization" and "Inverse binarization" methods.

Parameter Adjustment

  • Increase this value: Will cause more pixels to be classified as black due to grayscale values below the threshold, resulting in fewer white areas in the final image. Suitable for scenarios needing to suppress background noise or extract only the brightest regions in images.

  • Decrease this value: Will cause more pixels to be classified as white due to grayscale values above the threshold, resulting in more white areas in the final image. Suitable for scenarios where targets have low brightness or poor contrast with background.

Parameter Range

[0,255], default value: 120