Pattern Recoflnition. Vol. 20, No. 3, pp. 273 •280, 1987. Printed in Great Britain.
0031-3203/87 $3.00+ .00 Pergamon Journals Ltd. )987 Pattern Recognition Society
CURVEDNESS OF A LINE PICTURE NOBORU BABAGUCHIand TSUNEHIROAIBARA .' Department of Electronics Engineering, Faculty of Engineering, Ehime University, Matsuyama, 790 Japan (Received 17 October 1985; in revised form 29 September 1986)
Abstract--The shape analysis of a binary picture is of great importance for pictorial pattern recognition. In this paper, we propose a useful geometric feature parameter called curvedness. Curvedness represents which lines are dominant in a binary picture, straight or curved. Our algorithm for measuring curvedness is based on the relationship between the distance to a boundary point on each black point along each quantized direction and the mean width of a binary picture. We investigate the fundamental property of curvedness. The experimental results for Japanese Hiragana and Kanji characters show the validity of curvedness. Binary picture processing Line picture Feature extraction Character recognition
Shape analysis
I. INTRODUCTION
Geometric feature
an effective feature parameter when classifying Kanji and Hiragana characters. In pictorial pattern measurement and recognition, it is By the way, geometric features which are conof great importance to analyze the shape of a binary cerned with curvature and angle will be unable to picture. We may roughly classify the shape analysis extract by means of a simple local operation such as a into two cases. One is to describe the shape of a picture neighbor search and a pointwise operation, as in itself, such as chain coding m and Fourier descrip- discussed by Rosenfeld et al. ~41and Bennett et al. ~51Also tor,~2j on account of data compression and in measuring curvedness, it is desirable to introduce a simplification of processing. The other is to numerize global or quasi-global operation. Our concern is then a geometric feature which a picture essentially with the distance to a boundary point on each black possesses, that is, the extraction of feature parameters point along each quantized direction. Based on the from an original picture. relationship between the distances and the mean width In this paper, we propose a useful geometric of a picture, the condition of each black point is feature parameter for a binary picture, called described. The characteristics of our method would be curvedness, and describe the algorithm for measuring specified as follows. (I) The algorithm is based on the curvedness. Curvedness represents which lines are features which can be easily extracted, (2) An original dominant in a binary picture, straight or curved. picture can be preserved. Most geometric features are, Classifying each point by determining whether it is in general, extracted after a thinning preprocesslocated on curved lines or not, we will measure ing. However, noises and distortions generated in the curvedness. thinning process prevent extracting various features Curvedness as a feature parameter will be applicable correctly. The proposed algorithm can do without a to character recognition. We Japanese have a large thinning process. Thus we analyze neither a thinned character set which consists of Kanji (Chinese picture nor a boundary of a picture representing the character; more than 2000 characters), Hiragana (46 row of points. This suggests the fundamental difference characters), Katakana (46 characters) and so on. The from other methods 4'-7) that are concerned with the usual style of Japanese sentences is a mixture of both curvedness and straightness of binary pictures. Kanji and Hiragana characters. From the viewpoint of geometrical structure, we can point out an interesting thing with respect to each character set. As shown in Fig. I, each Kanji has a complex structure and is ]~_ . . . . . KANJ[ composed mainly of straight lines, whereas each Hiragana has a simple structure and is composed |i~ " 9 l, ~ "C . . . . . HIRAGANA mainly of curved lines,q~ These are quite opposite features. Therefore, curvedness will be expected to be Fig. 1. Examples of Japanese Kanji and Hiragana characters.
/i~ ~
273
274
NOBORU BABAGUCH! and TSUNEHIRO AIBARA
Section 2 gives some definitions which are related to the proposed method. Section 3 describes the algorithm for measuring curvedness in detail. Some experimental results are shown in Section 4.
2. DEFINITIONS We now proceed to give a brief explanation on a binary picture. A binary picture F, which is represented as an array ofsize N x N, is a finite set of points (pixels) whose value is either 1 or 0. A point of its value to be I is especially called a black point. Each set of 8-connected black points is referred to as a black region or simply a reyion. A black point on the region boundary is called a boundary point. Let f(i,j), (i,j = 1..... N ) denote an element of a picture array, namely the value of a point ofcoordinate (i,j), where i,j represent the vertical axis and the horizontal axis, and f ( l , I) is the left-upper most point. In this paper, a line picture (henceforth abbreviated LP) is of particular interest and is used in the same manner as a line drawing which is a kind of binary picture. The attribute of LPs is that black points are concentrated in the region with some widths. Typical instances of LPs are binarized pictures of a character, a circuit diagram and so on. An LP will occasionally occur in the mid-stage of picture processing. Note that the width of an LP need not be i. Figure 2 shows the eight quantized directions and their corresponding codes m, (m = l . . . . . 8). The quantized direction is defined for every 45 °. The eight directions seem to be available for a rectangular array on account of its simplicity of treatment. Further, the opposite direction, for instance 45 ° and 135 °, may be identified and given the same code k, (k = 1. . . . . 4), which stands for the right-up diagonal, vertical, left-up diagonal and horizontal orientation in accordance with the ordered number. We call k and m the orientational ('ode and directional code, respectively. In Fig. 2, the orientational codes are depicted in parentheses.
3. ALGORITHMFOR MEASURINGCURVEDNESS In this section we describe the algorithm for measuring curvedness. What deserves our attention is as follows: it should be determined not by a local feature extraction, but by a global or quasi-global feature extraction, whether a black point is located on a curved line or not. Therefore, on each black point we measure the distance to a boundary point along each quantized direction so that we may describe the condition of a point by means of each distance and the mean width of an LP. Each distance will inform us of some geometric features, that is, the directionality of the point, the existence of feature point and so on. The algorithm is partitioned into four procedure steps. In what follows, we will use the positional vector r such that r = (i,j) to represent the position of a point.
Step 1. Measurement of distances We provide a point-cell P,(r) on each black point to store the number of points between a point of r to a boundary point along the direction corresponded to the directional code m. At first stage, we scan the picture array from a left-up point to a right-down one, that is, a TV raster scanning. We repeat the following procedure only on a black point, for m = 1. . . . . 4, If f ( r + r.) = 0, If~: f ( r + r,) :/: 0,
then P.,(r) = 0
then P,jr) -- P,(r + r,) (1)
where rl = ( - 1 , 1 ) , r2 -- ( - 1 , 0), r 3 = ( - l , - l ) and r4 = (0, - 1). Figure 3 indicates the vector representation of 8-neighbors. At second stage, we scan the array from a right-down point to a left-up one, that is, the inverse scanning of first stage, and repeat the same procedure of equation (1), for m = 5..... 8, where r5 = ( 1 , - 1 ) , r~ = (1,0), r7 = (1, 1) and rs = (0, 1). A pair of these procedures stores the number of points for eight directions in the point-cell. We define the directional distances d,(r), (m = 1. . . . . 8), as
V f2 P.(r), for m = 1,3,5,7 d,Jr) =
P,(r),
for m = 2, 4, 6, 8.
(2)
It is noted that the unit distance of neighboring points for diagonal directions is x/~. By summing the distance
2(2l
3~[~1
of opposite directions, we define the orientational
)
~j
4(4) :
/\
~ 8(4)
r3
(-i,-1) r4
(o,-i) 7(3)
5(I)
[
6(2) Fig. 2. The quantized directions.
r5
i(1,-I)
r2 (-I,
rI o)
r
(-i,
1)
r8
( i , j) ( o, I) r6
r7
( 1, o)i( 1, I)
Fig. 3. Vector representation of 8-neighbors.
275
Curvedness of a line picture
2w/2W, which is the maximum length within the overlapped region composed of the lines of width IV,, the threshold value should be greater than it. Then we settle on A = 2.8 which is approximately 2~//2.
D2
f
D3,
For n = 1, we call the point a uni-orientational point and the value f(r) of a black point is replaced by orientational codes as follows: .
b
f(r) = k, (k = 1. . . . . 4)
i'
where Ok(r) = max {Dl(r), O2(r), D3(r), D,(r) }.
{
Fig. 4. Illustration of orientational distances.
distances Dk(r), (k = 1. . . . . 4), as Ok(r) =
{ dk(r) + dk+4(r) + ,v/'2, dk(r)+dk+4(r)-t- 1,
for k = 1, 3 for k = 2,4.
(3)
Figure 4 illustrates the orientational distances. D~,...,D4 are the orientationai distances of a black point b.
The value of a point specifies the orientation of the region to which it belongs. For n = 2, 3, 4, we call the point a multi-orientational point and the value is replaced by 5, 6, 7, respectively. Accordingly, a black point is classified into seven classes and easily discriminated by its replaced value. In multi-orientational points, the points whose value is 5, that is n = 2, are of good significance. Next, we will detect the curve generating point (henceforth abbreviated CGP). Based on the directional distances d,~(r), we obtain the directional code m satisfying din(r)> A" W/2.
Step 2. Measurement of the mean width of an LP The mean width of an LP is introduced as a factor to describe the condition of black points. Yamada and Mori proposed a technique for measuring the mean width of a character pattern. (8) Since their method depends on the orientational distances conveniently, we can employ the same technique in our method. The width w(r) of a black point is defined as w(r) = min {Dl(r), D2(r), D3(r), D4(r)}.
5". w(r),
Nt, rEB
(5)
(7)
Let M be the number of codes which satisfy equation (7), then M varies from 2 to 4. For M = 2, 3, 4, the point belongs to a cornering, branching and crossing region, respectively. Now, C G P is to be regarded as a particular case of cornering points. Let m~, m2 denote the two directional codes which satisfy equation (7). We proceed to define CGP. C G P is a point which satisfies
(4)
The width of a black point is to be evaluated as the minimum value for all orientationai distances. In Fig. 4 the width of b is DI. The mean width Wof an LP is given by
w = !
(6)
/
and
M = 2
(8)
[ml - m21 -- 3 or 5.
(9)
Two lines from C G P make an angle of 135 '~. In other words, CG P will be the point where the direction of a line changes least. Figure 5 shows an example of classification of black points. The numbers indicate the value of points and C G P is represented by "#".
where B is a set of coordinates of all black points and N~ is the number of all black points in an array F.
Step 3. Classification of black points A black point is classified according to both the distances and the mean width. In this step, we first make use of the orientationai distances. We enumerate the number n of the orientation for which the distance is greater than some threshold value. Let the threshold value be A. W, where Wis the mean width of an LP and A is a constant value. The number n indicates how many lines for four orientations there exist on its point. What is now important is how to choose an appropriate value of A. Let us consider this problem in Fig. 4. D, and D3 do not reflect the global shape of the LP, butD, and D4 do. Using a small threshold value, we will determine that there is a line along the left-up orientation by enumerating D3. Apparently, this determination is inappropriate. Since D3 nearly equals
Step. 4 Discrimination between curved lines and straight lines The given results of the previou~ steps reveal that the value of each black point should be any number of 1. . . . . 8, where C G P is denoted by 8. The value of points represents its conditions. In this step, we begin to carry out the region labeling procedure. We need the region labeling because we want to treat each region consisting of points in the same condition. So we assign a distinct label to each region with the same value. After the region labeling procedure, we consider the relationship of connectedness among the labeled regions. Our purpose is then to seek out the regions which simultaneously satisfy the following two conditions: the region is composed of CGPs and the region is connected only to the region of uni-orientational points. Let R,.#p be a set of such regions as
276
NOgORU BABAGUCHIand TSUNEHIROAIBARA 444444 II:4444444 4444444444
'llllll, 22
444444444444444444444444444444444444444444
)444444444444444444444444444444444444444444554 ;5444444444444444444444444444444444444444444554
Fig. 5. Classification of black points. described above. Let R,.o, be a set of regions which are connected to R~gp. We define a set of points on curved lines denoted by Be as
B~ = R~gpu R¢or Other points in B are regarded as the points on lines in this case. Finally, we obtain curvedness C, that is,
(10)
straight
c ffi NJN~.
(11)
where No Nb are the number of points in Bc and B. Note that C ranges from 0 to 1, and that the closer to 1 the value C is, the more curved lines exist in an LP. Figure 6 shows the final result of our method. Points on curved lines and other points are denoted by "c" and "s", respectively. F r o m this LP, W (mean width) ffi 3.06, C (curvedness) = 0.42 are measured.
4. EXPERIMENTAL RESULTS AND DISCUSSION
Properties of curvedness We have first investigated the fundamental property of curvedness. Given a line, we would like to know the discriminant ability ofcurvedness. To what degree will curvedness be able to discriminate between a curved line and a straight line? As is well known, the curvature v of a continuous circle is v ffi ( l / r ) ,
(12)
where r is a radius of the circle. Equation (12) expresses
that the curvature of a circle is proportional to the reciprocal of its radius. No matter where a point is located on the circle, the curvature on its point is constant. As the radius of a circle becomes larger, its curvature is smaller, and vice versa. F r o m the preceding discussion we generate circles or arcs of various radii and fixed width w in a digital picture array of size 50 x 50. Now we proceed to describe how to generate circles. Denoting the value of points byf(i,j), the value of either 1 or 0 is assigned as follows: For
i,j -- 1..... 50
l f(ij) = 1 if (i - io)2 + (j --J0f g: r2 and
(1 3) (i -- io)2 + (j --jo) ~ ~ (r -- w)2 f(id) ffi 0 otherwise where io,jc, r are integers. Of course, equation (12) will not hold for digital circles. However, the size of radius would be associated with its curvature even for digital circles and arcs given by equation (13). So we could roughly investigate the property of curvedness through the generated pictures. In this experiment we generate, as an LP, a single circle or a single arc with fixed w(w = 3) in the picture array by varying/o, Jo and r as r < 25: 25 ~ r ~ 50: 50 < r.
(io,jo) = (25, 25): circle, (io,/0) = (0, 0): arc, fro,Jd = (50 - r, 50 - r): arc
and measure curvedness for each LP. Figure 7 shows the relationship between curvedness and radii of generated circles or arcs. Evidently, for
Curvedness of a line picture
277
)SSSCCCCCC :SSSCCCCCCCCCC SSSCCCCCCCCCCCCC SSS CCCCCCCCCC $ss cccccccc sss ccccccc 'SSS CCCCCCC
SSS
CCCCCC
sss sss sss sss SSS SSS SSS SSS SSS
cccccc ccccc ccccc CCCCC CCCCC CCCCC CCCCC CCCC CCCC CCCC CCCC CCCC CCCC CCC CCCC CCCC CCC CCCC CCC CCCC CCC CCCC CCC CCC CCC
SSS
SSS SSS SSS SSS SSS SSS SSS SSS SSS SSS SSS SSS SSS SSS SSS SSS SSS SSS SSS SSS SSS SSS SSS SSS SSS SSS sss
CCC
CCC CCC CCC CCC CCC CCC CCC CCC CCC CCC ccc
SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
Fig. 6. Discrimination between curved lines and straight lines. o u')
~o nL.)
oo ;
(510.00
3D. O0
m
50.00
.
70.00
,
gO. O0
RADIUS
":!ii:
Fig. 7. Curvedness vs radii of generated circles and arcs. . . .
r < 64, i.e. large curved lines, curvedness takes a high value, while for r > 64, i.e. almost straight lines, curvedness is low. Consequently each line whose radius is smaller than 64 is interpreted in a 50 x 50 array as a curved line by means of curvedness. The generated LP as a single arc of r = 64 is shown in Fig. 8.
Curvednessfor Kanji and Hiragana characters Since a character pattern is a good example of LPs, we have applied the proposed method for Japanese Hiragana and Kanji characters. As stated in Section 1, Hiragana characters are composed mainly of curved lines, while Kanji characters are mainly straight lines. The two sets are just right for testing our method. In Japan, the standard character data base, named ETLg, including Kanji and Hiragana, has evaluated various character recognition systems fairly well. The test samples are 956 distinct characters of 75 Hiragana characters and 881 Kanji characters which are
° . °
Fig. 8. A single arc of r (radius) = 64. supplied in ETL8 as specimen characters. A character pattern of samples is an array of size 64 × 64. We measured curvedness for each character in the two sets and calculated the mean, variance, maximum and minimum values of curvedness for each set. The measurement results are indicated in Table 1. In addition, the normalized histogram of curvedness for each set is shown in Fig. 9. Each frequency is normalized by the whole number of all samples. The rates of all samples whose value of curvedness is 0 are 9 and 63%, and whose value is within 0.1 are 27 and 86%, for Hiragana (75 samples) and Kanji (881 samples), respectively. Some actual results for Hiragana and Kanji characters are shown in Figs 10 and I1. In both figures, (a)-(c) represent an original picture, points on curved lines and other points. Values
278
NOBORU BABAGUCHIand TSUNEHIROAIBARA
[]
HIRAGANA
X
NAN J!
~ °0. O0
_ _ _.~-~ O. 20
O. 40
O. 60
CURVEDNESS
O. OO
1. O0
Fig. 9. Normalized histogram for Kanji and Hiragana. of curvedness of Fig. 10{a-I), (a-2), (a-3), Fig. 1 l(a- 1), (a-2), (a-3) are 0.34, 0.48, 0.70, 0.0, 0.16, 0.56, respectively. As observed in the figures, there are some mis-classified points. This results from the mismeasurement of distances of the points on a region boundary and a crossing (branching) region. In order to improve this algorithm for stroke extraction of character patterns, some modification will be needed. The experimental results reveal that curvedness
reflects what we want to measure, that is, the value of curvedness is proportional to the number of curved lines in the LP. It is worthy of note that not all Hiragana characters are composed of curved lines alone. Rather, it will be valid to say that though Hiragana is composed of both curved and straight lines, the proportion of curved lines in Hiragana is much greater than that in Kanji. Indeed Hiragana may be a curved LP, but has some exceptions. Consequently the experimental results obtained herein coincide with the fact that the curved lines are dominant in Hiragana, and the straight lines are dominant in Kanji. Therefore we can conclude that curvedness is regarded as one of the useful geometric feature parameters for a binary picture, as we have expected.
5. CONCLUDING REMARKS
In thispaper, we have proposed curvedness which is one of the useful geometric featuresfor a digitalbinary picture. The experimental resultsconfirm the validity of curvedness. Curvedness will evidently take a high value in case the LP is composed of curved lines.T w o
~iL~~'~,
J
(a-l)
(b-l)
(c-I)
(a-2)
(b-2)
(=-2)
)
>"
mn' (a-3)
(b-3)
Fig. 10. Actual results ~r Hiragana,
(c-3)
Curvedness of a line picture
279
H H
H N (a-l)
(b-l)
(C-1)
% _ = , iH, rg °-
m %- -
] (b-2)
(a-2)
(c-2) ~
"-
:...
l~
!!-i
13,
iii
:~,.-..~. . . . . . . . . . . . --ilil::l
,..:..,. . . .
--,~
|!| !
'ii
~
,m'ar
~,
....
ill
..-=
li~ii'i~i--.i~ili::r-
I
" ~ ~ . ~ '
(a-3)
(b-3)
."
~,'.
m~
(c-3)
Fig. 11. Actual results for Kanji. SUMMARY
Table 1. Measurement results Curvedness Mean Kanji Hiragana
0.057 0.327
Variance Maximum Minimum 0.009 0.044
0.632 0.941
0.0 0.0
points concerning this algorithm are worth while noting: firstly that this algorithm is based on the features which can be extracted with simple operations: secondly that an original picture can be preserved because no thinning preproccssing is required. We mention some problems which still remain to be explored. We will have to investigate more pre,ciscly the property of curvedness. In particular, the stability ofcurvedness in the same category should be analyzed. Next, it is interesting to apply curvedness to classifying Hiragana and Kanji characters in practice. However, we will probably not achieve a complete classification of Japanese characters by means of curvedness alone. Therefore we should take account of some other feature parameters which, for example, indicate the complexity of a character pattern.
The shape analysis of a binary picture is of great importance for pictorial pattern recognition. In this paper, we propose a useful geometric feature parameter, called curvedness, and describe the algorithm for measuring curvedness. We deal with a kind of binary picture, called a line picture (LP) that is used in the same manner as a line drawing. Most LPs are thought to be composed of both curved and straight lines. Curvedness represents which lines are dominant in an LP, straight or curved. The algorithm for measuring curvedness is summarized as the following four steps. (1) Measurement of distances: the quantized direction is defined for every 45 °. On each black point we measure the distance to a boundary point along each quantized direction. (2) Measurement of the mean width of an LP: based on the minimum distance on each black point, the mean width of an LP is measured. (3) Classification of black points: the condition of each point is described in terms of the distances for each direction and the mean width. (4) Discrimination between curved lines and straight lines: by investigating the relationship among the regions consisting of points in the same condition, it is decided whether a
280
NOBORUBABAGUCHIand TSUNEHIROAIBARA
point is on curved lines or straight lines. Finally, curvedness is defined as the ratio of the number of points on curved lines to that of all black points. The characteristic points of our algorithm would be as follows: (1) the algorithm is based on the features which can be extracted with simple operations, (2) an original picture can be preserved because no thinning preprocessing is required. We have clarified the fundamental property of curvedness, i.e. the discriminant ability for a single line which is either curved or straight. Moreover the experimental results for Japanese Kanji and Hiragana characters show that curvedness takes a high value for the LP composed mainly of curved lines. Acknowledyemems--The first author wishes to acknowledge
Professor Y. Tezuka and Associate Professor H. Sanada, Osaka University, for their continual encouragement. Special thanks are due to the members of Eleetrotechnical Laboratory, Japan, who edited the character data base. This work was supported in part by the Grant-in-Aid for scientific research from the Ministry of Education.
REFERENCES
I. H. Freeman, Computer processing of line drawing images, ACM Comput. Surt,. 6, 57-97 (1974). 2. C.T. Zahn and P.Z. Roskies, Fourier descriptors for plane closed curves, IEEE Trans. Comput. C-21, 269-281 (1972). 3. S. Mori, K. Yamamoto and M. Yasuda, Research on machine ,eco'gnition of handprinted characters, IEEE Trans. Pattern Anal. Mach. Intell. PAMI-6, 386-405 (1984). 4. A. Rosenfeld and E. Johnston, Angle detection on digital curves, IEEE Trans. Comput. C-22, 875-878 (1973). 5. J.R. Bennett and J.S. MacDonald, On the measurement of curvature in a quantized environment, IEEE Trans. Comput. C-24, 803-820 (1975). 6. C.E. Kim, Digital convexity, straightness, and convex polygons, IEEE Trans. Pattern Anal Mach. lntell.. PAMI-4, 618-626 (1982). 7. S.H.Y. Hung, On the straightness of digital arcs, IEEE Trans. Pattern Anal. Mach. lntell. PAMI-7, 203-215
11985). 8. H. Yamada and S. Mori, An analysis of handprinted character data base II, Bulletine of electrotech. Lab. 40, 513-529 (1976).
About the Author--NOBORU BABAGUCH!was born in Osaka, Japan, on 20 February 1957. He received the B.E., M.E. and Ph.D. degrees in Communication Engineering from Osaka University, Suita, Japan in 1979, 1981 and 1984, respectively. He joined Ehime University, Matsuyama, Japan in 1982 and is currently an Assistant Professor of Electronics Engineering. His research interests include pattern recognition, character recognition, digital picture processing and artificial intelligence. Dr. Babaguchi is a member oftbe Institute of Electronics and Communication Engineers of Japan, and the Information Processing Society of Japan. About the AuIhor--TSUNEHIROAIBAR^received the B.E. degree from Ehime University, M.S degree from Oregon State University and Ph.D. degree from Osaka University in 1955, 1968 and 1972, respectively. He is now Professor of the Dept. of Electronics Engineering, Ehime University. His current research interests include pattern recognition, digital image processing and artificial intelligence. Dr. Aibara is a member of the IECE of Japan, the IPS of Japan, the IEE of Japan and the IEEE.