开启左侧

划痕检测,求帮我

  [复制链接]
1959616972 发表于 2017-11-28 15:06:20 | 显示全部楼层 |阅读模式
帮我解决这个划痕检测的案例,谢谢,划痕最后需要标记出来
1.bmp
其他图像下载:
链接:https://pan.baidu.com/s/1qYzEmew 密码:c49r
Criss 发表于 2017-11-29 16:02:00 | 显示全部楼层
  1. list_files ('C:/Users/Admin/Desktop/51halcon', ['files','follow_links','recursive'], ImageFiles)
  2. tuple_regexp_select (ImageFiles, ['\\.(bmp),'ignore_case'], ImageFiles)
  3. for Index := 1 to |ImageFiles| by 1
  4.     read_image (Image, ImageFiles[Index-1])
  5.    
  6.     threshold (Image, Region, 150, 255)
  7.     closing_circle (Region, RegionClosing, 3.5)
  8.     reduce_domain (Image, RegionClosing, ImageReduced)
  9.     median_image (ImageReduced, ImageMedian, 'circle', 3.5, 'mirrored')
  10.     dyn_threshold (ImageReduced, ImageMedian, RegionDynThresh, 24, 'dark')
  11.     dilation_rectangle1(RegionDynThresh, RegionDilation, 3, 2)
  12.     connection (RegionDilation, ConnectedRegions)
  13.     select_shape (ConnectedRegions, SelectedRegions, 'max_diameter', 'and', 40, 200)
  14.     dev_display (Image)
  15.     dev_display (SelectedRegions)
  16.     stop()
  17.     dump_window (3600, 'jpeg', 'C:/Users/Admin/Desktop/51halcon/'+Index+'_1.jpg')
  18.    
  19. endfor
复制代码
初步效果如下:
TIM截图20171129160339.png
zazaniao 发表于 2017-11-30 00:09:51 | 显示全部楼层
  1. * Image Acquisition 01: Code generated by Image Acquisition 01
  2. list_files ('C:/Users/zazaniao/Desktop/51halcon划痕图像', ['files','follow_links'], ImageFiles)
  3. tuple_regexp_select (ImageFiles, ['\\.(tif|tiff|gif|bmp|jpg|jpeg|jp2|png|pcx|pgm|ppm|pbm|xwd|ima|hobj)
  4. ,'ignore_case'], ImageFiles)
  5. for Index := 0 to |ImageFiles| - 1 by 1
  6.     read_image (Image, ImageFiles[Index])
  7.     * Image Acquisition 01: Do something
  8.     *分割,得到圆环区域,用作检测ROI
  9.     threshold (Image, Regions, 145, 255)
  10.    
  11.     connection (Regions, ConnectedRegions)
  12.     select_shape_std (ConnectedRegions, SelectedRegions, 'max_area', 70)
  13.     closing_circle (SelectedRegions, RegionClosing, 3.5)
  14.     fill_up_shape (RegionClosing, ROI, 'area', 1, 100)
  15.    
  16.     *裂缝分割
  17.     median_image (Image, ImageMedian, 'circle', 5, 'mirrored')
  18.     dyn_threshold (Image, ImageMedian, RegionDynThresh, 14, 'dark')
  19.    
  20.     connection (RegionDynThresh, ConnectedRegions1)
  21.     intersection (ConnectedRegions1, ROI, RegionIntersection)
  22.      
  23.     connection (RegionIntersection, ConnectedRegions2)
  24.    
  25.     select_shape (ConnectedRegions2, SelectedRegions1, 'area', 'and', 20, 99999)
  26.     union1 (SelectedRegions1, RegionUnion)
  27.     connection (RegionUnion, ConnectedRegions3)
  28.    
  29.     dev_display (Image)
  30.     select_shape (ConnectedRegions3, SelectedRegions2, 'rect2_len1', 'and', 15, 99999)
  31.    
  32.     *对区域进行特征筛选:裂缝的方向一般指向或者背离圆心
  33.     count_obj (SelectedRegions2, Number)
  34.     gen_empty_obj (Obj)
  35.     area_center (ROI, Area, Row, Column)
  36.     AngleOffset:=rad(30)
  37.     for i:=1 to Number by 1
  38.         select_obj (SelectedRegions2, ObjectSelected, i)
  39.         smallest_rectangle2 (ObjectSelected, Row2, Column2, Phi, Length1, Length2)
  40.         area_center (ObjectSelected, Area1, Row1, Column1)
  41.         angle_lx (Row, Column, Row1, Column1, Angle1)
  42.         angle_lx (Row1, Column1, Row, Column, Angle2)
  43.         if(abs(Phi-Angle1)<AngleOffset or abs(Phi-Angle2)<AngleOffset)
  44.             concat_obj (Obj, ObjectSelected, Obj)
  45.         endif
  46.     endfor
  47.    
  48.     *对裂缝合并
  49.     union1 (Obj, RegionUnion1)
  50.     closing_circle (RegionUnion1, RegionClosing2, 273.5)
  51.     dev_display (Image)
  52.     dev_display (RegionClosing2)
  53.     stop ()
  54. endfor
复制代码
dongfei799 发表于 2017-12-23 22:51:55 | 显示全部楼层
看的我目瞪口呆,佩服佩服大佬
xieleim 发表于 2018-1-3 10:13:28 | 显示全部楼层
bzsoft 发表于 2017-11-28 19:36
什么样的划痕,可以找我处理!

你好,有没有做过噪声很高的图片上的划痕识别啊?交流交流经验吧
shine夕鱼咔咔 发表于 2018-1-4 14:55:34 | 显示全部楼层
看看跟我想的有什么不一样:loveliness:
haley00421 发表于 2018-2-21 08:40:51 | 显示全部楼层
這麼細小的劃痕也看的到,來看看其他人如何解決的。
ckycd 发表于 2018-3-19 15:03:00 | 显示全部楼层
最近也碰到类似的案子,刚好学习下
honghuli 发表于 2018-5-4 11:49:50 | 显示全部楼层

这个案例很不错,可以下载下来学一下。
williamliao 发表于 2018-7-2 18:29:14 | 显示全部楼层
不明觉厉!新人努力学习中
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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