1,直接上代码
*读图 read_image (Image, 'C:/Users/yashunxu/Desktop/5处理图片/Halcon/MER-500-7UM(RQ0002001015)_2017-11-13_17_01_50_533-0.bmp') *生成ROI gen_rectangle1 (ROI_0, -0.5, 1679.16, 613.82, 2274.3) *去除ROI外区域 reduce_domain(Image,ROI_0, ImageReduced) *裁剪ROI crop_domain(ImageReduced, ImagePart) *对图像进行缩放 zoom_image_factor (ImagePart, ImagePart, 0.5, 0.5, 'weighted') *获取图像大小 get_image_size (ImagePart, Width, Height) * * Compute the outer contour dev_clear_window() *获取图像边界亚像素 edges_sub_pix (ImagePart, Edges, 'canny',3, 5, 22) *获取边界长度 length_xld (Edges, Length) *标记边界长度并排序 tuple_sort_index (Length, Indices) *选择目标边界 select_obj (Edges, ContourComplete1, Indices[|Indices| - 1] + 0) *拟合所选目标边界成圆 fit_circle_contour_xld(ContourComplete1, 'algebraic', -1, 0, 0, 3, 2, Row1, Column1, Radius1, StartPhi1, EndPhi1, PointOrder1) *生成圆 gen_circle_contour_xld(ContCircle1, Row1, Column1, Radius1, 0, 6.28318, 'positive', 1) *选择目标边界 select_obj (Edges, ContourComplete2, Indices[|Indices| - 1] + 1) *拟合所选目标边界成圆 fit_circle_contour_xld (ContourComplete2,'algebraic', -1, 0, 0, 3, 2, Row2, Column2, Radius2, StartPhi2, EndPhi2, PointOrder2) *生成圆 gen_circle_contour_xld (ContCircle2, Row2, Column2, Radius2, 0, 6.28318, 'positive', 1) *Compute the intersections计算交点坐标 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,相应的结果图
图一 原图
图二 选取ROI
图三 去除ROI外部区域
图四 裁剪ROI
图五 生成ROI亮区亚像素边界
图六 生成拟合圆
图七 图六放大看
图八 图像变量及控制变量图