溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

Halcon算子的示例分析

發(fā)布時(shí)間:2022-01-10 09:07:53 來(lái)源:億速云 閱讀:136 作者:柒染 欄目:編程語(yǔ)言

本篇文章為大家展示了Halcon算子的示例分析,內(nèi)容簡(jiǎn)明扼要并且容易理解,絕對(duì)能使你眼前一亮,通過(guò)這篇文章的詳細(xì)介紹希望你能有所收獲。

read_image (Image,'fabrik')

*畫矩形

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

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

*縮減圖像定義域

reduce_domain (Image, Rectangle, ImageReduced)

*閾值分割出感興趣的部分

threshold (ImageReduced, Region, 0, 65)

*將不相互連接的區(qū)域分開(kāi)為單獨(dú)區(qū)域

connection (Region, ConnectedRegions)

*根據(jù)區(qū)域面積篩選出指定區(qū)域

select_shape (ConnectedRegions, SelectedRegions, 'area', 'and', 2500, 5150)

*************************測(cè)量算子*******************************

*畫仿射矩形

draw_rectangle2 (3600, Row5, Column4, Phi1, Length2, Length3)

gen_rectangle2 (Rectangle1, Row5, Column4, Phi1, Length2, Length3)

*獲取測(cè)量句柄

gen_measure_rectangle2 (Row5, Column4, Phi1, Length2, Length3, 512, 512, 'nearest_neighbor', MeasureHandle)

*句柄,平滑參數(shù),灰度差,極性,選擇邊緣點(diǎn),邊緣中心y,x坐標(biāo),幅度,距離

measure_pos (Image, MeasureHandle, 6.1, 65, 'all', 'all', RowEdge, ColumnEdge, Amplitude, Distance)

gen_cross_contour_xld (Cross, RowEdge, ColumnEdge, 6, Phi1)

close_measure (MeasureHandle)

*************************圖像--區(qū)域--輪廓************************

*區(qū)域轉(zhuǎn)輪廓

gen_contour_region_xld (SelectedRegions, Contours, 'border')

*輪廓點(diǎn)坐標(biāo)

get_contour_xld (Contours, Row, Col)

gen_cross_contour_xld (Cross1, Row, Col, 6, Phi1)

*輪廓擬合圓

fit_circle_contour_xld (Contours, 'algebraic', -1, 0, 0, 3, 2, Row3, Column, Radius, StartPhi, EndPhi, PointOrder)

gen_circle_contour_xld (ContCircle, Row3, Column, Radius, 0, 6.28318, 'positive', 1)

*輪廓擬合橢圓或橢圓弧

fit_ellipse_contour_xld (Contours, 'fitzgibbon', -1, 0, 0, 200, 3, 2, Row4, Column3, Phi, Radius1, Radius2, StartPhi1, EndPhi1, PointOrder1)

gen_ellipse_contour_xld (ContEllipse, Row4, Column3, Phi, Radius1, Radius2, 0, 6.28318, 'positive', 1.5)

**************************圖像--輪廓**************************

*提取亞像素精度邊緣輪廓

edges_sub_pix (ImageReduced, Edges, 'canny', 1, 20, 40)

*篩選出指定輪廓

select_contours_xld (Edges, SelectedContours, 'contour_length', 0, 50, -0.5, 0.5)

dev_set_color ('green')

*擬合直線

fit_line_contour_xld (SelectedContours, 'tukey', -1, 0, 5, 2, RowBegin, ColBegin, RowEnd, ColEnd, Nr, Nc, Dist)

disp_line (3600, RowBegin, ColBegin, RowEnd, ColEnd)

****************************擬合矩形****************************

*生成感興趣的區(qū)域

read_image (Image, 'fabrik')

draw_rectangle1 (3600, Row11, Column11, Row2, Column2)

gen_rectangle1 (Rectangle, Row11, Column11, Row2, Column2)

reduce_domain (Image, Rectangle, ImageReduced)

*提取輪廓,擬合矩形

edges_sub_pix (ImageReduced, Edges, 'canny', 1, 20, 40)

select_contours_xld (Edges, SelectedContours, 'contour_length', 80, 800, -0.5, 0.5)

fit_rectangle2_contour_xld (SelectedContours, 'regression', -1, 0, 0, 3, 2, Row1, Column1, Phi1, Length21, Length31, PointOrder)

gen_rectangle2 (Rectangle1, Row1, Column1, Phi1, Length21, Length31)

***********************************計(jì)算垂足、夾角***************************************

read_image (Image, 'fabrik')

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

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

reduce_domain (Image, Rectangle, ImageReduced)

edges_sub_pix (ImageReduced, Edges, 'canny', 1, 20, 40)

sort_contours_xld (Edges, SortedContours, 'upper_left', 'true', 'row')

*取輪廓上的點(diǎn)

select_obj (SortedContours, ObjectSelected, 2)

get_contour_xld (ObjectSelected, Row, Col)

*取輪廓上的線

select_obj (SortedContours, ObjectSelected1, 10)

fit_line_contour_xld (ObjectSelected1, 'tukey', -1, 0, 5, 2, RowBegin, ColBegin, RowEnd, ColEnd, Nr, Nc, Dist)

*計(jì)算點(diǎn)到線的垂足

projection_pl (Row[0],Col[0],RowBegin, ColBegin, RowEnd, ColEnd ,RowProj, ColProj)

*顯示點(diǎn)、直線、垂足、垂線

gen_cross_contour_xld (Cross,Row[0],Col[0], 6, 0.785398)

disp_line (3600, RowBegin, ColBegin, RowEnd, ColEnd)

gen_cross_contour_xld (Cross1,RowProj, ColProj, 6, 0.785398)

disp_line (3600, Row[0],Col[0],RowProj, ColProj)

*計(jì)算兩條直線的夾角

angle_ll ( RowBegin, ColBegin, RowEnd, ColEnd, Row[0],Col[0],RowProj, ColProj, Angle)

*弧度轉(zhuǎn)角度deg,角度轉(zhuǎn)弧度rad

Ang:=deg(Angle)

*計(jì)算直線和水平軸x的夾角

angle_lx (RowBegin, ColBegin, RowEnd, ColEnd, Angle1)

Ang1:=deg(Angle1)

angle_lx (Row[0],Col[0],RowProj, ColProj, Angle2)

Ang2:=deg(Angle2)

上述內(nèi)容就是Halcon算子的示例分析,你們學(xué)到知識(shí)或技能了嗎?如果還想學(xué)到更多技能或者豐富自己的知識(shí)儲(chǔ)備,歡迎關(guān)注億速云行業(yè)資訊頻道。

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI