halcon 例程学习dyn

编程入门 行业动态 更新时间:2024-10-15 04:20:45

halcon <a href=https://www.elefans.com/category/jswz/34/1769196.html style=例程学习dyn"/>

halcon 例程学习dyn

halcon mean+dyn_threshold的阈值指某一像素周围的阈值,周围直径参数值为目标的宽度2D+1;

当前背景之间差异明显时,可以设定全局阈值进行threshold,但很多情况下由于背景不均一,目标体经常表现为比背景局部亮一些或暗一些,无法确定全局阈值操作,需要通过其邻域找到一个合适的阈值进行分割。

MeanImage是参考图像,通过与OrigImage对比找到领域确定阈值,一般采用平滑滤波算子(如mean_image)获取参考图像。offset设定邻域比较的区间范围,灰度值变化在offset范围内均是可以接受的。 

opening_circle理解为当开操作的圆在区域内放不下时delete,放得下时保留;closeing_circlel理解为连接比较近的两个区域;一般开操作成对存在,例如本例子先闭后开(连接区域后消除小毛刺)。

* This example shows the use of the operator dyn_threshold for
* the segmentation of the raised dots of braille chharacters.
* The operator dyn_threshold is especially usefull if the
* background is inhomogeneously illuminated. In this example,
* the segmentation with a simple threshold is not possible
* because the brightness of the background increases from
* left to right.
* 
dev_update_off ()
* 
* Preparation
read_image (Image, 'photometric_stereo/embossed_01')
get_image_size (Image, Width, Height)
dev_get_window (WindowHandle)
if (is_handle_elem(WindowHandle) == true)* valid window handledev_resize_window_fit_image (Image, 0, 0, -1, -1)
elsedev_open_window_fit_image (Image, 0, 0, -1, -1, WindowHandle)
endif
set_display_font (WindowHandle, 16, 'mono', 'true', 'false')
dev_set_line_width (2)
* 
dev_display (Image)
Message := 'Original image'
disp_message (WindowHandle, Message, 'window', 12, 12, 'black', 'true')
disp_continue_message (WindowHandle, 'black', 'true')
stop ()
* 
* Use a strong mean filter on the image to blur out the braille points
mean_image (Image, ImageMean, 59, 59)
* 
dev_display (ImageMean)
Message := 'Mean filtered image'
disp_message (WindowHandle, Message, 'window', 12, 12, 'black', 'true')
disp_continue_message (WindowHandle, 'black', 'true')
stop ()
* 
* Compare the original image with the blurred one and determine the
* region where the gray values of the two images differ by more than 15
dyn_threshold (Image, ImageMean, RegionDynThresh, 15, 'not_equal')
* 
dev_display (Image)
dev_display (RegionDynThresh)
Message := 'Regions segmented with dyn_threshold'
disp_message (WindowHandle, Message, 'window', 12, 12, 'black', 'true')
disp_continue_message (WindowHandle, 'black', 'true')
stop ()
* 
* Post-process the found regions
closing_circle (RegionDynThresh, RegionClosing, 8.5)
opening_circle (RegionClosing, RegionOpening, 6.5)
connection (RegionOpening, ConnectedRegions)
smallest_circle (ConnectedRegions, Row, Column, Radius)
gen_circle_contour_xld (ContCircle, Row, Column, Radius, 0, 6.28318, 'positive', 1)
* 
* Show the results
dev_display (Image)
dev_set_color ('green')
dev_display (ContCircle)
Message := 'Results of braille segmentation after morphology'
disp_message (WindowHandle, Message, 'window', 12, 12, 'black', 'true')
* 
dev_update_on ()

原图

动态阈值后

 闭操作

 开操作

更多推荐

halcon 例程学习dyn

本文发布于:2024-03-05 00:59:32,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1710889.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:例程   halcon   dyn

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!