【1】Halcon图像掩磨

具体思路:打开图像,将图像转换为区域(二值化或者区域增长法),选择感兴趣区域,将区域变换为图像,将两个图像相乘,最后得到掩磨图像。

关键函数:

threshold()   //图像转换为区域

connection //区域化

select_shape() //选择感兴趣区域

paint_region // 将区域变换为图像

mult_image // 图像相乘

【2】代码

*[1]open image
read_image (Flower, 'C:/Users/Administrator/Desktop/datapicture/flower.jpg')
rgb1_to_gray (Flower, GrayImage)

*[2]select roi  二值化 膨胀  区域分割  面积过滤
threshold (GrayImage, Regions, 127, 255)
dilation_circle (Regions, RegionDilation, 25.5)
connection (RegionDilation, ConnectedRegions)
select_shape (ConnectedRegions, SelectedRegions, 'area', 'and', 10000, 199999)

*[3]region translate into image  获取图像尺寸  建立空白图像  roi区域打印
get_image_size (GrayImage, Width, Height)
gen_image_proto (GrayImage, ImageCleared, 0)
paint_region (SelectedRegions, ImageCleared, ImageResult, 255, 'fill')

*[4]掩磨
mult_image (GrayImage, ImageResult, ImageResult1, 0.005, 0)

【3】图像展示

Logo

有“AI”的1024 = 2048,欢迎大家加入2048 AI社区

更多推荐