189 8069 5689

Halcon算子的示例分析-创新互联

本篇文章为大家展示了Halcon算子的示例分析,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。

铜山网站建设公司创新互联,铜山网站设计制作,有大型网站制作公司丰富经验。已为铜山上千余家提供企业网站建设服务。企业网站搭建\外贸网站建设要多少钱,请找那个售后服务好的铜山做网站的公司定做!

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)

*将不相互连接的区域分开为单独区域

connection (Region, ConnectedRegions)

*根据区域面积筛选出指定区域

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)

*句柄,平滑参数,灰度差,极性,选择边缘点,边缘中心y,x坐标,幅度,距离

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)

*************************图像--区域--轮廓************************

*区域转轮廓

gen_contour_region_xld (SelectedRegions, Contours, 'border')

*轮廓点坐标

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)

****************************拟合矩形****************************

*生成感兴趣的区域

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)

***********************************计算垂足、夹角***************************************

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')

*取轮廓上的点

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)

*计算点到线的垂足

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

*显示点、直线、垂足、垂线

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)

*计算两条直线的夹角

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

*弧度转角度deg,角度转弧度rad

Ang:=deg(Angle)

*计算直线和水平轴x的夹角

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

Ang1:=deg(Angle1)

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

Ang2:=deg(Angle2)

上述内容就是Halcon算子的示例分析,你们学到知识或技能了吗?如果还想学到更多技能或者丰富自己的知识储备,欢迎关注创新互联行业资讯频道。

另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


文章名称:Halcon算子的示例分析-创新互联
URL网址:http://jkwzsj.com/article/dsecjh.html

其他资讯