HALCON图像处理的粘连零件颗粒计数

来源:互联网 发布:linux 克隆 编辑:程序博客网 时间:2024/04/29 10:20

方法使用的是论文

基于HALCON图像处理的粘连零件颗粒计数方法研究

测试使用图片粘连工件计数

dev_clear_window()*读取图片read_image (Image, 'C:/Users/Administrator/Desktop/new/QQ图片20161212193015.jpg')get_image_size (Image, Width, Height)*自动阈值分割bin_threshold (Image, Region)*分割后选择的是所需的背景,所以求反一次complement (Region, RegionComplement)dev_display(Image)* dev_display(RegionComplement)*做一次闭运算closing_circle(RegionComplement, RegionClosing, 3.5)*空洞填充 fill_up_shape (RegionClosing, RegionFillUp, 'area', 1, 100) *欧式距离函数的距离变换 distance_transform (RegionFillUp, DistanceImage, 'octagonal', 'true', Width, Height) *int4byte convert_image_type (DistanceImage, ImageConverted, 'byte') *图像取反 invert_image (ImageConverted, ImageInvert) *增加对比度 scale_image_max (ImageInvert, ImageScaleMax) *高斯平滑处理 gauss_image (ImageScaleMax, ImageGauss, 11) *分水岭算法 watersheds_threshold (ImageGauss, Basins, 10) *计数统计为29个 count_obj (Basins, Number) *发现有小区域面积干扰,重新选择区域select_shape (Basins, SelectedRegions, 'area', 'and', 5267.61, 119050)*获取到正确的数目25count_obj (SelectedRegions, Number1)
0 0
原创粉丝点击