Various methods of sub-pixel edge and contour extraction processing in Halcon

Sub-pixel edge and contour extraction in halcon

In image processing, image features are extracted mainly from two angles, regions or edges. There are three ways to extract sub-pixel edges. After extraction, edge template matching can be used, and both connection and segmentation can be used. This does not involve edge pairs as operators for visual measurement, only for newcomers who have just learned halcon.
insert image description here
This picture represents three ideas for using edges in the course of the project. The supervisor of a large factory asked me this question before, and I think it is necessary to talk about it, hehe. Of course, the real edge extraction depends on the lighting of the light source, the specific needs of the project, etc. Here are just a brief introduction of three ideas.
The first way of thinking is my very common way of thinking. After finding out the ROI area, I then cut out the specific area from the original image and extract the edges in the area. Note here that there is a slight difference between the edge and the outline. The edge includes the internal texture and the part of the grayscale change, which often refers to the sub-pixel level line. The outline generally refers to the surrounding part of the area. If the area is extracted first, considering that there are mature threshold segmentation algorithms, such as dynamic threshold segmentation, watershed segmentation, threshold segmentation, etc., the noise caused by some lighting can be eliminated.
insert image description here
If you zoom in on the details of the image, you can see that the XLD (sub-pixel edge) is a line, which will be interpolated within the pixel, and the enlarged image will not change, while the outline is around the image area. If you zoom in, you will see that the pixel is not interpolated . Many times, image processing algorithm engineers do not distinguish between edges and contours, but it is best to make a strict distinction, so that you will know the difference when you see contour and xld in halcon.
insert image description here
Next, the relevant operators in the first idea are explained:
first, segment the area of ​​the image, then convert the area into a contour, and then select the contour (in this step, you can use feature detection to view the features of xld)
insert image description here

threshold (Image, Regions, 163, 255)
gen_contour_region_xld (Regions, Contours, 'border')
select_contours_xld (Contours, SelectedContours, 'contour_length', 0.5, 200, -0.5, 0.5)

The second way of thinking is to directly convert the entire image into xld, and then select the xld you want step by step

edges_sub_pix (Image, Edges, 'canny', 1, 20, 40)
select_shape_xld (Edges, SelectedXLD, 'circularity', 'and', 0.4, 0.6)

The image effect is
insert image description here
that the third is to find the xld based on the gray value range of the whole image, where the xld is closed, and here is to find the xld of the area with a gray value smaller than 128

threshold_sub_pix (Image, Border, 128)

insert image description here

Guess you like

Origin blog.csdn.net/qq_43376782/article/details/121821725