halcon学习笔记 ----第三课: 图像的 BLOB 分析处理流程---dyn_threshold.hdev

知识点一:

 1、mean_image (Image, ImageMean, 59, 59)

 2、dyn_threshold (Image, ImageMean, RegionDynThresh, 15, 'not_equal')

       dyn_threshold动态阈值算子一般和均值滤波算子一起使用,先用mean_image算子得到平滑后的图像,然后将原始图像和均值滤波后的图像对比,得到需要的区域,特别适用于所选目标和背景图像对比不均匀时

 注意:mean_image算子的最后两个参数应为奇数,值应为2D+1,D为所提取目标最大边缘的直径

                                                                                 

                                                                    nnn

知识点二:常用的三种显示算子

         1、显示图片算子        

         dev_display (Image)
         

         2、界面显示汉字算子

         Message := 'Original image'
         disp_message (WindowHandle, Message, 'window', 12, 12, 'black', 'true')
         

        3、界面显示按F5继续提示算子,该算子由disp_message算子演变而来,在C#中没有暂停功能,只起到显示字体作用

        disp_continue_message (WindowHandle, 'black', 'true')

         

知识点三:

       对于图像分割后所得到的区域,如果区域的对象存在孔或缝隙(图片2),可以先用闭运算填充(图像3),然后再开运算去除毛刺(图片4),然后打散,求最小外接圆半径,然后生成圆形轮廓

       

* 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 (WindowHandle >= 0)
    dev_resize_window_fit_image (Image, 0, 0, -1, -1)
else
    dev_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 ()

1、原始图片

        

                                                                                                    图片1

2、动态阈值后的图片

          

                                                                                                      图片2

3、闭运算后的图片 

         

                                                                                                      图片3

  4、开运算图片

        

                                                                                                      图片4

     

5、打散

          

                                                                                                     图片5

6、目标生成圆形轮廓

         

                                                                                                        图片6

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值