本篇文章為大家展示了Halcon算子的示例分析,內(nèi)容簡明扼要并且容易理解,絕對能使你眼前一亮,通過這篇文章的詳細(xì)介紹希望你能有所收獲。
銅山網(wǎng)站建設(shè)公司創(chuàng)新互聯(lián),銅山網(wǎng)站設(shè)計(jì)制作,有大型網(wǎng)站制作公司豐富經(jīng)驗(yàn)。已為銅山上千余家提供企業(yè)網(wǎng)站建設(shè)服務(wù)。企業(yè)網(wǎng)站搭建\外貿(mào)網(wǎng)站建設(shè)要多少錢,請找那個(gè)售后服務(wù)好的銅山做網(wǎng)站的公司定做!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ū)域分開為單獨(dú)區(qū)域
connection (Region, ConnectedRegions)
*根據(jù)區(qū)域面積篩選出指定區(qū)域
select_shape (ConnectedRegions, SelectedRegions, 'area', 'and', 2500, 5150)
*************************測量算子*******************************
*畫仿射矩形
draw_rectangle2 (3600, Row5, Column4, Phi1, Length2, Length3)
gen_rectangle2 (Rectangle1, Row5, Column4, Phi1, Length2, Length3)
*獲取測量句柄
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)注創(chuàng)新互聯(lián)行業(yè)資訊頻道。
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。