halcon fits a circle and finds its intersection

1, directly on the code

*Read the picture
read_image (Image, 'C:/Users/yashunxu/Desktop/5 process image/Halcon/MER-500-7UM(RQ0002001015)_2017-11-13_17_01_50_533-0.bmp')
* Generate ROI
gen_rectangle1 (ROI_0, -0.5, 1679.16, 613.82, 2274.3)
*Remove the area outside the ROI
reduce_domain(Image,ROI_0, ImageReduced)
* Crop ROI
crop_domain(ImageReduced, ImagePart)
* Scale the image
zoom_image_factor (ImagePart, ImagePart, 0.5, 0.5, 'weighted')
* Get image size
get_image_size (ImagePart, Width, Height)
*
* Compute the outer contour
dev_clear_window()
* Get image border subpixels
edges_sub_pix (ImagePart, Edges, 'canny',3, 5, 22)
* Get the border length
length_xld (Edges, Length)
* mark border length and sort
tuple_sort_index (Length, Indices)
*Select target boundary
select_obj (Edges, ContourComplete1, Indices[|Indices| - 1] + 0)
* Fit the selected target boundary into a circle
fit_circle_contour_xld(ContourComplete1, 'algebraic', -1, 0, 0, 3, 2, Row1, Column1, Radius1, StartPhi1, EndPhi1, PointOrder1)
* Generate circle
gen_circle_contour_xld(ContCircle1, Row1, Column1, Radius1, 0, 6.28318, 'positive', 1)
*Select target boundary
select_obj (Edges, ContourComplete2, Indices[|Indices| - 1] + 1)
* Fit the selected target boundary into a circle
fit_circle_contour_xld (ContourComplete2,'algebraic', -1, 0, 0, 3, 2, Row2, Column2, Radius2, StartPhi2, EndPhi2, PointOrder2)
* Generate circle
gen_circle_contour_xld (ContCircle2, Row2, Column2, Radius2, 0, 6.28318, 'positive', 1)

*Compute the intersections to calculate the intersection coordinates
intersection_circles(Row1, Column1, Radius1, 0, 6.28318, 'positive', Row2, Column2, Radius2, 0, 6.28318, 'positive', Row, Column, IsOverlapping)

* Display results
display_intersection_points (ContCircle1,ContCircle2,3600, Row, Column, IsOverlapping, 1, 'intersection_circles', '')

2. Corresponding result graph


Figure 1 Original image


Figure 2 Select ROI


Figure 3 Removing the outer region of the ROI


Figure 4 Cropped ROI


Figure 5. Generate the sub-pixel boundary of the ROI bright area


Figure 6 Generate a fitted circle


Figure 7 and Figure 6 zoom in


Figure 8. Image variables and control variables

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324935373&siteId=291194637