日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

halcon python缺陷检测_Halcon学习笔记之缺陷检测(一)

發布時間:2023/12/3 61 豆豆
生活随笔 收集整理的這篇文章主要介紹了 halcon python缺陷检测_Halcon学习笔记之缺陷检测(一) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

*surface_scratch.hdev:extraction of surface scratches via local thresholding and morphological post-processing*

dev_close_window()

dev_update_window(‘off’)

*****

*step: acquire image //獲取圖片

*****

read_image(Image,’surface_scratch’) //讀入圖片名為’surface_scratch’的圖片

get_image_size(Image,Width,Height) //獲取圖像的尺寸:寬、高

//在坐標為(0,0)處打開一個圖像窗口。其寬和高分別是Width和Width,窗口的句柄為WindowID

dev_open_window_fit_image(Image,0,0,Width,Width,WindowID)

//設置窗口中顯示的字體顏色,大小,加粗,傾斜

set_display_font(WindowID,12,’Courier’,’true’,’false’)

dev_set_draw(‘margin’) //設置區域填充類型:’margin’ or ‘fill’

dev_set_line_width(4) //設置線寬,這個在填充類型為fill時效果不明顯

dev_display(Image) //顯示圖片

disp_continue_message(WindowID,’black’,’true’) //顯示繼續消息,等待用戶按F5繼續執行

stop()

*****

*step: segment image

*****

*-> using a local threshold

mean_image(Image,ImageMean,7,7) //用7×7的窗口對圖像進行均值濾波

dyn_threshold(Image,ImageMean,DarkPixels,5,’dark’) //利用本地閾值進行圖像分割

*->extract connected components

connection(DarkPixels,ConnectedRegions) //對區域進行連通運算

dev_set_colored(12) //設置區域顯示的顏色數目

dev_display(ConnectedRegions) //顯示圖像

disp_continue_message(WindowID,’black’,’true’)//顯示繼續提示,提示繼續

stop()

*****

*step: process regions

*****

*->select large regions

select_shape(ConnectedRegions,SelsectedRegions,’area’,’and’,10,1000) //區域選擇,用面積的形態特征選擇面積在10到10000間的區域

dev_display(Image) //顯示原圖

dev_display(SelectedRegions) //顯示選擇的區域

disp_continue_message(WindowID,’black’,’true’) //顯示繼續提示,提示繼續

stop()

*->visualize fractioned scratch

open_zoom_window(0,round(Width/2),2,303,137,496,3,WindowHandleZoom)

dev_set_color(‘blue’) //設置顯示顏色(藍色),功能與dev_set_colored類似

dev_display(Image) //顯示原圖

dev_display(SelectedRegions) //顯示選中的區域圖

disp_continue_message(WindowID,’black’,’true’) //顯示繼續提示信息

stop()

*->merge fractioned scratches via morphology

union1(SelectedRegions,RegionUnion) //合并所有區域

dilation_circle(RegionUnion,RegionDilation,3.5) //用半徑3.5 的掩膜進行膨脹

dev_display(Image) //顯示原圖

dev_display(RegionDilation) //顯示膨脹后的區域圖

disp_continue_message(WindowID,’black’,’true’)//顯示繼續提示信息

stop()

skeleton(RegionDialtion,Skeleton) //計算區域的中軸,見例程:surface_scratch.hdev

connection(Skeleton,Errors) //連通操作,以便后面進行區域選擇

dev_set_colored(12) //設置顏色

dev_display(Image) //顯示原圖

dev_display(Errors) //顯示所有抓痕

disp_continue_message(WindowID,’black’,’true’) //顯示繼續提示信息

stop()

*->distinguish small and large scratches

close_zoom_window(WindowHandleZoom,Width,Height) //關閉縮放窗口

select_shape(Errors,Scratches,’area’,’and’,50,10000)//選擇區域面積在50到10000的作為劃痕

select_shape(Errors,Dots,’area’,’and’,1,50) //選擇區域面積在1到50 的作為點

dev_display(Image) //顯示原圖

dev_set_color(‘red’) //設置區域顯示顏色為紅色

dev_display(Scratches) //顯示條狀劃痕(顯示為紅色)

dev_set_color(‘blue’) //設置區域顯示顏色藍色

dev_display(Dots) //顯示點狀劃痕(顯示為藍色)

總結

以上是生活随笔為你收集整理的halcon python缺陷检测_Halcon学习笔记之缺陷检测(一)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。