Hello Mat

 找回密码
 立即注册
查看: 6528|回复: 0

二值化模板图像匹配

[复制链接]

1294

主题

1520

帖子

110

金钱

管理员

Rank: 9Rank: 9Rank: 9

积分
22633
发表于 2019-1-13 17:33:03 | 显示全部楼层 |阅读模式
二值化模板图像匹配
  1. dev_update_off()
  2. dev_set_draw('margin')
  3. read_image (Image, 'E:/视频讲解/图库/4Cam0_00.PNG')
  4. get_image_size(Image, Width, Height)
  5. * 加载模型
  6. read_region(ModelEdges, 'regionMatchingModel.hobj')

  7. * 提取纹理特征
  8. * inspect_shape_model(Image, ModelImages, ModelRegions, 1, 10)
  9. texture_laws(Image, ImageEL, 'el', 5, 5)
  10. threshold(ImageEL,Region,5,255)
  11. texture_laws (Image, ImageLE, 'le', 5, 5)
  12. threshold(ImageLE,Region1,5,255)
  13. union2(Region, Region1, RegionUnion)
  14. * blob分析
  15. connection(RegionUnion, ConnectedRegions)
  16. select_shape(ConnectedRegions, SelectedRegions, 'area', 'and', 150, 9999999)
  17. union1(SelectedRegions, RegionUnion1)

  18. * 二值化配准
  19. zbest_Area:=0
  20. zbest_Rx:=0
  21. zbest_Cx:=0
  22. zbest_Cita:=0
  23. gen_empty_obj(zbest_Region)
  24. region_features(RegionUnion1, 'area', Value)
  25. if(Value>0)
  26.     smallest_rectangle1(RegionUnion1, Row1, Column1, Row2, Column2)
  27.     smallest_rectangle1(ModelEdges, Row11, Column11, Row21, Column21)
  28.     move_region(ModelEdges, InitPos, Row1-Row11, Column1-Column11)
  29.    
  30.     for cita:= -1 to 1 by 0.5
  31.         vector_angle_to_rigid(Height/2,Width/2,0,Height/2,Width/2,rad(cita),HomMat2D)
  32.         affine_trans_region(RegionUnion1, RegionAffineTrans, HomMat2D, 'nearest_neighbor')
  33.         for Rx:=0 to 30 by 2
  34.             for Cx:=0 to 30 by 2
  35.                 move_region(InitPos, RegionMoved, Rx, Cx)
  36.                 intersection(RegionMoved, RegionAffineTrans, RegionIntersection)
  37.                 region_features(RegionIntersection, 'area', Value1)
  38.                 if(Value1>zbest_Area)
  39.                     zbest_Area:=Value1
  40.                     zbest_Rx:=Rx
  41.                     zbest_Cx:=Cx
  42.                     zbest_Cita:=cita
  43.                     union1(RegionMoved, zbest_Region)
  44.                 endif
  45.             endfor
  46.         endfor
  47.     endfor
  48.    
  49.    
  50. endif
复制代码



算法QQ  3283892722
群智能算法链接http://halcom.cn/forum.php?mod=forumdisplay&fid=73
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Python|Opencv|MATLAB|Halcom.cn ( 蜀ICP备16027072号 )

GMT+8, 2024-4-20 03:15 , Processed in 0.270993 second(s), 30 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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