HALCON示例程序find_pads.hdev通过fit_rectangle2_contour_xld绘制精准轮廓
生活随笔
收集整理的這篇文章主要介紹了
HALCON示例程序find_pads.hdev通过fit_rectangle2_contour_xld绘制精准轮廓
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
HALCON示例程序find_pads.hdev通過(guò)fit_rectangle2_contour_xld繪制精準(zhǔn)輪廓
示例程序源碼(加注釋)
- 關(guān)于顯示類(lèi)函數(shù)解釋
dev_update_pc (‘off’)
dev_update_window (‘off’)
dev_update_var (‘off’)
read_image (Image, ‘die_pads’)
dev_close_window ()
get_image_size (Image, Width, Height)
dev_open_window (0, 0, Width * 2, Height * 2, ‘black’, WindowHandle)
dev_set_part (0, 0, Height - 1, Width - 1) - fast_threshold - 使用全局閾值快速閾值處理圖像。
- fast_threshold(圖片:區(qū)域:最小灰度值,最大灰度值,最小閾值分割值:)
fast_threshold (Image, Region, 180, 255, 20) - 分割連通域
connection (Region, ConnectedRegions) - 使面積與長(zhǎng)短軸比值篩選區(qū)域
select_shape (ConnectedRegions, SelectedRegions, [‘a(chǎn)rea’,‘a(chǎn)nisometry’], ‘a(chǎn)nd’, [200,1], [1200,2])
fill_up (SelectedRegions, RegionFillUp) - 求取最大邊界
shape_trans (RegionFillUp, RegionTrans, ‘convex’) - boundary - 將區(qū)域縮小到其邊界。
- boundary(區(qū)域:區(qū)域邊界:邊界種類(lèi) ?
boundary (RegionTrans, RegionBorder, ‘inner’) - 使用圓形元素對(duì)區(qū)域進(jìn)行膨脹
dilation_circle (RegionBorder, RegionDilation, 2.5)
union1 (RegionDilation, RegionUnion) - 減少圖片定義域
reduce_domain (Image, RegionUnion, ImageReduced) - 求取邊界
edges_sub_pix (ImageReduced, Edges, ‘sobel_fast’, 0.5, 20, 40) - 使用長(zhǎng)度篩選邊界
select_shape_xld (Edges, SelectedContours, ‘contlength’, ‘a(chǎn)nd’, 10, 200) - union_adjacent_contours_xld - 計(jì)算端點(diǎn)靠近的輪廓的并集。
- union_adjacent_contours_xld(邊緣:合并邊緣:最大絕對(duì)距離,最大長(zhǎng)度相對(duì)距離,模式:)
union_adjacent_contours_xld (SelectedContours, UnionContours, 2, 1, ‘a(chǎn)ttr_keep’) - fit_rectangle2_contour_xld - 擬合XLD輪廓為矩形。
fit_rectangle2_contour_xld (UnionContours, ‘tukey’, -1, 0, 0, 3, 2, Row, Column, Phi, Length1, Length2, PointOrder) - gen_rectangle2_contour_xld - 創(chuàng)建矩形形狀的XLD輪廓。
gen_rectangle2_contour_xld (Rectangle, Row, Column, Phi, Length1, Length2)
dev_display (Image)
dev_set_colored (12)
dev_display (Rectangle)
處理思路
這個(gè)例子是主要講解了如何利用邊緣提取與矩形擬合進(jìn)行精確定位。使用了fast_threshold進(jìn)行閾值分割,boundary并dilation_circle得到邊界圖像,使用edges_sub_pix進(jìn)行邊緣提取,select_shape_xld篩選邊界,fit_rectangle2_contour_xld邊界矩形擬合,gen_rectangle2_contour_xld繪制邊緣輪廓。
后記
大家有什么問(wèn)題可以向我提問(wèn)哈,我看到了第一時(shí)間回復(fù),希望在學(xué)習(xí)的路上多多結(jié)交良師益友。
總結(jié)
以上是生活随笔為你收集整理的HALCON示例程序find_pads.hdev通过fit_rectangle2_contour_xld绘制精准轮廓的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 20.链式队列
- 下一篇: Java疯狂讲义读书笔记第一章