blob分析找出感兴趣区域,求其轮廓再用差分找缺陷

发布时间:2024年01月10日
*关闭程序计数器,图形变量,窗口图形更新
dev_update_off() 


* Image Acquisition 01: Code generated by Image Acquisition 01
ImageFiles := []
ImageFiles[0] := '1.bmp'
ImageFiles[1] := '2.bmp'
for Index := 0 to |ImageFiles| - 1 by 1
    
    *读取一张图像
    read_image (Image, ImageFiles[Index])

    *分割出环形区域
    threshold (Image, Region, 100, 255)

    *对区域进行连通处理
    connection (Region, ConnectedRegions)

    *过滤出圆环区域
    select_shape (ConnectedRegions, SelectedConnectedRegions, ['area','circularity'], 'and', [40000,0.6], [99999,1]) 

    *将圆环区域中的图像剪切出来
    reduce_domain (Image, SelectedConnectedRegions, ImageReduced) 

    *将图像和高斯导数进行卷积运算求轮廓
    derivate_gauss (ImageReduced, DerivGaussImage, 1.5, 'gradient') 

    *分割出图像中的轮廓
    threshold (DerivGaussImage, DerivGaussRegion, 9, 50)

    *对轮廓区域进行连通处理
    connection (DerivGaussRegion, DerivGaussConnectedRegions) 

    *获取的轮廓区域
    select_shape_std (DerivGaussConnectedRegions, SelectedDerivGaussConnectedRegions, 'max_area', 70) 

    *填充该轮廓区域
    fill_up (SelectedDerivGaussConnectedRegions, RegionFillUp) 

    *求轮廓区域和填充的轮廓区域之间的补集区域
    difference (RegionFillUp, SelectedDerivGaussConnectedRegions, RegionDifference) 

    *对补集区域进行连通处理
    connection (RegionDifference, ResultConnectedRegions) 

    *获取缺陷区域
    select_shape (ResultConnectedRegions, DefectResult, 'area', 'and', 50, 999) 

    *显示图像
    dev_display (Image) 

    *显示缺陷区域
    dev_display (DefectResult)
    
    stop()

endfor

文章来源:https://blog.csdn.net/weixin_38241876/article/details/135506715
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。