Halcon-区域生长和分水岭图像分割
作者:互联网
区域生长图像分割
regiongrowing (Image,Outregion: Row,Col,Tolerance,MinSize)
函数:regiongrowing (ImageMedian, Regions, 1, 1, 2, 100)
ImageMedian:输入的单通道图像
Regions:输出的一组区域
参数3和4:矩形的宽和高,奇数,可以视为卷积核
参数5:像素灰度值差-阈值
参数6:输出区域的最小像素数,默认为100
*区域分割
read_image (Image, 'mreut')
dev_close_window ()
get_image_size (Image, Width, Height)
dev_open_window (0, 0, Width, Height, 'white', WindowHandle)
median_image (Image, ImageMedian, 'circle', 2, 'mirrored')
regiongrowing (ImageMedian, Regions, 1, 1, 2, 100)
fill_up_shape (Regions, RegionFillUp, 'area', 1, 100)
closing_circle (RegionFillUp, RegionClosing, 7.5)
dev_clear_window ()
dev_set_draw ('fill')
dev_set_color ('green')
dev_display (RegionClosing)
dev_set_color ('black')
dev_set_draw ('margin')
dev_display (RegionClosing)
分水岭图像分割
watersheds_threshold (ImageInvert, Basins, 5)
参数分别为输入图像;输出盆地区域;灰度阈值
*分水岭分割
dev_set_draw ('margin')
dev_set_colored (12)
read_image (Image, 'pellets')
dev_display (Image)
threshold (Image, Region, 105, 255)
connection (Region, ConnectedRegions)
select_shape (ConnectedRegions, SelectedRegions, 'area', 'and', 20, 99999)
dev_display (SelectedRegions)
distance_transform (SelectedRegions, DistanceImage, 'octagonal', 'true', 380, 350)
convert_image_type (DistanceImage, ImageConverted, 'byte')
invert_image (ImageConverted, ImageInvert)
watersheds_threshold (ImageInvert, Basins, 5)
dev_display (Basins)
intersection (Basins, SelectedRegions, RegionIntersection)
dev_display (RegionIntersection)
标签:set,Image,dev,Halcon,ImageMedian,image,图像,分水岭,display 来源: https://blog.csdn.net/weixin_45645281/article/details/113810139