HALCON示例程序high.hdev使用不同方法提取区域
示例程序源码(加注释)
- 关于显示类函数解释
dev_close_window ()
read_image (Mreut, ‘mreut_y’)
get_image_size (Mreut, Width, Height)
dev_open_window (0, 0, Width, Height, ‘black’, WindowHandle)
read_image (MreutDem, ‘mreut_dgm_2.0’) - 在0到255范围内扩展的最大灰度值
scale_image_max (MreutDem, ImageScaleMax) - Initialize parameters
get_system (‘clip_region’, Information)
set_system (‘clip_region’, ‘false’)
dev_set_draw (‘margin’)
dev_set_color (‘red’) - 使用圆形掩码进行开
dual_rank (ImageScaleMax, ImageRank, ‘circle’, 15, 10, ‘mirrored’) - 图像对减
sub_image (ImageScaleMax, ImageRank, ImageSubRank, 1, 0) - 二值化
threshold (ImageSubRank, High, 7, 255) - 请参考之前博客中的介绍
zoom_region (High, HighZoomed, 8, 8)
move_region (HighZoomed, HighZoomedMoved, -250, -600)
clip_region (HighZoomedMoved, HighAreas, 0, 0, 511, 511)
dev_display (Mreut)
dev_display (HighAreas)
disp_continue_message (WindowHandle, ‘black’, ‘true’)
stop () - gen_disc_se - 生成用于灰度形态学的椭圆形结构元素。
gen_disc_se (SE, ‘real’, 30, 30, 0) - 礼帽 = 原始输入-开运算结果
- 黑帽 = 闭运算-原始输入
gray_tophat (MreutDem, SE, ImageTopHat)
threshold (ImageTopHat, High, 4, 1000)
zoom_region (High, HighZoomed, 8, 8)
move_region (HighZoomed, HighZoomedMoved, -250, -600)
clip_region (HighZoomedMoved, HighAreas, 0, 0, 511, 511)
dev_display (Mreut)
dev_display (HighAreas)
disp_continue_message (WindowHandle, ‘black’, ‘true’)
stop () - 动态阈值,这个在之前帖子用过太多次了,不介绍了。
mean_image (ImageScaleMax, ImageMean, 51, 51)
dyn_threshold (ImageScaleMax, ImageMean, High, 4, ‘light’)
zoom_region (High, HighZoomed, 8, 8)
move_region (HighZoomed, HighZoomedMoved, -250, -600)
clip_region (HighZoomedMoved, HighAreas, 0, 0, 511, 511)
dev_display (Mreut)
dev_display (HighAreas)
set_system (‘clip_region’, Information)
处理思路
这个例子是主要讲解了阈值分割的三种方法使用图像的闭运算与原图对减dual_rank 、sub_image、threshold ;礼帽算法gen_disc_se、gray_tophat 、threshold ;动态阈值mean_image 、dyn_threshold
后记
大家有什么问题可以向我提问哈,我看到了第一时间回复,希望在学习的路上多多结交良师益友。