遗忘海岸

江湖程序员 -Feiph(LM战士)

导航

圆的拟合__测量圆心距

read_image(Image, 'gj1')
emphasize (Image, ImageEmphasize, 7, 7, 1)

rgb1_to_gray (ImageEmphasize, GrayImage)
threshold (GrayImage, Regions, 62, 255)
**填充孔洞
fill_up (Regions, RegionFillUp)
**断开并选择
connection (RegionFillUp, ConnectedRegions)
select_shape (ConnectedRegions, SelectedRegions, 'area', 'and', 141786, 159011)
**扩展边缘到工件外周那圈黑的
dilation_circle (SelectedRegions, RegionDilation, 5)
**填写边缘
shape_trans (RegionDilation, RegionTrans, 'convex')

**由区域获取外边缘轮廓
gen_contour_region_xld (RegionTrans, Contours, 'border')
**拟合外边缘轮廓
fit_circle_contour_xld (Contours, 'algebraic', -1, 0, 0, 3, 2, Row, Column, Radius, StartPhi, EndPhi, PointOrder)
**由拟合参数生成一个拟合后的轮廓 
gen_circle_contour_xld (ContCircle, Row, Column, Radius, 0, rad(360), 'positive', 1)
stop()
*********处理内圆*****************
threshold (GrayImage, Regions1, 12, 36)
fill_up (Regions1, RegionFillUp1)
connection (RegionFillUp1, ConnectedRegions1)
select_shape (ConnectedRegions1, SelectedRegions1, ['area','circularity'], 'and', [18599,0.6916], [26972.6,0.9074])
shape_trans (SelectedRegions1, RegionTrans1, 'outer_circle')
gen_contour_region_xld (RegionTrans1, Contours1, 'border')
fit_circle_contour_xld (Contours1, '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)


dev_clear_window ()
dev_display (ContCircle1)
dev_display (ContCircle)
disp_cross (200000, Row1, Column1, 6, 0)
disp_cross (200000, Row, Column, 6, 0)
**计算圆心距离
distance_pp (Row, Column, Row1, Column1, Distance)
disp_message (200000, Distance, 'window', 20, 20, 'black', 'true')
View Code

posted on 2021-08-12 09:30  遗忘海岸  阅读(257)  评论(0编辑  收藏  举报