遗忘海岸

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

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

统计

圆的拟合__测量圆心距

复制代码
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   遗忘海岸  阅读(265)  评论(0编辑  收藏  举报

编辑推荐:
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
阅读排行:
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· .NET周刊【3月第1期 2025-03-02】
· [AI/GPT/综述] AI Agent的设计模式综述
· 分享 3 个 .NET 开源的文件压缩处理库,助力快速实现文件压缩解压功能!
点击右上角即可分享
微信分享提示