Hello Mat

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

划痕、刮痕缺陷检测

[复制链接]

1294

主题

1520

帖子

110

金钱

管理员

Rank: 9Rank: 9Rank: 9

积分
22633
发表于 2018-6-13 22:40:25 | 显示全部楼层 |阅读模式
划痕、刮痕缺陷检测:
halcon12 + win32
  1. dev_update_off ()
  2. read_image (Image, 'surface_scratch')
  3. invert_image (Image, ImageInverted)
  4. get_image_size (Image, Width, Height)
  5. *
  6. optimize_rft_speed (Width, Height, 'standard')
  7. * Enhance the scratches by filtering in the frequency domain
  8. gen_sin_bandpass (ImageBandpass, 0.4, 'none', 'rft', Width, Height)
  9. rft_generic (ImageInverted, ImageFFT, 'to_freq', 'none', 'complex', Width)
  10. convol_fft (ImageFFT, ImageBandpass, ImageConvol)
  11. rft_generic (ImageConvol, Lines, 'from_freq', 'n', 'byte', Width)
  12. *
  13. * Segment the scratches by using morphology
  14. threshold (Lines, Region, 5, 255)
  15. connection (Region, ConnectedRegions)
  16. select_shape (ConnectedRegions, SelectedRegions, 'area', 'and', 5, 5000)
  17. dilation_circle (SelectedRegions, RegionDilation, 5.5)
  18. union1 (RegionDilation, RegionUnion)
  19. reduce_domain (Image, RegionUnion, ImageReduced)
  20. * line_gauss线检测
  21. lines_gauss (ImageReduced, LinesXLD, 0.8, 3, 5, 'dark', 'false', 'bar-shaped', 'false')
  22. union_collinear_contours_xld (LinesXLD, UnionContours, 40, 3, 3, 0.2, 'attr_keep')
  23. select_shape_xld (UnionContours, SelectedXLD, 'contlength', 'and', 15, 1000)
  24. gen_region_contour_xld (SelectedXLD, RegionXLD, 'filled')
  25. union1 (RegionXLD, RegionUnion)
  26. dilation_circle (RegionUnion, RegionScratches, 10.5)
  27. *
  28. * Display the results
  29. dev_set_draw ('margin')
  30. dev_display (Image)
  31. dev_display (RegionScratches)
复制代码





本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

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

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-4-19 17:39 , Processed in 0.243213 second(s), 22 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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