0031-321)3,81~030225-11 S02.(X)/0 Pergamon Press Ltd, © 1981 Paltern Recognition Society
Pattern Re~oqnition VoL 13, No 3, pp. 225 235, 1981. Printed in Great Britain.
A THINNING ALGORITHM BASED ON PROMINENCE DETECTION CARLO ARCELtA and GABRIELLA SANNIT1 DI BAJA Istituto di Cibernetica del C.N.R., Arco Felice, Naples, Italy (Receited 7 May 1979; in revised form 10 March 1980; received Jbr publication 19 November 1980) Abstract --- Binary pictures are taken into account and an algorithm which transforms a digital figure into a set of 8-simple digital arcs and curves, by employing local sequential operations, il illustrated. The adopted procedure considers the removal of suitable contour elements of the given figure and it is repeated on every current set of 1-elements as long as the final thinned figure is obtained. The notion of local elengation is employed to find, at every step of the process, those contour regions which can be regarded as significant protrusions. Then such regions are detected before applying the removal operations, contributing hence to the isotropic behavior of the proposed thinning transformation. Further refinements of the algorithm are also discussed.
Binary pictures Elongated figures Thinning Significant protrusions deletion Crossing number Local sequential operations
Isotropic
However, we want to point out that the shape information which can be drawn from S and retained In digital picture processing, shape information has by T when only removal operations are taken into been extensively used both to reduce the a m o u n t of account may be rather poor. For instance, since no data to be processed and to solve problems of figure curvature-dependent operations are performed, it is description and classification. (1) In this frame,york, not possible to prevent the deletion of those contour one approach has been to think of a transformation by elements which are more significant from a perceptual which a figure is thinned down to a line drawing point of view, e.g. the so-called corner points/6"7~ without destroying shape information during the Essentially, what can be obtained is a stylized figure, process. The behavior of the numerous thinning consisting of the medial line of S, which only retains algorithms existing in the literature ~2-4~ can be scherelevant information about the original if this latter is a matically considered as originating a stylized version globally elongated figure. In the following we will refer of the original figure, which is composed of simple our arguments exclusively to figures of such a class. digital arcs and curves. 15~Generally, these components Our purpose is to present an algorithm which allows one to achieve a thinning transformation by making are spatially placed along the medial regions of the figure and their arrangement is such that the visual use of mainly sequential local operations. This choice effect produced meaningfully resembles the original is motivated by the fact that sequential computers are one. An example of this transformation can be found in widely employed to process pictorial data and that Fig. 1, where the set of elements resulting after thinning their performance can be improved, as has been shown, ~s~ if local operations are performed on picture is shown superimposed over the initial set. In this paper we will restrict ourselves to the case of elements taken in a definite sequence, by using at each step the results obtained from operating on the binary pictures on a square grid, as most authors have done, and, without losing generality, we will concern preceding elements of the sequence. Let us recall that one of the strategies which can be ourselves with only one figure, i.e. a connected set of lelements, regardless of its order of connectivity. Let S employed to balance the use of sequential local operations with the need to achieve a symmetrical represent the figure, S the background (i.e. the set of 0removal of the l-elements (which forces T to lie along elements) and T the transformed set. the medial region of S) is that of considering an Generally, T is obtained as the subset of S which iterative compression of S during which only the remains after the assignment to S of all those lelements whose removal does not cause any discon- contour elements of the current figure are examined nection or hole in S. Since T must retain some relevant and, if possible, deleted at every step. As for the information about the shape of S, it is desirable that the requirement that the structure of T be influenced by removal operations be applied simultaneously from all the elongated regions of the original figure, a widely directions, i.e., from North, East, South and West, so as followed approach has been that of preserving the end points, i.e. those 1-elements having only one other to originate an isotropic transformation. 1. I N T R O D U C T I O N
225
226
CAR~o ARCELLI and GABRIELLA SANNITI DI BAJA
::::::::::::::::::::::
z ,7...7..-:..:: ,z
:::::::::::::::::::::
.... .
==================================
-_::z.~::
::_-:~:r . . . . . . . 17:::::
.z:::~:::
:::;_-,-::
;:::::-::-
.::::
::~...z.:.::::
::::;::_,r-::::::
=========================
==========================
_ii~---.~-~i~iiig}i!_-........" ~i~_~ii. :ii.---:~i-=--~L-"~ii
:ii~i-:
_:'~:~-FF.
:_:.-E~'~
"::~?..~::E
--:"E__: :"?..:: : " .E ?.: : :
: :----':'~"--: :.~ .'.:"?.:": : :~
__:E:""
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Fig. 1. Results of thinning binary pictures. The transformed set is shown superimposedover the input figure.
element of S in their nearest neighborhood, from removal. In fact, some have thought that these points must be generated in a one-to-one correspondence with the significant protrusions of S. Once preserved, the end points become sources of the digital arcs constituting T, which in this way will be characterized by a structure reflecting to a large extent the original shape of S. Unfortunately, we note that most of the existing algorithms do not ensure that the previous correspondence always holds, so their performance is likely to become unacceptable when a wide repertory of figures is to be processed. In our opinion, this behavior is imputable to the fact that the removal occurs during a 'blind' sequential process, which may even cause end points to be originated according to the order in which the chosen sequence of operations is applied to the contour elements. In the next section, we discuss some difficulties which may arise during the use of the removal 9perations. In Section 3, we suggest a way of defining the significant protrusions, which ensures that thinning algorithms will show an isotropic behavior, even in the case of noisy contours. Then, in Section 4, we illustrate an algorithm which closely matches the parallel nature of the thinning transformation and discuss in detail some of the computations involved. Finally, in Section 5, we conclude by making some remarks on the performance of the proposed algorithm. 2.
END
POINT
sition. Otherwise it would not be clear which criterion of significance is adopted and the behavior of the related algorithm would be questionable. Unfortunately, this shortcoming occurs rather often, since it is deeply rooted Jn any sequential process which has to simulate a parallel one such as thinning. To overcome it, we think that the contour configurations which are assumed to be sufficiently significant to originate end points, should be identified at the beginning of every iteration of the figure compression before applying the removal operations. In the opposite case, the sequential way of examining and deleting would change the geometry of the neighborhood the contour elements are embedded in and may allow the creation of spurious end points. For instance, in Fig. 2 it is shown how the anisotropic performance of a sequential algorithm erases, by means of connectedness-preserving operations, the contour elements which are not end points. This example is rather trivial, but it is not too difficult to tailor other examples to more sophisticated algorithms, once the sequence in which the operations are applied is known. Furthermore, the same arguments hold for a wide class of parallel algorithms,19~namely those employing parallel operations involving only the nearest neighbors of every element. In this case, each iteration is
DETECTION
In the past, most authors have centered their attention on proving that the removal operations they proposed did not alter the connectedness of S and of S, while as regards the elongated regions, their algorithms were only asked to be able to detect the end points whenever they were generated. However, since the validity of a thinning transformation is strictly dependent on the amount of perceptual significance the transformed figure still retains, we note that the first requirement to be satisfied should be that an end point is always, or never, detected in correspondence of the same contour configuration, whichever its po-
0
o
o
0
o
o
0
o
o
•
~o
o~ o 0
o 0
0
•
Fig. 2. Anisotropic performance of a standard sequential algorithm which removes, from top left to bottom right, the contour elements (circled).The dotted elements are retained, being either end points or necessary to preserve figure connectedness.
A thinning algorithm based on prominence detection performed by applying a sequence of four parallel processes, every one of which refers to the 1elements having respectively one 0-element as neighbor in the North, East, South and West direction. Also in this case, the sequentiality of the global process alters, within each iteration, the geometry of the contour and, as can be seen in Fig. 3, it remains questionable, after the deletion has been performed, whether the small protrusions were significant or not. Some researchers have tried to overcome these ambiguities by applying suitable cleaning operations either before or after thinning. In the first casd ~°~ they smooth the original figure by removing contour
I_ll
,, OlOl
I~ t•
I
I1[11 11 I I ~ ] ] I]ll~ II IIIl~ II
I
IIIJ
IOl [ [ [Ol I
I
II II ilill
!
I111 II[lilli illllLII / lilll
I I ] [
/~LIIIIIII
I I I 711 ! H!! Ill I ,I IIII W
configurations having a negligible size, while in the second case ~11~ they delete from the thinned figure those arcs which have not been generated according to some criterion fixed a priori. Recently, an alternative techniqud 12~ has been proposed in which the deletion operations are executed on every actual contour according to a carefully chosen order. In this way no spurious end points are generated and the need to perform either pre- or post-processing is avoided. However, in the present paper we want to deal with a more flexible definition of end points. This, besides excluding the influence of the contour noise on the structure of the final figure, allows one to establish case by case, depending only on the problem domain, what has to be accepted as significant protrusion. For this purpose, in the following section we will make use of the notion of local elongation. 3. SIGNIFICANI PROTRUSIONS
I1~ Illl|l LI I[IlIlI |[ ]
U-'I
[
ooHi I ,,,,It
227
| lol
lot I I
I I I I I I II
I Ioi
I I
I II[
LiiiiLiii Illll
I
~lll
I!!,,!H!
Fig. 3. Four steps of an algorithm which deletes concentrically circled elements from North, East, South and West directions respectively. Dotted elements are not removed since they are either end points or if deleted would disconnect the figure• The last figure shows the anisotropy of the transformation.
Let us recall some definitions. As is well known, (~3~ to deal correctly with binary digital pictures on a square grid two metrics must be chosen for S and S. Specifically the 4-distance do and the 8-distance d8 are considered, respectively given by d4(si4, Sh.k) = l i - h I + IJ - kl ;da(Si.j, Sh.k) = m a x ( ] / -- h l , l j - kl) , where sio and Sh.k are any two picture elements. The elements s~0, sh. k are 4(8)-adjacent, or 4(8)-neighboring, if their 4(8)-distance is unitary. The set of elements 4(8)-adjacent to s~4 is called the 4(8)-neighborhood of s~4. A 4(8)-path is a sequence of 4(8)-adjacent elements. A set of elements is 4(8)-connected if for every pair of its elements a 4(8)-path connecting them exists, all made by elements of the set itself. We note that, since we are concerned with a thinning transformation, it is convenient to choose 8-connectedness for the set of 1elements so as to obtain a subset T made by a minimum number of elements. The set C of the elements of S with at least one element of S in their 8neighborhood will constitute the contour ofS ; C is a 4connected curve. The set K = S - C will be called the core of S. In the literature, the notion of elongation has been introduced in connection with the shrinking operation and it has been used as a global feature) 2~ If n is the number of shrinking steps necessary to cause the vanishing of the set S with area A, then such a set is called elongated if A ~> 10n 2. Although such a definition is generally accepted, it is worthwhile to remember that this measure of elongation is unreliable if n is small. As for the notion of local elongation, we recall that all the connected subsets of the contour which are not adjacent to the core K may be considered as elongated regions, i.e., protrusions, of S. Nevertheless, to avoid the detection of both very weak convexities and digitization noise, it seems convenient to us to retain as significant protrusions (also called prominences, from now on) only those subsets of the contour which bear a distance d 8 >~ L from the core, where the value of L is at least 3.
228
CARLO ARCELLI and GABRIELLA SANNITI DI BAJA
With regard to thinning, we mentioned in the element, we suppose that the binary picture is borprevious section that, due to the uncertainty of the dered by rows and columns made by 0-elements. correspondence prominence/end point, it is sometimes To detect the prominences, it is first necessary to find difficult to obtain a structure for T which is mean- the core Ki. By definition, all the elements of Si having ingfully representative of the shape of S. To achieve no elements of S~ in their 8-neighborhood belong to this aim, our approach is to preserve the prominences this set. If we assign the label (L + 1) to the elements of from removal, instead of the end points. In this way, K , then it is possible, by using a distance transforthe distortion of the contour geometry occurring mation, ¢~ to identify the prominences as the connected during every step of the sequential removal process sets of elements labelled 1. More precisely, the elements does not alter the shape information and the resulting belonging to Pi are labelled 1, while the remaining set T is certain to have arcs in correspondence with contour elements are attributed labels ranging from 2 every significant protrusion of S. to L by executing a forward scanning (from top left to Furthermore, besides ruling out the effects of the bottom right) employing the local sequential operdigitization noise, we gain the possibility of identifying ation fl : the prominence~ with a definition which depends on fl(sh,k) = 0 if Sh,k = 0 the context (i.e., on the distance from the core) and which can be tailored on the requirements of the class f l(S~.k) = max(Sh,k, S h - l , k - 1 -- 1 , S n - l . k -- 1, of figures to be analysed. S h - l , k + l -- 1, Sh.k-1 -- l), Let us briefly describe the operations we want to if Sh,k:~ 0. perform on the set S. Initially, the elements belonging to the prominences are detected and marked, then all and then a backward scanning (from bottom right to the remaining contour elements whose deletion does top left) employing the local sequential operation fz not alter the connectedness of both S and S are sequentially removed. These two phases are repeated f2(sh.k) = 0 if Sh. ~ = 0 until a set with an empty core is obtained. Then this set f 2(Sh.k) = m a x ( s h . k , Sh.k+ l -- I, Sh+ l , k + l -- 1, is reduced to the 8-connected set T, having unitary S h + l , k - - 1, s h + l , ~ - i - 1), thickness everywhere. Due to the modification of the if Sh,k ~[=O. set of 1-elements (0-elements) during the compression process, it is convenient to identify the current set with In Fig. 5, the effects of applying these operations are a subindex i. Moreover, Ki and P~ will respectively shown referred to the input figure previously conindicate the core and the set of elements belonging to sidered in Fig. 4. According to the theory developed in the prominences of the current S~; Bi will indicate the Rosenfeld and Pfaltz, ¢8) it can be shown that every set of contour elements joining every connected comelement Sh,k of Ci bearing a distance d s ~< (L - 1) from ponent of P~ with K~, while S o and So will be the initial K i is given a label equal to [L - ds(Sh,k, Ki) + l]. sets. To help in the following description, the sets of These elements can then be removed from Si and elements involved in the transformation at any step i ascribed to S~ provided that they are not necessary to are shown in Fig. 4, where, for the sake of simplicity, ensure connectedness between the prominences the value L = 3 has been chosen. and K~. Generally, the notion of crossing number can pro4. THE ALGORITHM fitably help in finding suitable deletion rules. The crossing number C N of Sh,k, means the number of We will first illustrate some of the local sequential crossings from a 0(1)-element to a 1(0)-element occuroperations to be employed in our alg~,rithm.'Note that ring in the 8-neighborhood OfSh,k when taking a 4-path to allow the operations to be performed on every around it, starting from any 8-adjacent element and going back to the initial position. If C N # O, half its
r~ ~K~
E~
0
0
0
0
0
0
0
0
0
o
0
0
0
0
0
0
0
0
0
o o
[]
[]
eBi
£Pi
Fig. 4. Only the elements belonging to Kj, B~and P~ are not removed at step i.
3133333333
33-T~-~ 4 4 4 ~-
~2.
44443 3444443 13444443 3 3 3 3 ~ 3 4 ~-
Fig. 5. Labeling of St in the case of L = 3.
A thinning algorithm based on prominence detection value represents the number of 4-connected components of 0-element contained in the 8-neighborhood of sh. k and the fact that such a number of components does not vary when s,.k is removed constitutes the required condition for deletion of Sh.k. TO be more explicit, we recall (12) that Sh.k can never be erased when CN = 0 or C N = 8 ; when CN = 2, deletion becomes possible, but only if Sh.k is 4-adhacent to Si. In the remaining cases (CN = 4, 6) Sh.k can be removed if the following conditions respectively hold:
229
Fig. 7. Maximum width of a prominence.
1. N - W . ( 1 - N W ) + N ' E ' ( 1 - N E ) + S'E.(1
- SE)+ S.W'(1
- SW)= 1
2. N + E + S + W = 3 , where the symbols N, NE, E , . . . , N W indicate the state of the neighbors of Sh.k placed in the north, north-east, east,..., north-west positions. For the sake of clarity, in Fig. 6 the previous conditions may be checked against some typical configurations. If we now resume our thinning procedure, we note that it is not necessary to perform all the possible removal operations. On the contrary, it is sufficient to consider only the simple operation pertaining to the CN = 2 case. In fact, since the prominences must be retained and their structure only seldom coincides with that of an 8-simple digital arc (e.g., the prominence with maximal width is shown in Fig. 7), we would be anyway obliged to perform a final removal after the set with empty core S~- has been reached. Therefore, we can speed up the deletion process within every iteration and accomplish the complete removal of all the remaining deletable elements only at the final stage, which leads to the desired set T. As for the number of scannings of the whole binary picture necessary to delete the elemenls Sh,k such that ds(sh.k, Ki) ~< L 1 = L - 1, it is easy to verify that the upper bound is given by 2L 1 if a forward scanning is performed and that this number may be drastically reduced if a backward scanning (alternately) is also
0 0 0
CN=2
CN=4
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
@ @ 0
@ @ 0
@ @ @
0 @ @
0 @ @
0 0 0
CN:6
00
considered. On the other hand, it is difficult to estinaate the amount of possible reduction, since this is strictly dependent on the geometry of the contour configurations to be erased, so that while it is convenient to employ alternate forward and backward scannings, it is advisable to stop the process as soon as no elements are deleted, instead of making it run as far as the upper bound. Finally, let us describe the operations we will use to reduce the set S / w i t h empty core to the 8-connected set T in which no further elements can be deleted unless by breaking its connectedness or removing the end points. In order that a well-shaped T be extracted from Sy, it should be placed along the medial region of Sy; this forces us to devise a procedure able to remove the peripheral elements of Sz. These elements are identified within one scanning by assigning to every element Sh,k of S s a label eh.k (the value of which depends on the number of 4-neighbors in S s : eh.k = [2(W + N) + E + S + 1]) and by considering the elements which have at least one 8-neighbor with a label greater than their own. Such non-maxima are then sequentially removed within a subsequent scanning provided that disconnections do not occur. The advantage of this procedure is twofold : it gives to T a shape largely independent of the noisy contour of S I (see Fig. 8) and it allows easy handling of most of the branches of S j- which are two elements thick. With reference to Fig. 9, we can see that only one of the diagonally oriented branches [Fig. 9(d)] is unaffected by the removal of the non-maxima, while all the other types are reduced to 8-simple arcs. As regards the deletion rules, a good shape for T is obtained by
il@
•
•
@
O
@
0
0
•
0
0
@
@
Fig. 6. Configurations, referring to the cases CN = 2, 4, 6, in which the central element can be removed (left side) or not (right side).
Fig. 8. Elements belonging to sets with empty core are sequentially removed, unless they are assigned a locally maximal label or are necessary to ensure connectedness (circled elements).
230
CARLO ARCELLI and GABRIELLA SANNITI DI BAJA
I341 i.
I
C'
I
I
I
Fig. 9. The starred elements, being assigned maximal labels, are preserved during the phase of the peripheral element removal.
applying the operations concerned with the cases CN = 2 and CN = 4, while preserving the sh,k having both CN = 4 and more than two 4-neighbors from removal. If we now consider the thickest configuration which can be found in Sf, (see Fig. 7) it is easy to see that, after having applied the previous operations, the 4-connected parts still remaining in Sf are nowhere more than two elements thick. Therefore the desired final structure can be achieved by taking into account the following deletion rule,n 2) which is tailored to destroy 4-connectedness in favour of 8-connectedness without involving the notion of crossing number. Any element Sh.k, 4-adjacent to the background, can be deleted whenever at least one of the following conditions is verified : (a) E . S . ( N + W - N W + 1)/> 1
(b) W . S . ( N + E - N E + (c) N . W - ( E + S - S E + (d) N . E . ( W + S - S W +
1)~> 1 1)/> 1 1)>/1.
The effects on two typical configurations of the operation implementing this rule can be seen in Fig. 10. In summary, three complete scannings of the picture are employed to pass from Sf to T. The aforementioned operations allow accomplishment of the thinning transformation we have outlined in the previous section. 0
0
0
0
0
t
Q
Q 0
0
Q
0
0
•
OQ
0
0
Fig. 10. The central element can be removed (a) or not (b), depending on the rule given in the text.
In detail, the whole process can be followed by referring to Fig. 11, where L --- 3 is chosen and the elements removed step by step are represented by dashes. The figures 1l(a)-I l(f) show the elements actually belonging to P~ and K~ as elements labelled 1 and 4, respectively. Moreover, the elements ensuring connectedness between P~ and Ki, i.e., belonging to Bi, are labeled 2 and 3. In Fig. ll(a), the contour elements of So, which do not belong either to Po or to Bo, are dashed. Each subsequent figure should be interpreted as follows. The labelled elements are the outcome, in terms of elements of Kz, Pi and B~, of applying the operations of core finding, prominence detection and contour element removal to the set of labelled elements belonging to the preceding figure. The elements removed at every step, by applying the operation pertaining to the CN = 2 case, are dashed and are shown together with those already removed at the previous steps. The dashed elements are retained for illustrative purposes so as to originate a background shaped like So, against which the transformed figure is printed to show the isotropy of the transformation. At the sixth processing step a set with an empty core is obtained, [see Fig. 1l(f)] so that Sj. = S 6, Then only three steps are necessary to obtain the set T. During the first step the elements of Sf are assigned a label depending on the type of configuration in which they are embedded [see Fig. ll(g)], then removal of the elements with non-locally maximal labels is accomplished, [-see Fig. ll(h)]. Finally, the elements superfluous from the point of view of preserving 8-connectedness are deleted and the thinned version of So is obtained [see Fig. ll(i)]. Summarizing the contents of this section, the algorithm we propose can be described as follows. 1. 2. 3. 4. 5. 6. 7. 8. 9.
i=0. Detect K i. If Ki = ~ , go to 9. Detect Pi. Remove the contour elements not belonging to Pi w Bi. Let Si+l = P i u B i w K i . i = i + 1. Go to 2. Transform St into an 8-connected set T with unitary thickness and stop the program.
5. DISCUSSION AND CONCLUSIONS
Following the indications outlined in the introduction, we have tried to devise a thinning algorithm which can be regarded as satisfactory both from the computational and from the perceptual point of view. With respect to the first point, advantage has been taken of the use of sequential local operations performed both in forward and backward manner, so that, for instance, in some cases the labelling of the contour elements not belonging to the prominences can be
A thinning algorithm based on prominence detection
------4
23
--
-
4
----
44
44
4
--4444~--~ - 44 ~44 ~ 4 4
44"~4 44 ~ ~4 4 ~'~4"~
44~
44 44
.~44.~ 4 44 4 4~
4',~
44
'4
d4.+l
.
.
.
-- 4 4 4 4 4 444 4 .4
Z------
4 4
~
++,14
4~
4 d 4 4
44
4 d .4 44
~
-= 4-4 ~ - -
~
44
~ 4 ~ 4 ~444d444n----
--44~4----
---- , 4 4 4 44
--~
4
----
.
.
.
n44
.
.
-
~
--4 .
.
44 4
4
4
4
44
. . . . . . . . . . . .
44------
4
4
44
4---. .
.
.
.
.
.
.
.
.
.
.
. . . . . . . .
4
. . . .
----4
4~----
--4--
.~ 4
.
.
.
.
.
.
.
.
.
.
.
. .
.
.
.
.
.
.
.
.
,:-.
.
-s
.
,--.
4
.
s
4 4 n 4
4
.
.
.
.
~t----
:II:
.
1
-Is-
s
~
,
,
. . . . . . . . . . . . .
4~,,~4
.
s--
2 4
.
-is-
. . . .• . . . . . . . . . . . . .
44
.
11sx-
.
.
. . . .
.
. . . .
1
.
....
3 4
----S*~
.
z__,,,,.
. - - ~ I * i
.
.
--~--
-z~ll~Tz
- - I s * . . . . . * .
* ~ ---
.
~.~ 44 4 4 4 .4 4 ~ - -
44
444'~
--4 44 ~ 4 4 4 d4 ~ 4 4 ~4
- 4'~4 . .
.
4
. . . . .
44
--4 444
.
--4'4---4
~ --
•~ 4
---
4
.~w~.,*--
. . . . .
~----
S
:::::::::::::::::::::::
~44,,o.~
4 4 4 4 ~ 4 ~ 4 4 4 4 ~ ' ~ . . . . 4 . . . . . . . . . . . . . . . . .
. . . . . . . .
. . . . .1. . . . . . . . . . . . . i--. . . . .s . . . . . . . . . . . . . . . *. .
. . . . .~ . . . . . . . . . . . . . . . Z .
.
. .
.
.
.
.
.
.
.
.
.
. .
.
.
.
.
.
.
.
. .
.
.
.
.
.
.
. '.
.
s*
.
.
.
.
.
.
s . . . . . . . .
- - * i ~ *
-~
s * . . . . . . . . . . . . . . . .s . .
....
.
.
. .
.
.
.. . ... . ...
.
.
:E)YE: .
.
.
;t~s
. . . . .
i s - -
f) ~ 6 4 4 3 4 4 ,4 - - s 6 - - - 4 4 4 . . . . 4 . . . . 4 ~ - - 4 . . . . 4 - - - 4 - - - 4
. . . .
4-----.~- - s . . . . _ _ ~ _ _ _ - - - 6 . .
- - . . . . . .
. . . .
. . . .
.
.
.
.
. . . . .
. .
.
~4msm64~4 - 4 - -
. .
.
4 4
4
4
:~
- - - - 4
.
. .
.
.
.
.
. .
- .
m-
. s 6 64 4 - ~__
- - 4 . . . . . - - 4 . . . . - - 4 . . . . . . . . . . . . . . . . . . . . . . .
m - - mm • - - - m . . •
4 4 4 . . . . . . . . . . . . . . . !m . . ) z
. . . .
=e 4
mmmmmmmmlgmmm m.m-•
aS
~
~S
I
.
.
.
.
.
.
.
.
46----~ 4 . . = ;-.~SS6~I . . . . . . . . . .
.
.
.
.
.
.
.
.
. .
.
.
.
m • •
m
.4 4 m-
.
.
.
.
.
.
.
I--
4; "~
. . . . . . . . . . . . . . . . . . . . . .
S~ . . . . . SSS3
- . . . . .
• m •
•
•
m-•
- - - m
m-. . . . . m-m
•
--4--
g)
m-m
m
2
:
s
.
.
4 3
2
.
.
2
m 4 - -
.
.
• •
4
.
.
m
3
~ ~ a 4 4 1 4 4 1 ~ e s s m ~
m• - - m .
• •
]
.
--
. . . .
~
4 . . . . . . . . . . . . . . . . .
3
. .
.
m-m'----mm m-
2
. . . . ~. . . . . . . . . . . . . . . .
. .
4 4
3 2 = :~ . . . . . . . . . . . . . . . . . . . . . . m ~ ~m~m~s~s-J . . . . . ~ . . . . . ss ~ e ~ 6 6 ~ a m . . . . . 4 . . . . . ] 1 . . . .
. . . .
_ .
h') Fig. 11. Running example taken into account in the text.
i)
m .
.
.
.
.
.
.
232
CARLO ARCELLI a n d GABRIELLA SANNIT1 DI BAJA
performed within two scannings, whichever the value of L. As for the removal of these elements, we note that since connectedness between the core and the prominences must be ensured, it cannot be performed in one single scanning. However, the total number of scannings needed is difficult to estimate, since this depends not only on the geometry of the particular configuration to be erased, but also on the type (forward and/or backward) of scanning to be employed and on the power of the deleting operations used. Let us denote the number of scannings required to perform the labelling and removal within every iteration by the symbol m. Then, since one scanning is necessary to find the core, the overall number of scannings to be employed when w is the number of iterations necessary to obtain the set SI, amounts to (m + 1)w + 3. The power of a deleting operation can be increased by taking into account the possibility of removing all the deletable elements with C N = 2, 4, 6. However, to avoid the generation of a set Sy with a very awkward shape, it is convenient to disregard those deletable elements for which either C N = 6 or C N = 4 and more than two 4-adjacent neighbors are present. In fact, in the examples shown in Figs 1, 11, 13 and 14, this course was adopted, and a value of 3 was used for the threshold. For this minimum value of L, which originates transformed figures useful in most cases considered up to now in the literature, only one forward and one backward scanning are necessary, respectively, to detect the prominences and remove all the deletable elements (i.e., m = 4) so that the overall number of scannings to accomplish the whole process is 5w + 3. As regards the perceptual significance of the transformation, in our opinion this is achieved thanks to the isotropic detection of the prominences and to the introduction of the adjustable threshold L. In the first case, the contour configurations are detected in a parallel fashion, so that whatever their position on S i, the same configurations always (or never) give rise to the same digital arcs of T. In the second case, it is possible to avoid the generation of arcs in correspondence with both contour noise and regions which have a negligible size with respect to the global figure.
[; _+ _+ ~1_+ + 2 _ +
14+
+
+
[
+!+
i
r
distance dE = L and dE = Lx/2 from it. This fact can be overcome by employing a metric (e.g. the octagonal metric), which better approximates the Euclidean one. Nevertheless, we note that in this case the methods for
4. ÷ + '+ +
FZ5
In contrast to the definition of end points, widely used in other algorithms, the definition of prominence is context-dependent, allowing enhancement of the perceptual significance of the transformed figure. This purpose can be even better served if the value of L, initially determined in accordance with the requirements of the problem domain, is changed during the process, hence establishing a stronger connection between the property of elongation and that of sharp convexity. For instance, ifa fixed value of L is taken, it happens that arcs of T are equally generated in correspondence with both smooth and sharp convexities (refer to Fig. 12, where L = 3 is chosen). Conversely, by increasing the value of L as long as successive contours are considered, it becomes possible to rule out contour configurations assumed a priori to be less significant. Since the process of removing successive contours can also be interpreted as a propagation of the background over the figure, the example in Fig. 12 illustrates how the choice of the metric, employed in the definition of the contour, influences the shape of the configurations which are generated step by step on Si. Other choices could have been to define the contour either as an 8-curve, considering a propagation according to the d4, or as a 4-curve at the even steps and as an 8-curve at the odd steps, envisaging a propagation according to the octagonal metric3 ~) However, the different effect that each of these propagations of the background has on the modification of the contour geometry suggests that the appropriate choice should be made after carefully estimating the features of the task at hand. Another refinement of the algorithm could be made with regard to the prominence definition, so as to achieve a closer agreement with the perceptual intuition. As we mentioned, a prominence is any connected subset of the contour whose elements bear a distance d8 ~> L from the core. Then, it happens that we are compelled to take as equidistant from the core even the elements having, respectively, a Euclidean
'÷+ + + +
+ +
+
+ 4-+ +
4-
•
4-+
~" I+ 4- + +
4- +
+
+
..]
*
II
Fig. 12. C•ntinu•usanddashed•inesindicatetheb•rders•fsuccessivec•res.Thecr•ssede•ementsrepresent the initial contour, while the dotted elements identify prominences, L = 3, detected in correspondence with differently sharp convex regions of the original figure.
A thinning algorithm based on prominence detection generation of an octagonal propagation (~4) of the core over the contour may introduce an additional amount of computation which, for many applications, constitutes a more serious drawback than the aforementioned anisotropy in the prominence detection. A further remark concerns the fact that, when passing from S s to T, the lengths of the arcs are reduced by one element. This shortening could partly be avoided by also considering the end point condition within that phase; however, since this test does not affect arcs more than one element thick, we accepted an equal reduction for all types of arc. We think, however, that this arc length modification can be regarded as irrelevant in the majority of cases. One issue which should be raised before concluding this paper concerns noisy figures, i.e. figures possessing either protrusions or intrusions, holes included, whose size has to be considered non-significant with respect to the main features of the class of figures to be examined. While our algorithm allows successful management of the protrusions by introducing the prominences as those contour regions having a certain distance L from the core (see Fig. 13 for a further example) we did not mention any approach to handle the intrusions.
m +
+1+
+-4-~mmmmmm~++ ++++++ml+ + + ~ + + + + + + m + + mm ++ El ++
+
m + ++ m ++ + ÷m + + ~ + m + ÷ ~ + m + + +m + + + + +
+++
In fact, we must assume that some preprocessing has been performed on our figures before applying the thinning algorithm, otherwise the transformed set could lose most of its descriptive power. In particular, as pointed out in a recent review paper, "~ the presence of small holes strongly influences this undesirable behavior. Generally, techniques based on shrinking and reexpansion (see for instance chapter 9 of Rosenfeld and Kak (2)) allow origination of a satisfactory input figure. However, one could also devise a more complete way of removing intrusions by introducing a measure of relevance, having a role analogous to that of L in the case of protrusions. Although we did not directly consider this specific problem, it might be a topic for further research regarding the thinning of noisy figures. Due to the variety of applications in which thinning can be usefully employed, it is objectively difficult, if not impossible, to design an algorithm which satisfies all the possible requirements about the properties the transformed figure should possess. In this paper, our purpose has been to present an algorithm which, besides being relatively simple as regards to the involved computation and being characterized by the
~ + + + + + + +
++
+ + ÷ + + ~ I + ++ + + + + + m+ +++ ++ + ++~ ~ I + ++*
+ + + • * + + + + + * + + * +++ I + + + ~ + , I m m m m m m m m m m m + ÷ + + + + + ÷ + + + + + + ÷ ÷ + ÷ + + + ~ + ~ +
÷-~l+'+
+ +~+
++
÷ ~ + + + + + + + + ++ + + ++ + ~ + ~ + + + + ~ + ++ + ~ + -+++++ +~+ + + - ~+- - ~ + + + + + ÷+ + + ~
I + * + + + * + + + + + + + + * + ~ I i i I i I I I ~ I I ~ l ~ + ~ + + + ~ + + + + + ÷ + + + + + + + ÷ + + + + + + + +
+
233
+ + + + + +
+
++
+
+-~+ + + + + ++ + ~ -~+-*-+-~-+
* "1-÷ + ÷+÷ + •4-",- ÷ + + + ++ + ++ ÷ ÷ + + ÷ ÷+ + + + + + + + ÷ + + + + + +++ +~+ ÷ ~ + + ÷ + +
m + * ÷ I÷-~--*÷ + + • +++ + ++ ~ + + m m m l
+-I- * ~ + ~ * + * ÷-t--*--~ ÷ + -*- + + ~ - + ~ + ÷ ~ ÷ + + + ~ + +÷+ + + + ~ + ~ + ÷ + ++÷ ++ + + ÷ + + + + + + ÷ + + ~ ÷ + + ÷ ~ ÷ + + + + + ÷ + ~ + + + + + ÷ ÷ ÷ + + + + + + + + ~ ÷ + ~ + + ÷ + i m m m m m + ÷ + + + + ÷ +
++ + + + ~++ + - ~ - + + ~ + + + ÷ + + ÷ ,4. + ~ + + ÷ + ~ + ~ + + + + . 4 - + + ~ + + + + + ÷ + + + + + + + + + ÷ + ~ + ÷ + + + + ÷ + + + ~ - ¢ - ÷ + ~ + - ~ - + + - ¢ - + + + + + ~ + + ~ - + + ~ . + + + + + + + ~ ÷ + + + + + ÷ + + + + + ÷ + ÷ ~ + ÷ ÷ + + + + ÷ ÷ - 1 - ~ + ++ + + ÷ + + + + + ~ + + + + + + + ÷ + ++ + + ~ + + + ÷ + + + ÷ + ~ + + + + + ÷ + + ~ ÷ + ~++ + ÷ + ~ + + + ~ + + + + ÷ ÷ + ÷ ÷ ÷ + +
3~L~4
5~
-*-i-÷ ..t-IIl~lllI~
L~< 11
÷
+
-*-+-+
I m ÷+ m ++ m ++ ÷ ++ + ÷ m+ + ÷÷ i ++÷ -+..4- + ~ -¢-++-1--~1+ ÷ i-~÷-~--~+ + +÷ +÷ + + m÷ +÷+ + + -~ ++ ~ ÷ + + ÷÷ + + + + + ÷ + + + + + + I +++ +÷-~- +++ +÷
+++
+ + ~ - - 1 - -1--¢-~- ~ ~ ~÷ + -*--~- ÷ + + ~ ÷+ + ÷~ ÷-*--*- +~+ ÷
+ ÷ + ~ ÷ + + + + + + + ÷ +++ ÷ + + + + + + + ~ + -(- + + + +~+ -~- + + + + + + - * ÷ m + + + + + + + + + + + ~--~- + ~ + + + + + + + + + ~ -~-*-+ +~ -~++ ++ -~- +÷+ + +÷ mmmmmmmmmm .,.+ .~. ~ + + + + ~ + + -~ + + + + + ~ ÷ + + + + + ~ + +
+ + ÷ ÷ + + + + ÷÷ ÷ + + + + +++
÷ ++÷ ÷÷ ~ + + ÷ ~ + + + + + ~ + + + +
+ + ++ ~ .~ ++ ÷ + ~ + + + .~- + + ÷ + + + + ÷ + ~ + ~+ + +~+ ÷ + ÷ + + ++ + ~++ ÷ + ~-+÷ +÷+
12~
k ~
17
÷ + ÷+ + + + +
+ + +÷ + ÷ + +
÷++ + l m m ~ + + + + ÷ + + + + + + ÷ + + + ÷ ÷ + + + ÷ + + + + + + ÷ + + ÷ + + + + + + + ~ + + ÷ + + + ÷ ~ + + + + + ++~ ÷ + ÷ ÷ + + ÷ ÷ -~.÷ + ~ + + ÷ ~ + + ~ + + + + + ~ ÷ + ÷ ~ + + + ÷ + ÷ ~ ++ + ~ + + + + + +
m m i i m m m ÷ + + + + ÷ ÷ + ÷ + + + ~ + + + + + + ÷ + ~ ÷ ÷ + ÷ ~ + + ÷ ÷ + + ÷ + + ÷ + ÷ + ~ + + + + + ÷ ~ + + + ÷ + ~ ÷ + + ~ + + + + ÷ + + + ~ + + + + + + + + + + + + + ~ + + + + + + + + + + + ÷ + + + + + + + + + + ÷ + + + ~ + +
L ~18
Fig. 13. Transformed sets, obtained in correspondence with four different ranges of values of L, are shown superimposed over the initial figure. When the value of L is sufficiently increased, the number of protrusions of the initial set which can be regarded as significant, decreases. In this example three prominences are detected when 3 ~< L~< 4, two when 5 ~< L~< ll, onewhen 12 ~< L~< 17, none when L~> 18.
÷ + + + + + + +
234
CARLO ARCELLI a n d GABRIELLA SANNIT* DI BAJA
possibility of achieving an isotropic transformation, is also sufficiently flexible to be adequately modified so as to satisfy the needs of a specific task. The algorithm is tailored to work on elongated figures and its use is convenient whenever problems of figure generalization, in which a unique prototype has to be assigned to a whole set of slightly different figures, are to be faced. Conversely, if non-elongated figures are considered, the information content of T may be rather poor and it is better to take into account a different type of algorithm in which the geometry of the original contour plays a more discriminant role. (15'~6) The outcome of these algorithms, which we call skeletonization, is that the sources originating the digital arcs which constitute T are not only the prominences, but also some suitable elements placed on those contour arcs thought to be meaningfully convex on the basis of considerations which depend on the problem domain. In Fig. 14 the results of applying thinning and skeletonizingt*6) to the same input figure are shown and the different dependence of the algorithms on the property of contour convexity is apparent. Furthermore, let us consider a reverse distance transformation (s~in which to every element th.k of the transformed set is associated an 8-neighborhood with radius r = [ds(th.k, So) -- 1], and let us take the elements belonging to the union of all the neighborhoods as the reconstructed figure. The difference between the initial figure and the figure so recovered by starting from T (see Fig. 15) is another way to evaluate how much of S is lost, i.e. cannot be recovered, when describing S by means of the set T obtained by performing thinning instead of skeletonizing. In conclusion, the transformed set T obtained by thinning is not influenced by the peripheral nonelongated regions of S, and thus, if the initial figure needs to be recovered, it can be obtained only as a smoothed version. As mentioned above, this type of insensitiveness is quite desirable in any task of figure generalization. SUMMARY Thinning is a transformation widely used in digital picture processing, especially when elongated figures are at hand. In this paper, we consider binary pictures digitized according to the square tessellation and illustrate an algorithm which, by means of local sequential operations, allows one to obtain from any figure S, i.e., a connected set of 1-elements, a connected set T, one element thick throughout. Structurally, T can be described as a union of 8-simple digital arcs and curves. From a perceptual point of view, the shape of T should represcnta stylized version of S; therefore, whcn sequentially operating on the picture, attention must be paid, that the compression of S be performed symmetrically and that all the significant protrusions give their contribution to the shape of T. W e achieve this goal by considcring an iterative procedure which removes stcp by step some suitable contour elements
+=÷
•
+++÷++•+÷++++ +++++•+++++
+÷+++m++÷++
NNBHDHWmI••I•
--~+n+++
++++m++++
++÷+m÷÷~+ +++++•+++'+ ++ +++•++÷÷++
+++++m++÷+÷ n•im•m•omnpHm
++•++
+
+
~m
+--m+--
+++÷
+~+++++
+÷+÷~
÷
+++m+÷÷++
+++u~++
++m÷÷ m
Fig. 14. Transformed sets obtained when thinning (left side) and skeletonizing (right side) are performed.
from the actual set of 1-elements. Specifically, we pass from a set S~ to the successive set S~+ 1 by erasing from S~ those contour elements which neither identify significant protrusions (i.e., prominences) nor originate disconnections or holes in S~. As regards this last type of element, it is recognized by testing whether conditions involving the notion of Crossing number are satisfied. Contrary to the parallel case, where, for instance, vanishing of components may take place, no problems arise when removal operations are sequentially performed. As for the elements which should mark the prominences, they are usually identified with the end points, i.e., contour elements having only one element of S~ in their nearest neighborhood. However, this choice, widely followed in the literature, is not sufficiently context dependent to avoid, for instance,
÷~ I
m
÷mJnHlnigIl~ -~-,~lmiilamn,.,--I. ÷,.i~.'.4-illR~*+
÷~linngli~ -e-UmllJii~
innmnm aNNUm iilmn•imimm ÷•ummmmm~ ~+mmmmmmm~ •. , - - ~ m m m i m m m ~ ÷ ÷ ~+Nlmmmimg+
+mmnmmmi+ mgmummm mmmmm mmmmmnm +mmummmm+ ~nmmmmnn÷~
+~mnmim+++ ~ g m m m m m ~ + ÷mmmmmmm+ mmmmmm mmmmm mmmmmm
+mu•m•mm+
+~Nnmum~+ ~+mmmmmmmmm-,,--~+ ++lmmmmmmmmm~÷ +mmmmmmm+ mmmmmmm
+~+~+
=
mmlUll innaJmmBg | i i | l | l l R l l l l H l | | l H
Nlllmmmgnmn l l l l m l l l • n m i
gnmn•ingmn nmginmm mmmmm mnmmmmm mm•mmmmmm mmmmmmmmmmm
mmgmiwmuiumN a m m m m m n n mmnmmmmuu mmmmmmm BNBNI mmmmmmm mnmmmmnmm ummmmnmummm nmmmm•mmmmmmm mmmmmmmmmm• mmmmmmmmm mmmmmmm mmmmm mmmmmmm mim•mmmm•m mmmmmmmm••m •m•mummmmmmmm immmmmmm•nm mmmmmmmmm mmmmmmm minm•
Fig. 15. Figures recovered starting from the transformed sets shown in Fig. 14. When thinning is applied, the recovered figure may not coincide with the initial one (left side).
A thinning algorithm based on prominence detection that contour noise be sometimes mistaken for a prominence. Moreover, from an operational point of view, certain contour configurations may even originate end points according to the position they occupy on the contour. Since this anisotropy of the transformation is likely to strongly reduce the use of the obtained T, we disregard the end point detection and follow the approach of defining the contour regions which should be considered as prominences at every iteration, before performing the removal operations. Such regions are determined by adopting a criterion based on the notion of local elongation as well as on the requirements of the specific problem domain. In this way, the parallel nature of the thinning transformation is meaningfully enhanced and its typical purpose, i.e., to assign a c o m m o n prototype to a class of figures slightly different, can be regarded as widely satisfied. Since one of the aims of this paper is also to give an algorithm convenient from a computational point of view, the number of complete scannings of the picture required to accomplish every stage of the process is examined in relation to the different working hypotheses. Moreover, the implications of further refinements of the algorithm are discussed. A running example and some printouts showing the performance of the algorithm on the alphanumerics are included.
Acknowledgements - The help of Mrs. Marcella Izzo in preparing the manuscript is gratefully acknowledged, as is the assistance of Mr. Umberto Cascini and Mr. Salvatore Piantedosi in providing the illustrations.
235
REFERENCES
1. T. Pavlidis, A review of algorithms for shape analysis, Comput. Graphics Image Process. 7, 243-258 (1978). 2. A. Rosenfeld and A. C, Kak, Digital Picture Processing. Academic Press, New York (1976). 3. T. Pavlidis, Structural Pattern Recognition. Springer, Berlin (1977). 4. H. Tamura, A comparison of line thinning algorithms from digital geometry viewpoint. Proc. 4th Int. Joint Conf. Pattern Recognition, pp. 715 719, Kyoto, Japan (1978). 5. A. Rosenfeld, Arcs and curves in digital pictures, J. A.~s. comput. Mach. 20, 81-87, January (1973). 6. H. Freeman and L. S. Davis, A corner-finding algorithm for chain-coded curves, IEEE Trans. Comput. 26, 297-303 (1977). 7. L. S. Davis, Understanding shape: angles and sides. IEEE Trans. Comput. 26, 236 242 {1977). 8. A. Rosenfeld and J. L. Pfaltz, Sequential operations in digital picture processing, d. Ass. comput. Mach. 13, 471 494 (1966). 9. A. Rosenfeld, A characterization of parallel thinning algorithms, Inf. Control 29, 286-291 (1975). 10. C. J. Hilditch, Linear skeletons from square cupboards, Machine Intelligence, B. Meltzer and D. Michie, eds, Vol. IV, pp. 403-420. Edinburgh University Press. Edinburgh (1969). 11. A. Rosenfeld and L. S. Davis, A note on thinning, IEEE Trans. Syst., Man Cybernet. 6, 226 228 t1976). 12. C. Arcelli and G. Sanniti di Baja, On the sequential approach to medial line transformation, IEEE Trans. Syst., Man Cybernet. 8, 139-144 (1978). 13. A. Rosenfeld, Connectivity in digital pictures. J Ass. eomput. Mach. 17, 146 160 (1970). 14. A. Rosenfeld and J. L. Pfaltz, Distance functions on digital pictures, Pattern Recognition 1, 33 61 (19681. 15. H. Blum and R. N. Nagel, Shape description using weighted symmetric axis features, Pattern Recognition 10, 167 180 (1978). 16. C. Arcelli, L. P. Cordelia and S. Levialdi, From local maxima to connected skeletons. Preprint, Laboratorio di Cibernetica del C.N.R., Arco Felice, Naples (1979).
CARLOARCELLIwas born in Bologna, Italy, on 6 August 1941. He received the doctoral degree in physics from the University of Bologna, Bologna, in 1969. Since 1970 he has been working at the Istituto di Cibernetica of the National Research Council, Arco Felice, Naples, where he has done research in the field of picture processing. His current interest is shape analysis and description. About the Author -
About the Author GAaRIELLASANNm DI BAJAwas born near Naples, Italy, on 29 January 1950. She received the doctoral degree in physics from the University of Naples, Naples in 1973. During 1974 she joined the teaching staff of a professional institute in Naples. In the same year she obtained a research fellowship from the Istituto di Cibernetica of the Italian National Research Council, Arco Felice, Naples. Her main research activities have been carried on in the field of picture processing. Presently she is involved in a research program concerned with the study of medial line transformations as well as their use for image description purposes.