Halcon学习:坏点检测
生活随笔
收集整理的這篇文章主要介紹了
Halcon学习:坏点检测
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
此代碼作用于攝像頭模組實(shí)拍圖片檢測(cè)壞點(diǎn)。用到的算子是動(dòng)態(tài)閾值分割,實(shí)現(xiàn)邏輯是,實(shí)拍圖轉(zhuǎn)灰度圖,然后進(jìn)行動(dòng)態(tài)閾值分割獲得壞點(diǎn)。最后在原圖上框出壞點(diǎn)。
1 *此文件夾包含待測(cè)實(shí)拍圖
2 list_files ('E:/1(1)/1(1)', 'files', Files)
3 l:=|Files|
4 *設(shè)置畫(huà)框規(guī)格
5 dev_set_draw ('margin')
6 dev_set_line_width (1)
7 *循環(huán)每張圖進(jìn)行l(wèi)ocal_threshold獲取黑點(diǎn)即壞點(diǎn)
8 for i := 1 to l-1 by 1
9 read_image (Image, Files[i])
10 rgb1_to_gray (Image, GrayImage)
11 dev_display (GrayImage)
12 dev_display (Rectangle)
13 local_threshold (GrayImage, Region, 'adapted_std_deviation', 'dark', [], [])
14 *獲取壞點(diǎn)并計(jì)算數(shù)量
15 connection (Region, ConnectedRegions)
16 count_obj (ConnectedRegions, Number)
17 if (Number!=0)
18 *循環(huán)畫(huà)框
19 for j := 1 to Number by 1
20 select_obj (ConnectedRegions, ObjectSelected, j)
21 area_center (ObjectSelected, Area, Row, Column)
22 gen_rectangle2 (Rectangle, Row, Column, 0, 20, 20)
23
24 endfor
25 endif
26
27 endfor
效果圖如下:
總結(jié)
以上是生活随笔為你收集整理的Halcon学习:坏点检测的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 未开启“自动亮度调节”功能 iPhone
- 下一篇: 微信扫码登录实现