Halcon特征检测

简介:

             通过Halcon对目标区域特征检测。常用检测面积、长宽等。

 

介绍:

region_features (获取区域特征)
Regions (input_object) Regions to be examined.区域
Features (input_control) Shape features to be calculated.
Default value: 'area'
List of values: 'anisometry', 'area', 'area_holes', 'bulkiness', 'circularity', 'column', 'column1', 'column2', 'compactness', 'connect_num', 'contlength', 'convexity', 'dist_deviation', 'dist_mean', 'euler_number', 'height', 'holes_num', 'inner_height', 'inner_radius', 'inner_width', 'max_diameter', 'moments_i1', 'moments_i2', 'moments_i3', 'moments_i4', 'moments_ia', 'moments_ib', 'moments_m02', 'moments_m02_invar', 'moments_m03', 'moments_m03_invar', 'moments_m11', 'moments_m11_invar', 'moments_m12', 'moments_m12_invar', 'moments_m20', 'moments_m20_invar', 'moments_m21', 'moments_m21_invar', 'moments_m30', 'moments_m30_invar', 'moments_phi1', 'moments_phi2', 'moments_psi1', 'moments_psi2', 'moments_psi3', 'moments_psi4', 'num_sides', 'orientation', 'outer_radius', 'phi', 'ra', 'rb', 'rect2_len1', 'rect2_len2', 'rect2_phi', 'rectangularity', 'roundness', 'row', 'row1', 'row2', 'struct_factor', 'width'
特征选择
Value (output_control) The calculated features.输出的特征值
Features(特征)
areaArea of the object对象的面积 
rowRow index of the center中心点的行坐标 
columnColumn index of the center中心点的列坐标 
widthWidth of the region区域的宽度 
heightHeight of the region区域的高度 
row1Row index of upper left corner左上角行坐标 
column1Column index of upper left corner左上角列坐标 
row2Row index of lower right corner右下角行坐标 
column2Column index of lower right corner右下角列坐标 
circularityCircularity圆度0~1(circularity)
compactnessCompactness紧密度0~1(compactness)
contlengthTotal length of contour轮廓线总长(contlength)
convexityConvexity凸性(convexity)
rectangularityRectangularity矩形度0~1(rectangularity)
raMain radius of the equivalent ellipse等效椭圆长轴半径长度(elliptic_axis)
rbSecondary radius of the equivalent ellipse等效椭圆短轴半径长度(elliptic_axis)
phiOrientation of the equivalent ellipse等效椭圆方向(elliptic_axis)
anisometryAnisometry椭圆参数,Ra/Rb长轴与短轴的比值(eccentricity)
bulkinessBulkiness椭圆参数,蓬松度π*Ra*Rb/A(eccentricity)
struct_factorStructur Factor 椭圆参数,Anisometry*Bulkiness-1(eccentricity)
outer_radiusRadius of smallest surrounding circle最小外接圆半径(smallest_circle)
inner_radiusRadius of largest inner circle最大内接圆半径(inner_circle)
inner_widthWidth of the largest axis-parallel rectangle that fits into the region最大内接矩形宽度(inner_rectangle1)
inner_heightHeight of the largest axis-parallel rectangle that fits into the region最大内接矩形高度( inner_rectangle1)
dist_meanMean distance from the region border to the center区域边界到中心的平均距离(roundness)
dist_deviationDeviation of the distance from the region border from the center区域边界到中心距离的偏差(roundness)
roundnessRoundness圆度,与circularity计算方法不同(roundness)
num_sidesNumber of polygon sides多边形边数(roundness)
connect_numNumber of connection components连通数(connect_and_holes)
holes_numNumber of holes区域内洞数(connect_and_holes)
area_holesArea of the holes of the object所有洞的面积(area_holes)
max_diameterMaximum diameter of the region最大直径(diameter_region)
orientationOrientation of the region区域方向(orientation_region)
euler_numberEuler number欧拉数,即连通数和洞数的差(euler_number)
rect2_phiOrientation of the smallest surrounding rectangle最小外接矩形的方向(smallest_rectangle2)
rect2_len1Half the length of the smallest surrounding rectangle最小外接矩形长度的一半(smallest_rectangle2)
rect2_len2Half the width of the smallest surrounding rectangle最小外接矩形宽度的一半(smallest_rectangle2)
moments_m11Geometric moments of the region几何矩 
moments_m20Geometric moments of the region几何矩 
moments_m02Geometric moments of the region几何矩 
moments_iaGeometric moments of the region几何矩 
moments_ibGeometric moments of the region几何矩 
moments_m11_invarGeometric moments of the region几何矩 
moments_m20_invarGeometric moments of the region几何矩 
moments_m02_invarGeometric moments of the region几何矩 
moments_phi1Geometric moments of the region几何矩 
moments_phi2Geometric moments of the region几何矩 
moments_m21Geometric moments of the region几何矩 
moments_m12Geometric moments of the region几何矩 
moments_m03Geometric moments of the region几何矩 
moments_m30Geometric moments of the region几何矩 
moments_m21_invarGeometric moments of the region几何矩 
moments_m12_invarGeometric moments of the region几何矩 
moments_m03_invarGeometric moments of the region几何矩 
moments_m30_invarGeometric moments of the region几何矩 
moments_i1Geometric moments of the region几何矩 
moments_i2Geometric moments of the region几何矩 
moments_i3Geometric moments of the region几何矩 
moments_i4Geometric moments of the region几何矩 
moments_psi1Geometric moments of the region几何矩 
moments_psi2Geometric moments of the region几何矩 
moments_psi3Geometric moments of the region几何矩 
moments_psi4Geometric moments of the region几何矩 

 

使用:

  1. 彩色图像要转成灰色图像。
  2. 腐蚀和膨胀,去除影响的区域。
  3. 特征检测,根据特征参数选择所需要的。

 

read_image (Image, 'E:/照片/RGB.jpg')
decompose3 (Image, Image1, Image2, Image3)
trans_from_rgb (Image1, Image2, Image3, ImageResult1, ImageResult2, ImageResult3, 'hsv')
threshold (ImageResult3, Region, 180, 255)
*腐蚀
erosion_rectangle1 (Region, RegionErosion, 2, 2)
*膨胀
dilation_rectangle1 (RegionErosion, RegionDilation, 2, 2)
connection (RegionDilation, ConnectedRegions)
select_shape (ConnectedRegions, SelectedRegions, 'area', 'and', 150, 99999)
*特征
region_features (SelectedRegions, ['area','row1','column1', 'width', 'height'], Value)
for i := 0 to (|Value|/5) - 1 by 1
    area := Value[i*5]
    row1 := Value[i*5 + 1]
    column1 := Value[i*5 + 2]
    width := Value[i*5 + 3]
    height := Value[i*5 + 4]
    
    *height
    disp_arrow (3600, row1, column1, row1 + height, column1, 1)
    disp_message (3600, height, 'image', row1 + height/3, column1 - 10, 'cyan', 'false')
    
    *width
    disp_arrow (3600, row1, column1, row1, column1 + width, 1)
    disp_message (3600, height, 'image', row1 - 10 , column1 + width/3, 'cyan', 'false')
    
    *area
    disp_message (3600, area, 'image', row1 + height/3 , column1 + width/3, 'black', 'true')
endfor
长宽和面积
  • 3
    点赞
  • 37
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值