Abstract—This paper proposes a new two-scan algorithm for
labeling connected components in binary images. In the first
scan of our algorithm, all conventional two-scan labeling
algorithms process image lines one by one and process pixels
one by one. In comparison, we process image lines two by two
and process image pixels two by two. By our algorithm, the
average times for checking the neighbor pixels for processing a
foreground pixel will decrease, which leads to an efficient
labeling processing. Experimental results on various types of
images demonstrated that our method is more efficient than
conventional label-equivalence-based labeling algorithms.
Index Terms— connected component, labeling, pattern
recognition, fast algorithm, computer vision
I. INTRODUCTION
BELING of connected components in a binary image is
one of the most fundamental operations in pattern
analysis, pattern recognition, computer (robot) vision, and
machine intelligence [1,2]. Especially in real-time
applications such as traffic-jam detection, automated
surveillance, and target tracking, faster labeling algorithms
are always desirable.
Many algorithms have been proposed for addressing this
issue, because the improvement of the efficiency of labeling
is critical in many applications. For ordinary computer
architectures and 2D images, there are mainly two types of
labeling algorithms:
(1) Raster-scan algorithms. These algorithms process an
image in the raster-scan way. There are multi-scan
algorithms [3], [4] the four-scan algorithm [5],
two-scan algorithms [6-14], and the one-and-a-half
algorithm [15].
(2) Label propagation algorithms. These algorithms access
an image in an irregular way. There are run-based
algorithms [2], [16] and contour-tracing algorithms
[17], [18].
According to experimental results on various types of
Manuscript received Feb. 28, 2012. This work was supported in part by
the Ministry of Education, Science, Sports and Culture, Japan, Grant-in-Aid
for Scientific Research (C), 23500222, 2011.
L. He is with the Shanxi University of Science and Technology, and also
with the Graduate School of Information Science and Technology, Aichi
Prefectural University, Nagakute, Aichi 480-1198, Japan (The
corresponding author, Tel: +81-561-1111; Fax: +81-561-1108; e-mail:
helifeng@ist.aichi-pu.ac.jp).
Y. Chao is with Graduate School of Environment Management, Nagoya
Sangyo University, Aichi 488-8711, Japan.
K. Suzuki is with the Department of Radiology, Division of the Biological
Sciences, The University of Chicago, Chicago, IL 60637, USA (e-mail:
Suzuki@uchicago.edu).
images, the algorithm proposed in [13], which is an
improvement on the two-scan algorithm proposed in [12], is
the most efficient one, and has been used for various
applications [19]-[21]. For convenience, we denote this
algorithm as HCS algorithm.
The HCS algorithm is a two-scan labeling algorithm.
Similar to other two-scan labeling algorithms, it completes
labeling in two scans by three processes: (1) provisional label
assignment (i.e., assigning a provisional label to each
foreground pixel) and equivalent-label finding (i.e., finding
the provisional labels assigned to the same connected
components); (2) equivalent label record (i.e., using some
data structures to record equivalent labels) and
label-equivalence resolving (i.e., finding a representative
label for all equivalent provisional labels); (3) label
replacement (i.e., replacing each provisional label by its
representative label).
The HCS algorithm uses equivalent label sets and a
representative label table to record equivalent labels and
resolve the label equivalences. Usually, the smallest label in
an equivalent label set is used to the representative label of
the set and all labels in the set. For convenience, an
equivalent label set with the representative label u is denoted
as S(u), and the representative label of a provisional label s is
t, denoted as T [s] = t.
In the first scan, this algorithm uses the mask shown in
Fig. 1 (a), which consists of three scanned neighbor of the
current foreground pixels, to assign provisional labels to
foreground pixels, and to record and resolve label
equivalences. At any moment, all equivalent provisional
labels are combined in an equivalent label set with the same
representative label.
For the case where the current foreground pixel follows a
background pixel (Fig. 1 (b)), if there is no label (foreground
pixel) in the mask, it means that the current foreground pixel
does not connect with any scanned foreground pixel, and the
current foreground pixel belongs to a new connected
component in the scanned area. The algorithm assigns a new
provisional label m to the current foreground pixel, which is
initialized to 1, and establishes the equivalent label set
S(m)={m}; it sets the representative label table as T [m] = m,
and m = m+1 for later processing. Otherwise, i.e., if there are
foreground pixels in the mask, all of such foreground pixels
and the current foreground pixel belong to the same
connected component. Therefore the current foreground
pixel can be assigned any of the labels in the mask. On the
other hand, for the case where the current foreground pixel
follows another foreground pixel (Fig. 1 (c)), the current
foreground pixel can be assigned the same label of that
A New Two-Scan Algorithm for Labeling
Connected Components in Binary Images
Lifeng He, Yuyan Chao, Kenji Suzuki
L
Proceedings of the World Congress on Engineering 2012 Vol II
WCE 2012, July 4 - 6, 2012, London, U.K.
ISBN: 978-988-19252-1-3
ISSN: 2078-0958 (Print); ISSN: 2078-0966 (Online)