日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

halcon轮廓擦除_halcon第十二讲,毛刺去除

發布時間:2023/12/10 编程问答 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 halcon轮廓擦除_halcon第十二讲,毛刺去除 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

在視覺測量中我們很會被毛刺問題困擾,產生干擾的因素很多,有打光問題和產品本生帶毛刺,接下來給兄弟們帶來兩種去毛刺的方法。

第一種

read_image (Image1323153Ba0b96cf52f88f1, '1')

rgb1_to_gray (Image1323153Ba0b96cf52f88f1, GrayImage)

laplace_of_gauss (GrayImage, ImageLaplace, 0.5)

threshold_sub_pix (ImageLaplace, Border, 1)

select_obj (Border, ObjectSelected, 1)

smooth_contours_xld (ObjectSelected, SmoothedContours, 15)

get_contour_xld (SmoothedContours, Row1, Col1)

get_contour_xld (ObjectSelected, Row2, Col2)

*錯誤距離閾值

errdist:=0.5

distRow:= sqrt((Row1-Row2)*(Row1-Row2)+(Col1-Col2)*(Col1-Col2))

a:=find(distRow[>]errdist,1)

e:=Row2[a]

g:=Col2[a]

dev_display (Image1323153Ba0b96cf52f88f1)

gen_cross_contour_xld (Cross, e, g, 10, 0.785398)

運行結果

image.png

image.png

第二種

read_image(Image,'1')

get_image_size(Image,Width,Height)

dev_close_window()

dev_open_window(0,0,Width/3,Height/3,'black',WindowHandle)

dev_set_draw ('margin')

dev_set_color ('cyan')

dev_set_line_width(2)

rgb1_to_gray(Image,GrayImage)

dev_display(GrayImage)

*鼠標畫你要找的roi區域

draw_rectangle1(WindowHandle,Row1,Column1,Row2,Column2)

*顯示roi區域

gen_rectangle1(roi1, Row1, Column1, Row2, Column2)

*減少其他區域,顯示你畫的roi區域

reduce_domain(GrayImage,roi1,ImageReduced)

threshold (ImageReduced, Regions, 200, 255)

opening_circle(Regions,ReigionsoOpening,3.5)

closing_circle(ReigionsoOpening,ReigionsoClosibng,3.5)

*fill_up(ReigionsoClosibng,ReigionFillup)

*boundary(ReigionFillup,ReigionBoundary,'outer')

*ilation_circle(ReigionBoundary,ReigionDilation,1)

reduce_domain(Image,ReigionsoClosibng,ImageReduced1)

gen_contour_region_xld(ImageReduced1,Contours, 'border')

*edges_sub_pix(ImageReduced1,Edges,'canny',1,10,60)

dev_display(ImageReduced1)

dev_display(Contours)

stop()

*根據長度裁剪

select_shape_xld(Contours, AreaEdges1, 'contlength', 'and', 50, 9999)

*根據xld找尋區域輪廓的所有x,y坐標

count_obj (AreaEdges1, Number)

*遍歷亞像素坐標點

y2:=[]

x2:=[]

for x := 0 to Number-1 by 1

select_obj (AreaEdges1, ObjectSelected, x+1)

get_contour_xld (ObjectSelected, Row, Column)

y2 := [Row, y2]

x2 := [Column, x2]

endfor

*找最大最小x,y

min_x:=min(x2)

max_x:=max(x2)

min_y:=min(y2)

max_y:=max(y2)

*畫直線

disp_line (WindowHandle, min_y,min_x , min_y, max_x)

disp_line (WindowHandle, min_y,min_x ,max_y , min_x)

disp_line (WindowHandle, max_y , min_x, max_y, max_x)

disp_line (WindowHandle, max_y, max_x, min_y, max_x)

運行結果

image.png

image.png

有什么需求,可以評論一起探討思路

創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎

總結

以上是生活随笔為你收集整理的halcon轮廓擦除_halcon第十二讲,毛刺去除的全部內容,希望文章能夠幫你解決所遇到的問題。

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