halcon学习(一)dyn_threshold

来源:互联网 发布:淘宝上3m口罩差价很大 编辑:程序博客网 时间:2024/05/16 19:44

dyn_thresh 动态阈值分割

dyn_threshold(OrigImage,ThresholdImage : RegionDynThresh :Offset,LightDark : )
当前背景之间差异明显时,可以设定全局阈值进行threshold,但很多情况下由于背景不均一,目标体经常表现为比背景局部亮一些或暗一些,无法确定全局阈值操作,需要通过其邻域找到一个合适的阈值进行分割。ThresholdImage是参考图像,通过与OrigImage对比找到领域确定阈值,一般采用平滑滤波算子(如mean_image)获取参考图像。offset设定邻域比较的区间范围,灰度值变化在offset范围内均是可以接受的。令 g_{o} = g_{OrigImage}, g_{t} = g_{ThresholdImage}分别代表原图和参考图中的像素点的灰度值.我们的做法是把参考图像的灰度值加上(减去)一个Offset,然后去和原图的像素点逐像素对应地进行比较。下面看Halcon中给出的这些公式:

The condition for LightDark = 'light' is:g_o>=g_t+offset ,light就提取相对参考图更亮的区域。

For LightDark='dark' ,the conditon is: g_o<=g_t-offset ,dark就提取相对参考图更暗的区域

For LightDark='equal',g_t-offset<=g_o<=g_t+offset,选取和参考图差不多的区域。


Withdyn_threshold, contours of an object can be extracted, where the objects' size (diameter) is determined by the mask size of the lowpass filter and the amplitude of the objects' edges:The larger

the mask size is chosen, the larger the found regions become. As a rule of thumb, the mask size shouldbe about twice the diameter of the objects to be extracted. It is important not to set the parameter Offset to zero because in this case too many small regions will be found (noise). Values between 5 and 40 are a useful choice. The largerOffset is chosen, the smaller the extracted regions become. All points of the input image fulfilling the above condition are stored jointly in one region. If necessary, the connected components can be obtained by callingconnection.




1 0
原创粉丝点击