Summary analysis of Halcon binarization function


1.threshold

Function prototype :

threshold(Image : Region : MinGray, MaxGray : )

Function :
Use global threshold to segment images.
Parameter description :
Image: HImage type, input image, that is, the image to be segmented.
Region: HRegion type, output region, that is, the segmented region.
MinGray: Input grayscale low threshold, 0~255.
MaxGray: Input grayscale high threshold, 0~255, which needs to be greater than MinGray.
Function principle : The operator extracts pixels whose gray value gray satisfies the condition
: MinGray < gray < MAxGray from the input image .
For a more detailed analysis, please go to
the detailed explanation of the binary threshold function

2.fast_threshold

Function prototype :

fast_threshold(Image : Region : MinGray, MaxGray, MinSize : )

Function :
Use global threshold to segment images.
Parameter description :
Image: HImage type, input image, that is, the image to be segmented.
Region: HRegion type, output region, that is, the segmented region.
MinGray: Input grayscale low threshold, 0~255.
MaxGray: Input grayscale high threshold, 0~255, which needs to be greater than MinGray.
MinSize: The minimum size of the extracted object.
Function principle : The operator extracts pixels whose gray value gray satisfies the condition
: MinGray < gray < MAxGray from the input image .
To reduce processing time, selection is performed in two steps: first, all points on the selected horizontal line, specified by their distance MinSize, are processed. Next, process the neighborhood of all previously selected points (size (2 MinSize+1) x (2 MinSize+1)).

3.bin_threshold

Function prototype :

bin_threshold(Image : Region : : )

Function :
Use the automatically determined global threshold to segment a single-channel gray value image.
Parameter description :
Image: HImage type, input image, that is, the image to be segmented.
Region: HRegion type, output region, that is, the segmented region.
Function principle :
First, determine the relative histogram of gray value. Then, the relevant minimum value minimum is extracted from the histogram as a parameter of the threshold operation. To reduce the number of minima, the histogram is smoothed using Gaussian, and the size of the Gaussian template is gradually enlarged until there is only one minimum value in the smoothed histogram. Finally, select the pixels from the minimum value of the image to minimum.

4.auto_threshold

Function prototype :

auto_threshold(Image : Regions : Sigma : )

Function :
Segment the image using a threshold determined by the histogram.
Parameter description :
Image: HImage type, input image, that is, the image to be segmented.
Region: HRegion type, output region, that is, the segmented region.
Sigma : Input, for Gaussian smoothing of the histogram, Sigma >= 0.0.
Function principle :
Use multiple thresholds to segment single-channel images. First determine the absolute histogram of grayscale values. Then, the relevant minimum values ​​are extracted from the histogram, which in turn are used as parameters for the threshold operation. The byte image has a threshold of 0,255 and all minimum values ​​extracted from the histogram (after smoothing the histogram with a Gaussian filter with standard deviation Sigma). For each gray value interval, a region is generated. Therefore, the number of regions is the number of minimum values ​​+ 1.

5.binary_threshold

Function prototype :

binary_threshold(Image : Region : Method, LightDark : UsedThreshold)

Function :
Use the automatically determined global threshold to segment a single-channel image.
Parameter description :
Image: HImage type, input image, that is, the image to be segmented.
Region: HRegion type, output region, that is, the segmented region.
Method: Input, select the method used for binarization. There are 'max_separability', 'smooth_histo' respectively.
LightDark: Input, choose to extract foreground or background, 'dark', 'light' respectively.
UsedThreshold: Output, the binarization threshold used by the operator to automatically calculate.
Function principle :
The operator has two methods, which can only be used for images with bimodal histograms.
1. 'smooth_histo': The principle is the same as the bin_threshold() operator.
2. 'max_separability': Maximum inter-class method. This algorithm first calculates the histogram of the image, and then uses statistical moments to find the optimal threshold that divides pixels into foreground and background to maximize the separability of the two classes. This method only works with bytes and uint2 images. It is less sensitive to thin isolated peaks in the histogram that are far away from the rest of the spectrum, and is generally faster than "smooth_histo". Detailed analysis + source code implementation

6.dual_threshold

Function prototype :

dual_threshold(Image : RegionCrossings : MinSize, MinGray, Threshold : )

Function :
Threshold segmentation of signed images using dual thresholding.
Parameter description :
Image: HImage type, input image, that is, the image to be segmented.
RegionCrossings: HRegion type, output region, that is, the divided region.
MinSize: input, areas smaller than MinSize are suppressed.
MinGray: Input, suppress areas where the absolute gray value is smaller than MinGray.
Threshold: Input, areas with grayscale values ​​less than Threshold (or greater than -Threshold) will be suppressed.
Function principle :
Divide the input image into areas with gray value > Threshold ("positive" area) and areas with gray value < Threshold ("negative" area). Only "positive" or "negative" areas with a size larger than MinSize will be retained, and areas with grayscale values ​​between MinGray and -MinGray will be suppressed.

7.hysteresis_threshold

Function prototype :

hysteresis_threshold(Image : RegionHysteresis : Low, High, MaxLength : )

Function :
Perform hysteresis threshold segmentation on the image.
Parameter description :
Image: HImage type, input image, that is, the image to be segmented.
RegionHysteresis: HRegion type, output region, that is, the divided region.
Low: input, the lower threshold of the gray value.
High: input, the upper threshold of the gray value.
MaxLength: input, the maximum length of the path from the "potential" point to the "safe" point.
Function principle :
All points with a gray value greater than or equal to High in the input image are immediately accepted ("safe" points). On the contrary, all points with gray values ​​less than Low will be rejected immediately. If a "potential" point is connected to a "safe" point by a "potential" point path of length at most MaxLength points, then "potential" points with a gray value between the two thresholds will be accepted. This means that "safe" points affect their surroundings (hysteresis).

8.dyn_threshold

For detailed explanation, please refer to the previous article: Detailed explanation of dyn_threshold function

Guess you like

Origin blog.csdn.net/weixin_44901043/article/details/123126308