设为首页收藏本站
授权版本:2024_07
开启左侧

提取标签区域

[复制链接]
NYang 发表于 2022-4-12 15:30:44 | 显示全部楼层 |阅读模式
如图,如何把5张标签的区域提取出来?
1.jpg
奖励计划已经开启,本站鼓励作者发布最擅长的技术内容和资源,流量变现就在现在,[点我]加入吧~~~Go
az_noodle 发表于 2022-4-12 21:10:57 | 显示全部楼层
  1. read_image (Image5, 'D:/BMP/硬盘提取5个标签.jpg')
  2. rgb1_to_gray (Image5, GrayImage)
  3. get_image_size (GrayImage, Width, Height)
  4. dev_close_window ()
  5. dev_open_window (0, 0, Width/2, Height/2, 'black', WindowHandle)
  6. ***************找区域
  7. dev_display (GrayImage)
  8. mean_image (GrayImage, ImageMean, 80, 80)
  9. dyn_threshold (GrayImage, ImageMean, RegionDynThresh, 20, 'light')
  10. connection (RegionDynThresh, ConnectedRegions)
  11. fill_up (ConnectedRegions, RegionFillUp)
  12. opening_rectangle1 (RegionFillUp, RegionOpening, 300, 150)
  13. select_shape (RegionOpening, SelectedRegions, 'area', 'and', 150, 99999)
  14. dilation_circle (SelectedRegions, RegionDilation, 10)
  15. count_obj (RegionDilation, Number)
  16. sort_region (RegionDilation, SortedRegions, 'character', 'true', 'row')
  17. gen_empty_obj (EmptyObject)
  18. for Index := 1 to Number by 1
  19.     select_obj (SortedRegions, ObjectSelected, Index)
  20.     reduce_domain (GrayImage, ObjectSelected, ImageReduced)
  21.     crop_domain (ImageReduced, ImagePart)
  22.     scale_image (ImagePart, ImageScaled, 1.5, 0.5)
  23.     binary_threshold (ImagePart, Region, 'max_separability', 'light', UsedThreshold)
  24.     fill_up (Region, RegionFillUp1)
  25.     smallest_rectangle2 (RegionFillUp1, Row, Column, Phi, Length1, Length2)
  26.     area_center (RegionFillUp1, Area, Row1, Column1)
  27.     reduce_domain (ImageScaled, RegionFillUp1, ImageReduced1)
  28.     hom_mat2d_identity (HomMat2DIdentity)
  29.     hom_mat2d_rotate (HomMat2DIdentity, -Phi, Column1, Row1, HomMat2DRotate)
  30.     affine_trans_image (ImageReduced1, ImageAffineTrans, HomMat2DRotate, 'constant', 'false')
  31.     concat_obj (ImageAffineTrans, EmptyObject , EmptyObject)
  32. endfor
  33. ***************输出查看
  34. tile_images (EmptyObject, TiledImage, 1, 'horizontal')
  35. get_image_size (TiledImage, Width1, Height1)
  36. dev_open_window (0, 0, Width1, Height1, 'black', WindowHandle1)
  37. dev_display (TiledImage)
复制代码


新手,在学习中,仅供参考{:6_185:}
奖励计划已经开启,本站鼓励作者发布最擅长的技术内容和资源,流量变现就在现在,[点我]加入吧~~~Go
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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