为了对二值图像中连通体的标记进行加速,提出一种基于CUDA的二值图像连通体标记算法.首先为每个非零元素赋予初始标号,再将标号修改为8邻域内最小标号来完成初始标记;然后根据结构元素匹配法找到标号矩阵中同一连通体有可能出现不同根标号的位置,使用原子操作对根标号进行合并,通过CPU与GPU的协同工作来判断合并程度并进行循环修改;最后对所有标号使用回溯法进行一次性修改,实现复杂形状的连通体标记.实验结果表明,该算法较已有的算法减少了全局内存的读写次数和处理线程数量,加快了处理速度.
To accelerate connected component labeling(CCL)in binary image,a CUDA based CCL algorithm isproposed.First,the algorithm assigns each none-zero element a unique initial label,and modifies the label to thesmallest label around its8-neighbor.Then,structure element matching method is used to find the positions thatmay contain different root labels within one connected component,different root labels are merged using atomicoperation in CUDA.The merge operation would execute cyclically and the degree of merge is controlled by collaborativework of CPU and GPU.Finally,each label is modified to their root label by backtracking method,thuslabeling the complex-shaped components correctly.The experimental results show that this algorithm reducesglobal memory access as well as the number of processing threads,meanwhile,accelerates the processing speed.