High quality Chinese fonts generation for desktop publishing — a computer vision approach

High quality Chinese fonts generation for desktop publishing — a computer vision approach

Pattern Recognition Letters 9 (1989) 147 151 Norlh-Holland February 1989 High quality Chinesefonts generationfor desktop publishing- A computer visi...

325KB Sizes 0 Downloads 20 Views

Pattern Recognition Letters 9 (1989) 147 151 Norlh-Holland

February 1989

High quality Chinesefonts generationfor desktop publishing- A computer vision approach Y.S. MOON and W.K. H U I D~7~artment ~f Computer Science, The Chinese University ~["Hong Kong, Shatb~, Hong Kong Received 28 July 1988 Revised 8 November 1988

Ah,~wact: This paper introduces a method to generate high quality Chinese fonts for desktop publishing through tin automatic process. The main idea of this process is to employ a computer vision based method to convert a manual font library on paper into concise computer representations. The conversion process consists of 4 stages: image smoothing, boundary detection, corner detection and image regeneration. The algorithms, implementation and results are presented in the paper.

Key words' hnage processing, corner detection, font generation.

1. Background and objective Unlike alphabetic languages, ideograhic languages such as Chinese, Japanese have large character sets. Chinese, for example, has as character set consisting of as many as 25,000 characters, with each character representing single or multiple meanings. Even a reduced set of Chinese characters for practical daily uses requires about 6500 words [1]. C o m p u t e r output of these characters relies mostly on dot matrix printers employing dot matrices with sizes of 16 x 16, 24 × 24, 32 x 32 or 64 x 64 [2]. In the last few years, low cost laser printers become more affordable and so comes the DeskTop Publishing (DTP) technology. Compared to the dot matrix printers, laser printers have much better resolutions (300 dots per inch or even more). Such fine resolutions make the dot matrix representations of Chinese characters unsuitable for use on the laser printers because the dot matrices would produce characters that are too small. At a first sight, two solutions are possible: scale up the representation or use larger matrix size. Yet, the former method would introduce aliasing effects and the latter

method may require excessive computer storage for the characters. To solve the character representation problem, the method of font outline is considered. In this method, a character font is represented by the outlines of the character. Previous researchers have used straight line vectors to form the outline of a character [3]. Unfortunately, such a method is unable to represent the curves used in the characters. The effects, of course, are undesirable. The next possible way is Knuth's M E T A F O N T approach [4], [5]. In this approach, a font is generated by formal, mathematical descriptions of the outlines of the character using a computer program. Since the program is written before the font is actually created, we call the M E T A F O N T approach a 'forward' approach. Yet, this approach is not very feasible for Chinese as we cannot expect font designers, who are graphics designers rather than programmers, to write thousands of computer programs to implement the font libraries. In our approach, we make use of the existing font libraries available on paper. The paper fonts are scanned into a computer. Their edges are detected. Points on the edges with ~sudden" changes are re-

0167-8655/89/$3.50 ~' 1989, Elsevier Science Publishers B.V. (North-Holland)

147

Volume 9, Number 2

PATTERN RECOGNITION LETTERS

corded as control points. A representation of a font is, in fact, the collection of all control points generated for that font. By passing lines and curves through the control points, we can regenerate the characters. Moreover, by scaling the distances between the control points, we can enlarge or contract a font at will. In this way, fonts are represented independent of their sizes. Because our representations of the fonts are generated from font libraries which already exist on paper, our approach can be regarded as a 'backward' approach in contrast to the M E T A F O N T approach. Besides saving a lot of human labour, our approach is both efficient and reliable. In the subsequent sections, we will describe details of our work together with some demonstration of its results.

2. Methodology There are mainly five modules in our system. They are executed in sequence. Let us examine each module:

(a) Scanning module We use a scanner, an optical device which performs an operation like a photocopy machine, to scan the image of a font. The output is 'digitized image' stored in a file.

(b) Smoothing module The mean filter [6] is selected to smooth the image in our work. The reason for using this filter is its simplicity. Moreover, we also employ special constraints to filter the noise as well as imperfections of the font image after the use of the mean filter. The smoothing algorithm is shown below: (1) Assume frame l and frame2 both contain the original m x n image matrix. (2) F o r i = 2 t o m ldo(3) (3) F o r j = 2 t o n - l d o ( 4 ) & ( 5 ) (4) view (the value calculated by mean filter of location) 148

February 1989

= frame2(i - l j l) + frame2(i - 1j) + frame2(i - l j + 1) + frame 2(i,j - 1) + frame2(ij) + frame 2(ij + 1) + frame2(i + l j - 1) + frame2(i + l j) + frame2(i + l j + 1) (5) if view ~> 5, then frame2(ij) is a black point. else if view = 4, then if frame2(i,j)= 1 then frame2(ij) is a white point else if (view - frame2(ij - 1) + f r a m e l ( i j - 1)) = 4 then frame2(ij) is a black point. endif endif else frame2(ij) is a white point endif endif The smoothed image is stored in frame2 after this step.

(c) Edge detection module The complete outline of a Chinese character may consist of one or more boundaries of closed polygons. In this module, an edge detection technique is applied to the complete outline to get the boundaries. Since the scanned image is binary, very simple operators can be used. In our system, we have used the Laplacian operator [6]. The result of this module is one or more closed boundaries representing the outline of the character.

(d) Corner detection module In this module, the representations of the boundaries found in the previous module are compressed. The method we use is adopted from [7]. The idea is to fit a B-spline through all the points of each boundary detected. We then compute the displacement between each point and the B-spline. Points that have large displacements and high curvature are marked as corners and are treated as multiple control points, points between corners with high curvature are used as control points, the rest of the points are discarded. Using the notations in [7], the

Volume 9, N u m b e r 2

PATTERN RECOGNITION

LETTERS

February 1989

The equations are:

curvature of a point P~ can be computed as:

x =f(t)

curvature = cv = ,~clb2 - c2ba

= a~t~ + bl t2 + c , t + d 1,

y = g ( t ) = a2t3 + b 2 t 2 + c2 t + d ,

(C12 -]- C2) 3/2

where

where Xi - 2 Xi - 1 b 1 ..... q-

12

Xi

6

2

b2 = 3'! 7 2 + Yi - 1

12 cI =

2 1)

Yi

+

6

12

,

1)

2xi - 1

36

6,, . . . . .

36

9 +

+ Xi+l)/2,

Xi-I

l +4xi+xi+l)/6.

The coefficients a, to de are the same functions of

3. Implementation

12

The displacement 6 = (6x, by) between this point and the B-spline is

2

Cl = ( - -

y.

(Xi+ 2 - - X i - 2)

-[-

3

Yi

3xi+ 1 +.'ci+e)/6`

2 x i + Xi+ 1)/2`

12

(Xi+ l - - Xi

:

+ 3xi

bl = ( x i - l -

dl=(xi

12

(Yi+ 2 - - Y i - 2)

3 ('2 =

6

al = ( -- x i - 1

Xi + 2 -'F

Yi ._~ Yi + 1 _~_ Yi + 2

6

(Yi+I

Xi + 1 -I-

2yi

9

xi

2xi + 1

2 1

Yi

2

xi + 2

--9+

2yi + 1

9

36 Yi + 2

+ - -

36

At this point we have performed all necessary calculations, using the positions of the neighboring five points Pi z through Pi + 2. The condition for a given point Pi to be a corner is as follows: (a) the displacement 6 is larger than a given threshold 6c, (b) the curvature cv is larger than a given threshold c~, (c) the curvature c,. is a local maximum. If the curvature Cv is larger than a given threshold c~, it will be a control point only. All corners and control points are grouped to represent the original image.

The font to be input is available on an A-4 size sheet. The paper is scanned using a MSF300C scanner connected to an IBM PC/AT personal computer which controls the scanner. The image of a scanned font is first stored in the personal computer and then transferred through an Ethernet Network to a SUN-3/110 workstation for further processing. All programs for generating the control points are written in C with the assistance of the powerful SUN-3 windowing utility S U N V I E W . Finally, display of the regenerated font and printer output control are programmed using P O S T S C R I P T [8], a page description language commonly used for laser printing and available on the SUN-Ys NeWs system. In fact, the reason for using the SUN-3 workstation are twofold: (1) it is easier to develop large programs on the SUN-3 than on an IBM/PC which has 640k programmable memory, (2) the NeWs system which supports P O S T S C R I P T is very convenient to produce to W Y S I W Y G (What You See ls What You Get) effect as our output device, an A P P L E Laser Writer, supports POSTSCRIPT too.

(e) b n a g e b o u n d a r y r e g e n e r a t i o n m o d u l e

Using the control points we have chosen, we can regenerate the boundary of the original image. Although it is an approximation, the distance threshold limits the distortion introduced by the regeneration. The method we apply for boundary regeneration is also a B-spline method, as shown in [7].

4. Results We present 6 results in this paper, namely sample 1 to sample 6. Samples 1, 3, 6 are obtained using printed fonts as input to the scanner. The boundaries of these printed fonts are generally smooth. On the other hand, samples 2, 4, 5 are obtained using 149

ORIGINAL IMAGE

February 1989

PATTERN RECOGNITION LETTERS

Volume 9, Number 2

SMOOTHED IMAGE

BOUNDARY DECTED

BOUNDARY DETECTED

BOUNDARY REGENERATED

UNION OF TWO BOUNDARIES

Figure 5. Result of each stage of sample 5. /

CONTROLPOINTSDETECTED

BOUNDARY REGENERATED

UNION OF TWO BOUNDARJES BOUNDARY DETECTED

Figure I. Result of each stage of sample I.

BOUNDARY REGENERATED

UNION OF TWO BOUNDARIES

Figure 6. Result of each stage of sample 6. f/_

SMOOTHED IMAGE

ORIGINAL IMAGE

CONTROL POINTS DETECTED

BOUNDARY REGENERATED

BOUNDARY DETECTED

UNION OF TWO BOUNDARIES

Figure 2. Result of each stage of sample 2.

I, I

handwritten characters whose boundaries are more rugged. Intermediate results for the samples 1 and 2 are shown in Figures 1 and 2, respectively. The original boundary, the regenerated boundary and their union of each of the samples 3 to 6 are shown in Figure 3 to Figure 6. We find that the distortion of the images are acceptably small. The number of points required to represent the images for different threshold are shown in Table 1. According to the results in Table 1, we find that the average compression rate is 15.1 for the printed fonts and 7.7 for the handwritten characters. Since only printed fonts will be used as input to the scanner in practice, our results are acceptable.

I','

5. Conclusion

BOUNDARY DETECTED

BOUNDARY REGENERATED

UNION OF TWO BOUNDARIES

Figure 3. Result of each stage of sample 3.

BOUNDARY DETECTED

BOUNDARY REGENERATED

UNION OF TM#OBOUNDARIES

Figure 4. Result of each stage of sample 4. 150

When constructing a high quality Chinese font generation system, we have considered the following criteria: (a) High quality The shape of the regenerated image must not be distorted significantly with respect to the original image. (b) Size independence Fonts of different sizes can be easily generated by changing some parameters of the system. Distortion due to augmentation or reduction of the fonts should be acceptable.

Volume 9, N u m b e r 2

February 1989

P A T T E R N R E C O G N I T I O N LETTERS

Table 1 Concise results

Thresholds

Sample No.

Before compression

After compression

(points)

(points)

6544 1840 7255 3964 3634 1951

656 219 381 570 471 120

Comparession ratio

I

2 3 4 5 6

0.32 0.32 0.35 0.32 0.32 0.32

0.24 0.24 0.24 0.24 0.24 0.24

0.5 0.5 0.9 0.5 0.5 0.5

(c) Automatic operation The generation of fonts should be automatic with very little, if any, manual intervention. (d) Compact storage Since there are so many Chinese characters, each with different fonts, to store all of their representations in a computer can be a very serious problem. Minimization of the required storage leads to the application of data compression techniques for purposes of representation. Our initial results show that our backward approach for constructing Chinese font libraries using a computer vision method is feasible and reliable. It is feasible because the regenerated fonts show little distortions when compared with the original fonts and there are large savings of storage required for the representations of the fonts. Table 1 shows the compression ratios (usually larger than 10: 1) of the number of points required to represent the boundaries. In any event, we believe that the ratios can still be improved, especially when we review the control points distributions in Figures 1 and 2: too many control points are used to represent the slanting lines and curves. Currently, we are in the process of investigating the application of an artificial intelligence technique to further improve our results. Furthermore, we think that the operation of the system is not limited to Chinese fonts. Other kinds

9.98 8.40 19.04 6.95 7.71 16.25

of fonts, e.g. English fonts, Japanese fonts and other kinds of pictures are also possible candidates for our system. As shown in the result of sample 3 and sample 4, we find that the resulting images of these fonts preserve the 'taste' of this kind of Chinese fonts. Therefore, our work is suitable for the compression of these kind of fonts. Lastly, we are also investigating possibilities for applying our system to recognize Chinese signatures. References [1] Zhang, S.C., C.Y. Hsu and K.S. Zhang (1984). Fundamentals Of Chinese Language Computm~ (in Chinese), p. 65,

Shanghai. [2] Dot Matrix Set and Data Set o/Chinese Ideograms/or h~lormarion lnterchamze. National Standard Bureau, People's Republic of China. [3] Wang, X., Z. Lu, Z. Chen, Y. Tang and Y. Xiang (1984).

Augmentation and reduction for Chinese character images with high resolution (in Chinese). Chinese J. Computers 6, 418 426. [4] Knuth, D.E. (1979). TEX and METAFONT. Digital Press, Belford, MA. [5] Dong, Y.M. ( 1981 ). LCCD: A language for Chinese character design. &!/tware. Practice and Experience I I, 1273 1292. [6] Ballard, D.H. and C.M. Brown (1982). Computer Vision, Prentice Hall, Englewood Cliffs, NJ. [7] Medioni, G. and Y. Yasumoto (1987). Corner detection and curve representation using cubic B-splines, Computer Vision, Graphics and hnage Processing 39, 267 278. / 8 / A D O B E SYSTEMS I N C O R P O R A T E D (1985). POSTSCRIPT Langua~,,e Re/erence Manual. Addision-Wesley, Reading, MA.

151