Image Thresholding

You are currently viewing the documentation for version 1.8.1. To access documentation for other versions, click the "Switch Version" button located in the upper-right corner of the page.

■ To use the latest version, visit the Mech-Mind Download Center to download it.

■ If you're unsure about the version of the product you are using, please contact Mech-Mind Technical Support for assistance.

Function

This Step filters image pixels according to the set threshold and binarizes the pixels above and below the threshold according to the set rules.

Binary images are images whose pixels have only two possible intensity values. Numerically, the two values are often 0 for black, and 255 for white.

Image binarization is the process of converting a non-binary image to a binary image.

binarize image functional description

Usage Scenario

This Step is a general image processing Step. It is generally used to segment pixels that meet threshold conditions on 2D images.

Input and Output

binarize image input and output

Parameter Description

This Step provides four segment types for separating the target object from its background.

  • AdaptiveThreshold: a global adaptive thresholding method that includes two types of operation (THRESH_BINARY, THRESH_BINARY_INV).

  • DualThreshold: a thresholding method with both a low threshold and a high threshold to segment pixels that meet the conditions.

  • DynamicThreshold: a dynamic thresholding method that provides four thresholding types (Bright, Dark, In range, Out of range) and three image filter methods (Mean filter, Gaussian filter, Median filter). In addition, the pixel value offset and filter kernel size can be adjusted.

  • Threshold: a thresholding method with a global fixed threshold. With this method, a fixed threshold is set, and seven operation types (THRESH_BINARY, THRESH_BINARY_INV, THRESH_TRUNC, THRESH_TOZERO, THRESH_TOZERO_INV, THRESH_OTSU, THRESH_TRIANGLE) are introduced to segment pixels that meet the conditions.

AdaptiveThreshold

Operation

Description: This parameter is used to select the operation type for separating the target object from its background.

Value list: THRESH_BINARY and THRESH_BINARY_INV

  • THRESH_BINARY: generates a mask of pixels whose values are higher than the threshold.

  • THRESH_BINARY_INV: generates a mask of pixels whose values are lower than the threshold.

Default value: THRESH_BINARY

Tuning recommendation: Please select the operation type according to the actual requirement.

DualThreshold

Low Threshold

Description: If the low threshold is set to be lower than the high threshold, the pixels with values between the two thresholds will be set to 255, and other pixels will be set to 0. If the low threshold is set to be higher than the high threshold, the pixels with values beyond the interval set by the two thresholds will be set to 255, and other pixels will be set to 0.

Default value: 0

Tuning recommendation: Please set a proper value according to the actual requirement.

High Threshold

Description: See “Low Threshold.”

Default value: 100

Tuning recommendation: Please set a proper value according to the actual requirement.

DynamicThreshold

Thresholding Type

Description: This parameter determines whether the values of pixels should be set to 255 or 0.

Value list: Bright, Dark, In Range, and Out of Range. If P_o is a pixel in the original image, P_f is the pixel corresponding to P_o in the filtered image, and offset is the set value of Pixel Value Offset, then the thresholding types can be explained as follows:

  • Bright: If P_o ≥ P_f + offset, then P_o will be set to 255, or else it will be set to 0.

  • Dark: If P_o ≤ P_f − offset, then P_o will be set to 255, or else it will be set to 0.

  • In Range: If P_f − offset ≤ P_o ≤ P_f + offset, then P_o will be set to 255, or else it will be set to 0.

  • Out of Range: If P_o < P_f − offset or P_o > P_f + offset, then P_o will be set to 255, or else it will be set to 0.

Image Filter

Description: This parameter is used to select the filter to apply to the image.

Value list: Mean filter, Gaussian filter, and Median filter

  • Mean filter: Smooth the image by replacing the center value in the sliding window with the average of all the pixel values in the window.

  • Gaussian filter: Smooth the image and remove detail and noise.

  • Median filter: Replace each pixel with the median of neighboring pixels in the window.

Default value: Mean filter

Tuning recommendation: Please select a proper image filter method according to the actual requirement.

Filter Kernel Size

Description: This parameter sets the sliding window size (pixel-wise edge length) of the filter.

Default value: 3

Tuning recommendation: Please input an odd number because there should always be a center pixel in the window. Even numbers input will be incremented by one.

Pixel Value Offset

Description: The offset pixel value to apply to all pixels of the image after filtering.

Default value: 15.00

Threshold

Threshold (0–255)

Description: This parameter sets a threshold for filtering image pixels.

Default value: 128

Tuning recommendation: Please set a proper value according to the actual requirement.

Operation

Description: This parameter is used to select the operation type for separating the target object from its background.

Value list: THRESH_BINARY, THRESH_BINARY_INV, THRESH_TRUNC, THRESH_TOZERO, THRESH_TOZERO_INV, THRESH_OTSU, and THRESH_TRIANGLE

  • THRESH_BINARY: If the original pixel value is above the set threshold, the value will be set to 255, or else it will be set to 0.

  • THRESH_BINARY_INV: If the original pixel value is above the set threshold, the value will be set to 0, or else it will be set to 255.

  • THRESH_TRUNC: If the original pixel value is above the set threshold, the value will be set to the same value as the set threshold, or else the original value will be retained.

  • THRESH_TOZERO: If the original pixel value is above the set threshold, the original value will be retained, or else it will be set to 0.

  • THRESH_TOZERO_INV: If the original pixel value is above the set threshold, the value will be set to 0, or else the original value will be retained.

  • THRESH_OTSU: Find a global threshold with the Otsu’s method.

  • THRESH_TRIANGLE: Find a global threshold with the triangle method.

Default value: THRESH_BINARY

Tuning recommendation: THRESH_BINARY or THRESH_BINARY_INV is recommended to use.

We Value Your Privacy

We use cookies to provide you with the best possible experience on our website. By continuing to use the site, you acknowledge that you agree to the use of cookies. If you decline, a single cookie will be used to ensure you're not tracked or remembered when you visit this website.