Halcon缺陷检测

简介:

            用于表面缺陷的检测,判定产品的良率、是否合格等。

 

介绍:

gray_opening_shape(开运算)/gray_closing_shape(闭运算)
Image (input_object) Image for which the minimum gray values are to be calculated.灰度图像
ImageOpening(output_object) Image containing the minimum gray values.输出的灰色图像
MaskHeight (input_control)Height of the filter mask.
Default value: 11
Suggested values: 3, 5, 7, 9, 11, 13, 15
Typical range of values: 1.0 ≤ MaskHeight ≤ 511.0
运算的高参数
MaskWidth (input_control) Width of the filter mask.
Default value: 11
Suggested values: 3, 5, 7, 9, 11, 13, 15
Typical range of values: 1.0 ≤ MaskWidth ≤ 511.0
运算的宽参数
MaskShape (input_control)  Shape of the mask.
Default value: 'octagon'
List of values: 'octagon', 'rectangle', 'rhombus'
形状
dyn_threshold(局部阈值)
OrigImage (input_object)  Input image.图像
ThresholdImage (input_object) Image containing the local thresholds.要对比的图想
RegionDynThresh (output_object)  Segmented regions.输出的对比后区域
Offset (input_control) Offset applied to ThresholdImage.
Default value: 5.0
Suggested values: 1.0, 3.0, 5.0, 7.0, 10.0, 20.0, 30.0
Typical range of values: -255.0 ≤ Offset ≤ 255.0 (lin)
Minimum increment: 0.01
Recommended increment: 5
Restriction: (-255 < Offset) && (Offset < 255)
偏离量
LightDark (input_control)  

Extract light, dark or similar areas?
Default value: 'light'
List of values: 'dark', 'equal', 'light', 'not_equal'

 

g_{o} = g_{OrigImage}and g_{t} = g_{ThresholdImage}
light(亮)

go ≥ gt + Offset(缺陷点所在的灰度值大于周围,即亮点)

dark(暗)go ≤ gt - Offset(缺陷点所在的灰度值小于周围,即暗点)
equal(区间)gt - Offset ≤ go ≤ gt + Offset
not_equal(非区间)gt - Offset > go && go > gt + Offset
暗亮选择

 

使用:

  1. 彩色图像要转成灰色图像。
  2. 提取包含目标的图片或选择此目标的图片。
  3. 开和闭运算(参数需要根据实际更改),然后对比。
  4. 根据实际判断某个特征,例如面积,判定缺陷。
read_image (Image, 'E:/照片/缺陷')

*RGB图像转换
decompose3 (Image, Image1, Image2, Image3)
trans_from_rgb (Image1, Image2, Image3, ImageResult1, ImageResult2, ImageResult3, 'hsv')

dev_set_draw ('margin')
dev_set_color ('red')

*对比检测缺陷
openvalue := 1
closevalue := 100
gray_opening_shape (ImageResult3, ImageOpening, openvalue, openvalue, 'rectangle')
gray_closing_shape (ImageResult3, ImageClosing, closevalue, closevalue, 'rectangle')
dyn_threshold (ImageOpening, ImageClosing, RegionDynThresh, 50, 'dark')
connection (RegionDynThresh, ConnectedRegions)
count_obj (ConnectedRegions, Number)

*通过面积判定缺陷
for Index := 1 to Number by 1
    select_obj (ConnectedRegions, ObjectSelected, Index)
    area_center (ObjectSelected, Area1, Row1, Column1)
    if (Area1 > 1000)
        set_tposition (3600, Row1, Column1)
        write_string (3600, Area1)
    endif
endfor

dev_display (ImageResult3)
dev_display (RegionDynThresh)

 

缺陷
缺陷检测结果

 

 

  • 1
    点赞
  • 24
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值