Halcon-Detailed explanation of edge detection operator

One, operator introduction

1.1 Types
of commonly used edge detection operators in
halcon include the following: 1. edges_image: extract 2D image edges
2. edges_sub_pix: extract 2D image sub-pixel edges
3. edges_object_model_3d: extract 3D image edges
4. edges_color and edges_color_sub_pix: extract color images edge
1.2 distinction
edges_image selectively extract a variety of edge detection algorithm object edge, which differs from the subpixel edge operator that edges_image edge feature extraction is pixel unit, edges_sub_pix is smaller than a pixel unit to the extracted edge , Generally, moment method, interpolation method and fitting method are used.

Second, detailed explanation

2.1 edges_image(Image : ImaAmp, ImaDir : Filter, Alpha, NMS, Low, High : )

The main parameters in this operator include:
ImaDir (the edge direction of the image, it is useless for the sobel_fast algorithm, because it does not calculate the direction information)
Filter (the edge operator, including'canny','deriche1','deriche1_int4','deriche2', ' deriche2_int4','lanser1','lanser2','mshen','shen','sobel_fast')
Alpha (filter parameter, small value leads to strong smoothing, but less detail (the opposite of canny operator))
NMS( Non-maximum suppression (set to none, indicating that this value is not needed))
Low (lower threshold for hysteresis threshold operation (if threshold setting is not required, then negative))
High (upper threshold for hysteresis threshold operation (if not required) Threshold setting is negative))
2.2 Edge detection algorithm
For algorithms, the canny operator is currently the most stable edge detection method.
The canny algorithm consists of three stages: edge strength, edge refinement (NMS), and hysteresis threshold.
First, the calculation of edge strength is to calculate the image gradient: gradient magnitude matrix, gradient direction matrix:
1) Image grayscale
2) Gaussian filter
3) Sobel filter to obtain the gradient image in the x and y directions, denoted as fx, fy
4) Use fx and fy to find the gradient amplitude and the direction of the gradient.
5) The gradient direction at this time is any value between [-90, +90], and they are regularized into four types of 0, 45, 90, 135 degrees.
Then, calculate the non-maximum suppression (NMS), we classify first according to the directions stored in the regularized direction matrix, and then compare three pixels in the same direction to ensure that the value of the middle pixel is the largest, otherwise it is set to zero, and finally The cleaned gradient amplitude matrix is ​​obtained.
Finally, continue to process the gradient amplitude matrix, and divide the image into three parts according to the set high threshold value high and low threshold value low:
1. Pixels with gradient amplitude greater than high, set the value to 255;
2. Pixels with gradient amplitude less than low , the value is set to 0;
3. in the middle of the gradient magnitude of a pixel with its eight neighbors is determined, if the neighborhood is greater than high, then the pixel is set to the intermediate 255;
next, relates to
the following procedures binding Demonstration and explanation of each filtering algorithm:

read_image (I, 'C:/Users/Administrator/Desktop/a.png')
dev_close_window ()
dev_open_window(0, 0, 512, 512, 'black', WindowHandle)
get_image_size (I, Width, Height)
dev_set_window_extents (0, 0, Width, Height)
rgb1_to_gray(I, GrayImage)
*dev_set_lut ('change2')
*设置滞后阈值为默认值
*滤波参数值Alpha
*设置滞后阈值必须大于0,小于255,值越小细节越多,但同时会带来很多不需要的边缘信息。
*值越大则会丢失边缘,很多边缘点值都会被设置为0。
edges_image(GrayImage, ImaAmp, ImaDir, 'canny', 1, 'nms', 20, 40)
dev_display(ImaAmp)

Insert picture description here
Insert picture description here

Guess you like

Origin blog.csdn.net/baidu_35536188/article/details/112351198