论文Fast connected-component labeling 阅读

Fast connected-component labeling

由Lifeng He 发表在Pattern Recognition 42 (2009)的文章

Conventional two-raster-scan algorithms

在第一遍raster scan之后,算法需要记录各个label之间的关系,找出其中属于同一个component的label,有三种方法:

  1. 使用一个LxL的表,L表示label的数量。首先都初始化为0,如果label i和j是属于同一个component,那么就把表中的元素Xij=1
  2. 使用union find tres。如果label i和j属于同一个component,就把二者对应的union find tree连接起来
  3. 使用set结构来保存。如果label i和j属于同一个component,就把二者对应的set合兵

确定等价关系后,然后再根据等价关系重新label

Outline of our proposed algorithm

以8邻域分析为例,本文还是使用两次scan的方法,并使用上面的方法3来记录label之间的等价关系。这一块没有搞清楚:

Because the method by using equivalent label sets and the representative label table for resolving label equivalences is simple and
efficient, we also use the method for resolving label equivalence in our algorithm.
By this method, in the first scan, all provisional labels that belong to a connected component found at this point will be combined in the same equivalent label set and hold the same representative label. That is, all labels in an equivalent label set are equivalent. Therefore, when processing an object pixel, in the case where there is at least one object pixel in the mask, instead of assigning the minimum label in the mask to the object pixel, we can assign an arbitrary provisional label in the mask to it. This simplifies the labeling operation by avoiding calculation of the minimum label in the mask.

作者认为使用set的这种方法,因为相邻的反正都是属于同一个component,所以把邻域的任意个label赋值给当前点都可以,不需要进行min判断。这里对比的应该是使用union-find的two-pass方法,都会找到邻域最小的label来复制给当前点。但是我认为对于union-find也可以不用min判断,其与使用set的方式并无本质区别。相关论文或者博文上面都是写着要做一个min操作,但是没有发现有讲明原因的。

本方法重要的改进在于提出一种最高效的判断方法,不过此方法对于8邻域是有效的,对于4邻域可能就没有什么效果了。

首先,分析了16种可能的情况

image-20200523235222436

对于需要进行resolver操作的进行了分析,

image-20200523235324483

其中c1, c2, c3, and c4 分别表示b(x - 1, y),b(x - 1, y - 1), b(x, y - 1), and b(x + 1, y - 1), 表格中结果为1表示需要进行resolve操作,0表示不需要。根据这个表,可以推导出,不需要进行resolve操作的情况为c3 | !c4 | !c1 & !c2,根据这个结果,从而推导出最优的判断逻辑:

image-20200523220537262

使用这样的判断能最小化所需要的判断。比如,假如首先判断c4,如果c4不是一个object,虽然可以断定不需要resolve,但是我们还需要判断其他三个,判断他们是否是object,来给b设定一个合适的label。这种思路就相当于一个贪心算法,先把能输出最多结果的给处理,再处理其它的。c3就是一个能输出最多结果的,如果c3是object的话,那么既可以断定不需要resolve,也能断定b应该设定什么样的label。

性能对比

  • 不同图像大小的时的对比
  • 不同前景object占图像比例时的对比
  • 不同的图片类型的对比

image-20200524002537435

image-20200524002553910

posted @ 2020-05-24 00:28  willhua  阅读(470)  评论(0编辑  收藏  举报