edge边缘线轮廓合并转实体矩形

dev_update_off ()

* step: acquire image

read_image (Image, 'die_on_chip')
get_image_size (Image, Width, Height)
dev_close_window ()
dev_open_window (0, 0, Width * 2, Height * 2, 'light gray', WindowID)
dev_set_part (0, 0, Height - 1, Width - 1)
dev_set_line_width (3)
dev_set_color ('white')

dev_display (Image)
set_display_font (WindowID, 16, 'mono', 'true', 'false')

* step: extract contours for the die

* step: create ROI

dev_set_line_width (2)
dev_set_draw ('fill')
fast_threshold (Image, Region, 120, 255, 20)
opening_rectangle1 (Region, RegionOpening, 4, 4)
connection (RegionOpening, ConnectedRegions)
fill_up (ConnectedRegions, RegionFillUp)
select_shape (RegionFillUp, SelectedRegions, ['rectangularity','area'], 'and', [0.8,700], [1,99999])
smallest_rectangle2 (SelectedRegions, Row, Column, Phi, Length1, Length2)
gen_rectangle2 (Rectangle, Row, Column, Phi, Length1, Length2)
boundary (Rectangle, RegionBorder, 'inner_filled')
dilation_rectangle1 (RegionBorder, RegionDilation, 4, 4)
reduce_domain (Image, RegionDilation, ImageReduced)
dev_clear_window ()
dev_display (ImageReduced)
disp_continue_message (WindowID, 'black', 'true')
stop ()

* step: create contours

edges_sub_pix (ImageReduced, Edges, 'canny', 1.5, 30, 40)
segment_contours_xld (Edges, ContoursSplit, 'lines', 5, 2, 2)
select_contours_xld (ContoursSplit, SelectedContours1, 'contour_length', 10, 99999, -0.5, 0.5)
union_adjacent_contours_xld (SelectedContours1, UnionContours1, 30, 1, 'attr_keep')

* step: fit rectangle

fit_rectangle2_contour_xld (UnionContours1, 'tukey', -1, 0, 0, 3, 2, Row1, Column1, Phi1, Length11, Length12, PointOrder1)
gen_rectangle2_contour_xld (Rectangle1, Row1, Column1, Phi1, Length11, Length12)

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值