You are on page 1of 4

RESEARCHCONTRIBUTIONS

Image Processing
and Computer
Vision
A Fast Parallel Algorithm for
Robert M. Haralick
Editor
Thinning Digital Patterns

T. Y. ZHANG and C. Y. SUEN

ABSTRACT: A fast parallel thinning algorithm is proposed faster and more efficient parallel thinning algorithm.
in this paper. It consists of two subiterations: one aimed at The distortion should be as little as possible. Experi-
deleting the south-east boundary points and the north-west mental results indicate that this method can be used to
corner points while the other one is aimed at deleting the thin a variety of digital patterns.
north-west boundary points and the south-east corner
points. End points and pixel connectivity are preserved. 2. PARALLEL PICTURE PROCESSING
Each pattern is thinned down to a "skeleton" of unitary A binary digitized picture is defined by a matrix IT
thickness. Experimental results show that this method is where each pixel IT(i, j) is either 1 or 0. The pattern
very effective. consists of those pixels that have value 1. Each stroke
in the pattern is more than one element thick. Iterative
transformations are applied to matrix IT point by point
1. INTRODUCTION according to the values of a small set of neighboring
It is well known that the general problem of pattern points. It is assumed that the neighbors of the point (i, j)
recognition lies in the effectiveness and efficiency of are (i - 1, j), (i - 1, j + 1), (i, j + 1), (i + 1, j + 1),
extracting the distinctive features from the patterns. (i + 1, j), (i + 1, j - 1), (i, j - 1), and (i - 1, j - 1), as is
The stroke analysis method is a powerful approach to shown in Figure 1. In parallel picture processing, the
recognizing certain types of digital patterns such as al- new value given to a point at the nth iteration depends
phanumeric characters and ideographs. It should be on its own value as well as those of its eight neighbors
noted that the strokes thinned by hardware or software at the (n - 1)th iteration, so that all picture points can
are accompanied by different kinds of distortion. Differ-
ent thinning algorithms produce different degrees of
distortion [1-5, 7-12]. P, P2 P3
There is no general agreement in the literature on an (i- 1, j- 1) (i- 1, j) (i- 1, j+ 1)
exact definition of thinness. Pavlidis [6] describes a P, P1 P,
thinning algorithm that determines skeletal pixels by (i, j - 1) (i, j) (i,j+ 1)
local operations. At the same time, the pixels are la- P~ Pe Ps
beled so that the original image can be reconstructed (i+ 1 , j - 1) (i+ 1,j) (i+ 1,j+ 1)
from its skeleton. The goal of this paper is to find a
© 1984 ACM 0001-0782/84/0300-0236 75¢ FIGURE 1. Designations of the nine pixels in a 3 x 3 window.

236 Communications of the ACM March 1984 Volume 27 Number 3


Research Contributions

be p r o c e s s e d s i m u l t a n e o u s l y . It is a s s u m e d t h a t a 3 x 3 In t h e s e c o n d s u b i t e r a t i o n , o n l y c o n d i t i o n s (c) a n d (d)
w i n d o w is used, a n d t h a t e a c h e l e m e n t is c o n n e c t e d are c h a n g e d (Figure 3) as follows:
w i t h its e i g h t n e i g h b o r i n g e l e m e n t s . T h e a l g o r i t h m pre-
(c') P2*P4*P8 = 0
sented in this paper requires only simple computations.
(d') P2*P6*P8 = 0
3. T H I N N I N G A L G O R I T H M a n d t h e rest r e m a i n t h e same.
O u r m e t h o d for e x t r a c t i n g t h e s k e l e t o n of a p i c t u r e By c o n d i t i o n s (c) a n d (d) of t h e first s u b i t e r a t i o n , it
consists of r e m o v i n g all t h e c o n t o u r p o i n t s of t h e pic- will be s h o w n t h a t t h e first s u b i t e r a t i o n r e m o v e s o n l y
t u r e e x c e p t t h o s e p o i n t s t h a t b e l o n g to t h e s k e l e t o n . In t h e s o u t h - e a s t b o u n d a r y p o i n t s a n d t h e n o r t h - w e s t cor-
o r d e r to p r e s e r v e t h e c o n n e c t i v i t y of t h e s k e l e t o n , w e n e r p o i n t s w h i c h do not b e l o n g to a n ideal s k e l e t o n .
d i v i d e e a c h i t e r a t i o n into t w o s u b i t e r a t i o n s . T h e p r o o f for t h e first s u b i t e r a t i o n is given, t h a t is,
In t h e first s u b i t e r a t i o n , t h e c o n t o u r p o i n t P1 is de- t h e p o i n t s to b e d e l e t e d satisfy c o n d i t i o n s :
l e t e d from t h e digital p a t t e r n if it satisfies t h e f o l l o w i n g
conditions:
(a) 2 _< B(P1) -< 6
0 0 I
i
(b) A(P~)= 1
1 : P~ 0
(C) P2*P4*P6 = 0
1 I 0 0
(d) P4*P6*P8 = 0 \2 J
w h e r e A(P1) is t h e n u m b e r of 01 p a t t e r n s i n t h e o r d e r e d
set P2, P3, P4, - • - P8, P9 t h a t are t h e eight n e i g h b o r s of FIGURE 2. Counting the 01 patterns in the ordered set P2, P~, P4,
P1 (Figure 1), a n d .... P~, P~.

B(Pi) is t h e n u m b e r of n o n z e r o n e i g h b o r s of P1,
North
t h a t is,
P2
B(P1) = P2 + P3 + P4 + • • • + P8 + P9.
West Pa Pl P4 East
If a n y c o n d i t i o n is not satisfied, e.g., t h e v a l u e s of P2,
Pa
P3, P4, • • - P9 as s h o w n in Figure 2, t h e n
South
A(Pi) = 2
T h e r e f o r e , P~ is n o t d e l e t e d from t h e p i c t u r e . FIGURE 3. Pointsunder consideration and their locations•

.@~.~• @.~@. ~ . • ° . . . .

@@@@@@8@. @8#@@8@@. .@@@@88@


@@8@@88~. @@8@@@@~. .@@8@8@8 .8@@8@@@
@8@@8@@@. @8@@@@8@. .@@@8888 .@@@8@8@
@@@@@@~8. @@~0@@@8. .88@8@8@ .@@@@8@@
. . . . @° .'. .° .@ . . . .
#@@@@@@@. @@@@@~@@. .@@8@~@@ .@@~8@@@
@@@~@8@@. @@@@@@@@. .@88@8@@ .@@@@@@@ . . . . ~o .• • ° o@.,°°
. . . . @. .° .. .@ . . . .
@@8@~@@8. 8@~@@@@@. .@8@@@88 .@@@@88@ . . . . @. .. .. °@ . . . .
@@8@@8@@. @@~@@88@. .88888@~ .@@@8@@8 °° °@ . . . .
• °@o °°
~8@@8@@@. @@@@@@@@. .8@@@@@@ .@@@@@0@
@~8@8@@@@@@88@@@8@@@@@8@@8@. .°@.,o.
..@
. . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . .
~ ....
@ ....
8808@@88088@8@@@@@@@@~8~8@8. .@@@@@@@O@@@@@@@@@@@@@@@@@@ ..@ . . . . . . . . . . . . . . . . . . @ ....
@@@@@@@O@@@@@@@@O@@@@@@~@@@. .@@@@@@@@@@@@#@@O@~@@@@@@@@
@@8@888@8@88@8~@8@@8~@@@@8@. .8@@@@@@@@@~8@@8@#@@@ ....
.~88@@8@@@@@~@~8@8@@@@@@@@@ • .@ . . . . . . . . . . . . . . . . . . @. . . .
888@8@8~8@@@@@8@@8@@@@@#@0. • .@. . . . . . . . . . . . . . . . . . @. . . .
@@@~@@@8~8@8@8@@8@@@@@@~8@8. .8@8@@@@#@88@@@@@@8@@@@@8@@
@888@@88~ . . . . . . . . . . 888~88@@. .@@@@@@@@@8@@@@088@@@@@@@@@ ..~ . . . . . . . . . . . . . . . . . . @.o•

@@@@@8@@. @@@@@8@@. .@@@8@8@ .@@8@@@8 --@ . . . . . . . . ~...


@@@@@@@@. ~#@@@@@8. • 8@@@8@@ .@@@8@@@ --@ . . . . . . . . @...
@@@@@@8@. @@@@@~8@. • @@@8~@@ .@888@@~ .-@ . . . . . . . . ~...
@@@@8~@@. 8@@@@8@@. 8@@@@@@ .@8@@@@@ ..8 . . . . . . . . ~...
@@@@@0@@. #@@@@0@@. • .@ . . . . . . . . 8...
@@@@@@0 .@@@@88@
888@@8@~. @8@@@@@@. @88@8@8 .@@@8@88 ..................
8~8@@@@@. @@8@@@#8. @8@@@@@ .@@@8@@@
@@@@@@@@. #@#@@088. @@8@@@@ .@8@@@@@ ..................
~@#@@@#. @@@@@@@@.
°•o . . . . . . . . o . . . . . .
@@8@@@8 .@@@@@@~ ..................
@@@@@@. .@@@8@@.
(a) (b) (c)

FIGURE 4. Resultsof thinning the character 'H' by the subiterations.

March 1984 Volume 27 Number 3 Communications of the ACM 237


Research Contributions

(c) P2*P4*P6 = 0 (1)


0 O-- 0 0 0 0 ~ 0 0
(d) P4*P6*P8 = 0 (2)
I I I I I
The solutions to the set of equations (1) and (2) are P4 0 i 1 1 1 1 1 1
= 0 or P6 = 0 or (P2 = 0 and Ps = 0). So the point P1, I 1 1 ; I
0 ,0 0 0 O. 0 ~ 0 0
which has been removed, might be an east or south
boundary point or a north-west corner point. Similarly,
it can be proved that the point P1 deleted in the second FIGURE 5. Preventin9 the deletion of endpoints.
subiteration might be a north-west boundary point or a
south-east corner point. For example, the results of
processing the character "H" by both subiterations are
shown in Figure 4(a) and 4(b). The points marked by
" . " have been removed. The final result is shown in
Figure 4(c). Start )
By condition (a), the endpoints of a skeleton line are
preserved. Also, condition (b) prevents the deletion of
those points that lie between the endpoints of a skele-
ton line, as shown in Figure 5. The iterations continue I C=O
until no more points can be removed.
A flowchart of the proposed thinning algorithm is
shown in Figure 6. Initially, the original picture is
Search M (satisfied
stored in matrix IT and a counter C is set to 0. The the conditions of the
result of the processed picture is stored in matrix IT. To first subiteration)
save m e m o r y space, only two matrices, IT and M, are
used in our computation.
Figures 7(a)-7(c) show the results obtained by our
l C = C+l, ifM(i,j) = 1

algorithm for a Chinese character "@," a letter "B,"


and a digital "moving body," respectively. Skeleton IT = IT - M
points are marked by "*," or "@," and all those points
that have been deleted in the thinning process are
marked by " - . "
Yes
The above algorithm yields very good results with
respect to both connectivity and contour noise immu-
nity. Furthermore, the conditions for searching those
points that should be deleted from the pattern are very
simple. In order to assess the performance of our algo-
rithm, we have chosen one given by Stefanelli and Ro-
senfeld [11] for comparison. Both algorithms were writ-
ten in FORTRAN, run on the same CDC Cyber 172 C=O
computer, and tested with the same digitized patterns.
The result shows that the execution time of our algo-
rithm is only 50 percent of the one given [11]. As can
be predicted, the execution time depends on the com- Search M (satisfied
plexity of the pattern and the thickness of the strokes: the conditions of the
0.505 CPU seconds for the Chinese character " ~ " 0.454 second subiteration)
C = C + 1, if M(i,j) = 1
CPU seconds for the letter "B" and 1.163 seconds for
the moving body.

IT = IT - M
TABLE I. Comparison of CPU Time (in seconds) Consumed by
Different Parallel Thinning Algorithms

Method Yes
Pattern
Four-Step Two-Step Our Algorithm

B 0.765 0.678 0.454


•~ 1.031 0.882 0.505
Movingbody 2.713 2.221 1.163
FIGURE 6. Flowchart of the thinning algorithm.

238 Communications of the ACM March 1984 Volume 27 Number 3


Research Contributions

. . • ~ . .

..,.--- ... ......


..... @ ........ @@..


.@ • .@. ° ...... ~2j,~
.@ • °@o • "" i ; . . . . . ~ .... ~
,i ....... ~i ..... ; ............ iii .@ °@° • .

.@ • °@° •

.@ • o@• • ~
.@ • •@o °
.@ • .@• •
222,1 ~.2.
.@ • .@@..
.@ ° • o@o °

.@ . . . . . . . . . @.
1,2 *,,;;'. .H,,,, ..... .@@@@@@@@@@@..
.@ . . . . . . . . . @@..
'~,2 • ottt .... .@. . .@@..
..,. .... . .............. .@. . .@...
.@. . .@..
~e . . . . . . . . . .
.@ . . . . @..
.@. . .@.. .* ........ "~;;22
.@. . .@..
.@. . .@... ..~...

.@. . .@@..
..... @.......... @@..
..@@@@@@@@@@@@@@@@..
oo• . . . . . . • . • • o ~ o o • ::~;::::
(a) (b) (c)

FIGURE 7. Thinning of different digital patterns.

4. S U M M A R Y 7. Rosenfeld, A. Connectivity in digital picture. J. ACM 17, 1 (Jan.


1971), 146-160.
A parallel algorithm for thinning different types of digi- 8. Rosenfeld, A. A characterization of parallel thinning algorithm. Info.
tal patterns is presented in this paper. Each iteration is Control 29 (Nov. 1975}, 286-291.
divided into two subiterations that remove the bound- 9. Rosenfeld, A. and Davis, L.S. A note on thinning• IEEE Trans. Syst.
Man Cybern. SMC-6, 3 (March 1976), 226-228.
ary and corner points of the digital patterns. After sev- 10. Rutovitz, D. Pattern Recognition. Proc. Royal Statists. Soc. 129, Series
eral iterations, only a skeleton of the pattern remains. A (1966), 504-530.
The proposed algorithm appears to be very efficient 11. Stefanelli, S. and Rosenfeld, A. Some parallel thinning algorithms for
digital picture• J. ACM 18 (April 1971), 255-264.
in the thinning of digital patterns and it compares fa- 12. Tamura, H. A comparison of line thinning algorithms from digital
vorably with those described in [11]. The results in geometry viewpoint. Proc. 4th Int. Conf. Pattern Recognition, 1978, pp.
715-719.
Table I indicate that our method is 1.5 to 2.3 times
faster than the four-step and two-step methods de- CR Categories and Subject Descriptors: 1.5.2 [Pattern Recognition[:
scribed in [11] while the resulting skeletons look very Design Methodology--pattern analysis; 1.5.4 [Pattern Recognition[: Ap-
much the same. plications-computer vision
General Terms: Algorithms, Theory, Applications
REFERENCES Additional Key Words and Phrases: parallel algorithm, thinning of
digital patterns, skeletonization
1. Arcelli, C., Cordelia, L.P. and Levialdi, S. From local maxima to
connected skeletons. IEEE Trans. Pattern Analysis and Machine Intell.
PAMI-3 (March 1981), 134-143. Received 3/83; accepted 9/83
2. Arcelli, C. A condition for digital points removal. Signal Processing 1,
4 (1979), 283-285.
3. Deutsch, E.S. Thinning algorithms on rectangular, hexagonal, and Authors' Present Addresses: T. Y• Zhang, Department of Computer Sci-
triangular arrays. Commun. ACM 15, 9 (Sept. 1972), 827-837. ence and Automatic Control, Chongqing University, Chongqing, China;
4. Hilditch, C.J. Linear skeletons from square cupboards. In: Machine C. Y. Suen, Department of Computer Science, Concordia University,
Intelligence IV, B. Mertzer and D. Michie, Eds., University Press, 1455 de Maisonneuve West, Montreal, Quebec H3G 1M8. Canada
Edinburgh, 1969, pp. 403-420.
5. Ogawa, H. and Tanguchi, K. Thinning and stroke segmentation for Permission to copy without fee all or part of this material is granted
handwritten Chinese character recognition. Pattern Recognition 15, 4 provided that the copies are not made or distributed for direct commer-
(1982), 299-308. cial advantage, the ACM copyright notice and the title of the publication
6. Pavlidis, T. A Flexible Parallel Thinning Algorithm. Proc. IEEE and its date appear, and notice is given that copying is by permission of
Comput. Soc. Conf. on Pattern Recognition and Image Processing. Aug. the Association for Computing Machinery. To copy otherwise, or to
1981, pp. 162-167. republish, requires a fee a n d / o r specific permission.

March 1984 Volume 27 Number 3 Communications of the A C M 230

You might also like