开启左侧

一个精确测量圆环宽度的halcon程序

[复制链接]
sc_hym 发表于 2018-7-27 09:51:01 | 显示全部楼层 |阅读模式

效果图

效果图

  1. * Image Acquisition 01: Code generated by Image Acquisition 01
  2. read_image (Image, 'D:/images/ring.png')
  3. rgb1_to_gray (Image, GrayImage)
  4. dev_set_draw ('margin')
  5. median_image (GrayImage, ImageMedian, 'circle', 3, 'mirrored')
  6. threshold (ImageMedian, Region, 0, 50)
  7. gen_contour_region_xld (Region, outContours, 'border')
  8. fill_up (Region, RegionFillUp)
  9. *获取内部白色区域
  10. difference (RegionFillUp, Region, RegionDifference)
  11. gen_contour_region_xld (RegionDifference, inContours, 'border')
  12. count_obj (inContours, Number)
  13. *dev_display(Image)
  14. dev_set_color('green')
  15. dev_display(inContours)
  16. *calculate the distance from the pionts in the inner contour to the outer contour
  17. get_contour_xld (inContours, Row, Col)
  18. distance_pc (outContours, Row, Col, DistanceMin, DistanceMax)
  19. tuple_max (DistanceMin, maxDistance)
  20. tuple_min (DistanceMin, minDistance)
  21. disp_message (3600,'Max '+ minDistance, 'window', 20, 20, 'black', 'true')
  22. disp_message (3600,'Min '+ maxDistance, 'window', 40, 20, 'black', 'true')
复制代码
 楼主| sc_hym 发表于 2018-7-27 09:52:04 | 显示全部楼层
根据大家提供的思路优化升级的程序,其实里面很多算子,自己还不知道具体解释,只知道效果
洞庭渔人 发表于 2018-12-19 15:01:25 | 显示全部楼层
亲 有原图吗 能不能发上来学习学习 谢谢
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表