Hello Mat

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

光度立体视觉缺陷检测

[复制链接]

1323

主题

1551

帖子

0

金钱

管理员

Rank: 9Rank: 9Rank: 9

积分
22647
发表于 2018-6-13 22:46:36 | 显示全部楼层 |阅读模式
光度立体视觉缺陷检测:
halcon12 + win32
例如:四个角度,各拍摄一张图,供4张图,然后进行光度立体视觉缺陷检测,

  1. read_image (Images, 'photometric_stereo/blister_back_0' + [1:4])
  2. for I := 1 to 4 by 1
  3.     Message := 'Acquire image ' + I + ' of 4'
  4.     select_obj (Images, ObjectSelected, I)
  5.     dev_display (ObjectSelected)
  6.     disp_message (WindowHandle, Message, 'window', 12, 12, 'black', 'true')
  7.     wait_seconds (0.5)
  8. endfor
  9. *
  10. * Apply photometric stereo to determine the albedo and the surface gradient.
  11. Tilts := [6.1,95.0,-176.1,-86.8]   
  12. Slants := [41.4,42.6,41.7,40.9]
  13. ResultType := ['gradient','albedo']
  14. photometric_stereo (Images, HeightField, Gradient, Albedo, Slants, Tilts, ResultType, 'poisson', [], [])
  15. *
  16. * Display the albedo image
  17. dev_display (Albedo)
  18. stop ()
  19. *
  20. * Calculate the gaussian curvature of the surface
  21. * using the gradient field as input for the operator
  22. * derivate_vector_field.
  23. * Defects are usually easy to detect in the curvature image.
  24. derivate_vector_field (Gradient, GaussCurvature, 1, 'gauss_curvature')
  25. *
  26. * Detect defects
  27. *
  28. * Segment the tablet areas in the curvature image
  29. regiongrowing (GaussCurvature, Regions, 1, 1, 0.001, 250)
  30. select_shape (Regions, TabletRegions, ['width','height'], 'and', [150,150], [200,200])
  31. shape_trans (TabletRegions, TabletRegions, 'convex')
  32. union1 (TabletRegions, TabletRegions)
  33. erosion_circle (TabletRegions, TabletRegions, 3.5)
  34. * Search for defects inside the tablet areas
  35. reduce_domain (GaussCurvature, TabletRegions, ImageReduced)
  36. abs_image (ImageReduced, ImageAbs)
  37. threshold (ImageAbs, Region, 0.03, 255)
  38. closing_circle (Region, RegionClosing, 10.5)
  39. connection (RegionClosing, ConnectedRegions)
  40. select_shape (ConnectedRegions, Defects, 'area', 'and', 10, 99999)
  41. area_center (Defects, Area, Row, Column)
  42. gen_circle (Circle, Row, Column, gen_tuple_const(|Row|,20.5))
  43. * Display the defects in curvature image
  44. dev_set_draw ('margin')
  45. dev_display (Albedo)
  46. dev_display (Circle)
  47. disp_message (WindowHandle, 'Defect in albedo image', 'window', 12, 12, 'black', 'true')
复制代码

参考:
【1】检测效果:https://tieba.baidu.com/p/1712630404?red_tag=2883704820
【2】论文:https://wenku.baidu.com/view/564 ... 25.html?from=search





本帖子中包含更多资源

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

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

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-11-22 23:50 , Processed in 0.205595 second(s), 22 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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