全国服务热线:

15861139266

利用反射率图像和梯度图像检测皮革表面缺陷,苏州PLC培训,苏州-苏州机器视觉培训,苏州工业机器人培训,苏州电工培训
发布时间:2023-04-10 09:45:23 点击次数:336

利用反射率图像和梯度图像检测皮革表面缺陷

dev_close_window ()

dev_open_window (0, 0, 640, 480, 'black', WindowHandle)

set_display_font (WindowHandle, 14, 'mono', 'true', 'false')

* Part 1利用反射率图像检测皮革表面缺陷

read_image (Images, 'photometric_stereo/leather_1_0' + [1:4])

write_image (Images, 'tiff', 0, 'D:/1.tiff')

** 展示不同方向光源成像图像

for I := 1 to 4 by 1

    Message := 'Sample 1: Acquire image ' + I + ' of 4'

    select_obj (Images, ObjectSelected, I)

    dev_display (ObjectSelected)

    disp_message (WindowHandle, Message, 'window', 12, 12, 'black', 'true')

    wait_seconds (0.5)

endfor

* 应用光度立体法生成的反射率图进行缺陷检测

Tilts := [6.1,95.0,-176.1,-86.8]

Slants := [41.4,42.6,41.7,40.9]

ResultType := ['gradient','albedo']

photometric_stereo (Images, HeightField, Gradient, Albedo, Slants, Tilts, ResultType, 'poisson', [], [])

* 显示反射率图

dev_display (Albedo)

*检测缺陷

var_threshold (Albedo, Region, 15, 15, 0.4, 0.4, 'light')

connection (Region, ConnectedRegions)

select_shape (ConnectedRegions, SelectedRegions, 'area', 'and', 10, 99999)

union1 (SelectedRegions, RegionUnion)

closing_circle (RegionUnion, RegionClosing, 3.5)

connection (RegionClosing, Defects)

area_center (Defects, Area, Row, Column)

gen_circle (Circle, Row, Column, gen_tuple_const(|Row|,sqrt(Area) + 30))

*显示缺陷

dev_display (Albedo)

dev_set_color ('red')

dev_set_draw ('margin')

dev_set_line_width (4)

dev_display (Circle)


* Part 2 利用梯度图像检测皮革表面缺陷

read_image (Images, 'photometric_stereo/leather_2_0' + [1:4])

for I := 1 to 4 by 1

    Message := 'Sample 2: Acquire image ' + I + ' of 4'

    select_obj (Images, ObjectSelected, I)

    dev_display (ObjectSelected)

    disp_message (WindowHandle, Message, 'window', 12, 12, 'black', 'true')

    wait_seconds (0.5)

endfor


* 应用光度立体法生成的反射率图

photometric_stereo (Images, HeightField, Gradient, Albedo, Slants, Tilts, ResultType, 'poisson', [], [])

*对反射率图二值化(发现无法二值化)

threshold (Albedo, Region1, 128, 255)

* 显示反射率图

dev_display (Albedo)

derivate_vector_field (Gradient, Curl, 1, 'curl')

derivate_gauss (Curl, CurlGradient, 1, 'gradient')

* 显示梯度图

dev_display (CurlGradient)

Message := 'Changes in the gradient curl'

disp_message (WindowHandle, Message, 'window', 12, 12, 'black', 'true')

disp_continue_message (WindowHandle, 'black', 'true')

stop ()


* 用梯度图寻找缺陷

threshold (CurlGradient, Region, 0, 0.01)

rank_region (Region, RegionCount, 10, 10, 30)//归类区域

connection (RegionCount, ConnectedRegions)

select_shape (ConnectedRegions, SelectedRegions, 'area', 'and', 2000, 99999)

union1 (SelectedRegions, RegionUnion)

rank_region (RegionUnion, RegionCount1, 25, 25, 170)

connection (RegionCount1, NoTextured)


* 显示

dev_display (Albedo)

dev_set_draw ('margin')

dev_set_color ('red')

dev_set_line_width (3)

dev_display (NoTextured)

disp_message (WindowHandle, 'Non-textured areas on leather', 'window', 12, 12, 'black', 'true')

stop ()



蓝色企业培训课程表图文风横版海报__2023-04-07+10_17_46.png


立即咨询
  • 品质服务

    服务贴心周到

  • 快速响应

    全天24小时随时沟通

  • 专业服务

    授权率高,保密性强

  • 完善售后服务

    快速响应需求,及时性服务

直播课程
软件开发基础课程
上位机软件开发课
机器视觉软件开发课
专题课
联系方式
电话:15861139266
邮箱:75607082@qq.com
地址:苏州吴中区木渎镇尧峰路69号
关注我们

版权所有:江苏和讯自动化设备有限公司所有 备案号:苏ICP备2022010314号-1

技术支持: 易动力网络