Académique Documents
Professionnel Documents
Culture Documents
IEEE TRANSACTIONS ON PATTERN ANALYSIS AND MACHINE INTELLIGENCE, VOL. PAMI-8, NO. 2, MARCH 1986
Correspondence
square can be doubled compared to that of Freeman's chain code
without changing the maximum quantization error. This makes
longer chain segments available for encoding line drawings.
Furthermore, a specific labeling rule of quantization points is
TOSHI MINAMI AND KATSUYUKI SHINOHARA
adopted. As a result of this labeling, some codes occur more frequently than other remainder codes and Huffman coding can be
Abstract-The multiple grid(MG) chain code which uses four differ- applied to reduce the encoding bits.
In this correspondence, the coding algorithm of the MG chain
ent square grids is proposed to encode line drawings. The main processes adopted in the code are: 1) a grid selection algorithm which al- code is first described and then its performance is investigated by
locates quantization points only to the vicinity of the course of a line the encoding results of straight lines, circles, and contour maps. It
drawing, 2) labeling rule on quantization points which makes the fre- is proved that the coding efficiency of the MG chain code is about
quency of some codes larger than that of other codes, and 3) quanti- 60-70 percent better than that of the standard chain code. And it is
zation points allocation-not to the corners, but to the sides of a square also found that the subjective quality of the regenerated line drawwhich makes the straight line segments larger without increasing quan- ings by this algorithm is excellent. Finally, simulation results on the
tization error. A performance comparison of various chain codes is application of this coding algorithm to the electronic blackboard are
made from the viewpoints of the encoding efficiency, naturalness of the described. Here again, the superiority of the MG chain code to
encoded lines, and the rate distortion measure. Also, the superiority of other chain codes is proved.
the MG chain code to other codes is shown. At last, application of the
II. THE ENCODING ALGORITHM
MG chain code to the electronic blackboard system is explained.
In the algorithm to be described here, four different grids of horand vertical lines Go, GI, G2, and G3, whose centers are
izontal
Index Terms-Computer graphics, electronic blackboard, geometric
from each other by 2T, are used for quantization of
separated
quanticode,
chain
grid
multiple
encoding,
drawing
line
probability,
The side length of a unit square (fineness) of each
line
drawings.
zation error, rate distortion theory.
grid is 4T. The four square grids are represented by line vectors as
follows:
I. INTRODUCTION
Line vector
Grid
Cordinates of the
To encode line drawings such as contour maps, computer graphorigin
ics, engineering drawings, etc., Freeman's chain code and many
x=0 y=O
(0, 0)
other derived chain codes have been proposed [1]- [12].
x = 2T y = O
(1, 0)
A newly developed coding method described here is quite difx=0 y=2T
1)
(0,
ferent from these chain codes and is shown to be excellent in codx = 2T y = 2T
(1, 1).
ing efficiency and naturalness of regenerated line drawings [13]. In
the conventional chain code, a certain grid is prepared and a line
Each side of a square is divided into two equal length segments
drawing is superimposed on it, and the nearest nodes of the grid to and centers of the segments are used as positions for quantization
the line drawing are selected as quantization points. In these meth- points. A line drawing crossing the square is approximated by a
ods, tracking of line drawings is limited by the grid.
straight line connecting two quantization points. The quantization
On the contrary, in the multiple grid chain code or MG chain point on a segment where the line drawing enters to the square is
code described here, four different grids are prepared for quanti- labeled as "0." The center of the next segment on the same side is
zation, and by selecting the most appropriate grid for each quanti- labeled as "1" and other centers are labeled from 2 to 7 in due
zation, quite efficient encoding can be realized.
order as shown in Fig. 1.
That is to say, by this selection, direction of a line drawing is
To encode a line drawing, a square grid Go is superimposed on
predicted and the next quantization points are placed in the vicinity it and one of unit squares, on which the line drawing is crossing,
of the course of the line drawing. In general, high coding efficiency is selected as the square for quantization of the line drawing. By
can be achieved by approximating high curvature parts of line draw- the x and y coordinates of quantization points corresponding to the
ings with shorter straight line segments and low curvature parts of entrance of a line to the square, the starting point of the encoded
line drawings with longer straight line segments. In Freeman's chain line is determined. Then, by the label of the segment where the
code with fineness 2T, only two straight line units with the length line drawing exits from the unit square, the first chain code is obof 2T and 2 2T are used independently of curvatures.
tained. And again, by this label, a square which is used for the next
In the MG chain code, quantization points are taken on the sides quantization is selected, as shown in Fig. 2. The second square is
of a unit square and lengths of straight line units are quite diversi- selected in a way to make the next link as long as possible. The
fied: V2T, 2T, -/T, 4T, 3,12T, and 2v[T, under the condition selecting rule is tabulated as follows.
that the maximum error of the regenerated line drawings is the same
1) Case of the quantization point "0" on a vertical line
as the error of the regenerated line drawings by Freeman's chain
Present
of the exit
Label
code with a fineness of 2T. The variety of the straight line units in
+ Modification = Next Grid
Grid
point
quantization
efficiency
for
the
encoding
high
the MG chain code is one reason
+
(i, j)2
0
(i,j])
of this code.
(0, 0)
+
1
In this code, quantization points are allocated not to the corners,
1)
(i,j + 1)
(0,
(i, j)
+
(0, 0)
2
but to the sides of a square. By this allocation, the side length of a
(i, j)
(i, j)
+
0)
(1,
3
(i,
(i + 1,j)
j)
Manuscript received October 10, 1984; revised July 15, 1985. Recom
4
(i,
(i,j + 1)
(0,
1)
j)
mended for acceptance by Y. T. Chien.
The authors are with the Department of Electronic Engineering, Kogakuin University, Tokyo, 160, Japan.
IEEE Log Number 8405365.
'i, j
I or O.
IEEE TRANSACTIONS ON PATTERN ANALYSIS AND MACHINE INTELLIGENCE, VOL. PAMI-8. NO. 2, MARCH 1986
270
76
MG Chain Code;
4
2T |
7443563344345633
44T
4
(a)
6
232
7.
s2
O/
24 iI
3 2
4
2
-4-,_--
(d)
External Cover
Internal Cover
(c)
5
57
54
(b)
-i 1
24
234
5
5
0
5
77
square.
unit
on a
6
4
2 3
(h)
(e)
(f)
(g)
Fig. 2. Selection of a square for the next quantization.
5
+
(i, j)
(0, 0)
(i, j)
6
+
=(i + vj)
(i,j)
(1, 0)
7
+
(i,j)
(0,0)
(i,j)
2) Case of the quantization point "0" on a horizontal line
Label of the exit
quantization
Present Grid + Modification = Next Grid
point
+
0
(i,j)
(0,0)
=(i,j)
+
I
(i,j)
(1,0)
=(i+ 1,j)
+
2
(i,j)
(0,0)
(i,j)
3
+
(0, 1)
=(i + 1,j)
(i,j)
+
4
-(i+ 1,j)
(i,j)
(0,1)
+
- (i,j)
5
(i,j)
(0,0)
+
6
(i,j)
(0, 1)
(i,i+ 1)
+
7
(i,J)
(0,0)
=(i,j)
An example of a line drawing and the corresponding encoded
line is shown in Fig. 3. A numeral in a small circle indicates the
grid number.
The maximum error between the actual crossing point and the
quantization point is T, and this value corresponds to the error in
the encoded line by Freeman's chain code with a square of a side
length 2T. The length of a unit in a horizontal or vertical straight
line generated in Freeman's chain code is 2T and that of a diagonal
line is 2V2T. On the other hand, the lengths of units in straight
lines connecting two quantization points in the MG chain code are
12T, 2T, Vi76T, 47T, 3 liT, and 25Tas shown in Fig. 1. The difference between the average length of straight line generated by the
MG chain code and Freeman's chain code is one reason for the fact
that the number of required bits per unit curve length of the MG
chain code is smaller than those of Freeman's chain code.
In the MG chain code, codes 3, 4, and 5 are generated more
frequently than codes 0, 1, 2, 6, and 7 and Huffman coding can be
applied to reduce the redundancy effectively. The probability of each
code occurrence is investigated theoretically and experimentally.
To calculate the probability, the geometric probability theory is used
[15]. According to the geometric probability theory, the probability
or the measure of straight lines crossing areas A and B in Fig. 4 is
obtained by the difference between the internal cover and external
Fig. 5. Difference between the internal cover and external cover of dX and
A.
cover of convex areas A and B. This theory can be applied to calculate the measure dM of straight lines crossing the segment A,
segment B, and the infinitesimal division dx in Fig. 5 as follows.
6T-x
1(6T -X)2 + (6)2-
(1)
2T
(-
8T7- x
CI(8T-x)2
=
0.2405.
(6T)2
6Tx
)
1(67' -X)2 + (6T)2d
(2)
271
IEEE TRANSACTIONS ON PATTERN ANALYSIS AND MACHINE INTELLIGENCE, VOL. PAMI-8, NO. 2, MARCH 1986
Sii
So
S25
S24
S23
S22
P:
PNo POI
=
So
and
TABLE I
TRANSITION PROBABILITY MATRIX P
P07
Plo
(4)
0
P77
..
P70
For all the combination of segments, Mi1's, pij's, and P are calculated by (1)-(4). Along with this theoretical investigation, by encoding the map of the northern island of Japan with the use of MG
chain code, the probability of each code occurrence is obtained experimentally. Both results are shown in Table I. In the theoretical
investigation, it is assumed that line drawings are nearly straight
within two unit squares. This is a main cause for the slight difference between the theoretical result and the experimental result.
A state transition diagram corresponding to the experimental result in Table I is shown in Fig. 7. In the figure, each state shows
the quantized position of line drawings encoded by the MG chain
code, and the diagram is a simple Markov process representation
of the quantized line drawing. The stationary probability P of each
state in Fig. 7 or the occurring probability of each code is obtained
by the following equations:
(5)
UO Ul
P-
Uo
*--
UO
Ul
U7
U7
Ul
...
(6)
0.222
0.111
0.222
0.444
0.250
0.250
0.375
0.125
0.013
0.013
0.160
0.240
0.293
0.133
0.067
0.080
0.020
0.010
0.214
0.316
0.306
0.051
0.031
0.051
0.015
0.008
0.115
0.231
0.362
0.192
0.054
0.023
0.011
0.032
0.053
0.191
0.489
0.106
0.117
0.062
0.065
0.032
0.258
0.258
2
3
0
0
0.258
0.097
0.032
0.749 0.251 0
0.195 0.524
0.181
0
0
0
0
0.304
0
0.239 0.522 0.083 0.156
0
0.251 0.529 0.220 0
0
0.315 0.254 0.126 0
(a)
'j
0.281 0
0.502
0.317
(b)
(a) Experimental probability
(b) Theoretical probability
U7
E Uj
i =l
(7)
are
TABLE II
HUFFMAN CODE
calMG
Chain
Code
Huffman Code
10
01
00
0.196
110
0.286
1110
U5
0.199
11111
U6
0.067
111101
111100
ul
0.017
U2
0.157
U3
U4
U7
0. 064.
(8)
2)7 2
IEEE TRANSACTIONS ON PATTERN ANALYSIS AND MACHINE INTELLIGENCE, VOL. PAMI-8, NO. 2, MARCH 1986
>-
2L
(a)
41
MG Chain Coding
lul/45-1OO=35.6b
17/45%100=37.8-
20/45 1 0=44.-
28/60X1OO= 46.7'
3121
2
1 D X33
(b)
2C
1 8-3 = 54bi t I
I o
(c)
2
1 9/
54i
00=35.2%
MG Chain Coding
ol gLj!a
6TF1-
ooQLO!t1
a
I}I
121F-I
(d)
Finally, the Huffman code corresponding to the ui's in (8) is obtained as shown in Table II.
III. PERFORMANCE OF THE MG CHAIN CODE
chain code, Freeman's chain code, and the generalized chain codes
are compared to each other.
Furthermore, performance of various chain codes is compared
by the rate distortion measure and the results are shown in Section
III-C.
A. Comparison of the MG Chain Code to Freeman 's Chain Code
[1], [21
IEEE TRANSACTIONS ON PATTERN ANALYSIS AND MACHINE INTELLIGENCE, VOL. PAMI-8, NO. 2, MARCH 1986
Radius
Fineness
273
31 mm
Fineness
8 mm
4 mr,.
?MM
I I
I I
Starting point
point
End
End
I.
S
25 links
60 bits
129 bits
43 links
(a)
(b)
Fineness
Fineness 16 mm
I
start
8 nun
z I v*N,
I
IN
N
I
I.
-I I -l
22 links 66 bits
12 links 34 bits
MG Chain Coding
(d)
(c)
Fig. 9. Encoded circles by Freeman's chain coding and MG chain coding.
Original map
MG Chain Code
475 links
738 bits
(a)
(b)
Fig. 10. The northern island of Japan, Hokkaido.
802 links
2406 bits
(c)
IEEE TRANSACTIONS ON PATTERN ANALYSIS AND MACHINE INTELLIGENCE, VOL. PAMI-8, NO. 2. MARCH 1986
274
01
12 9
10
I
(a)
..0
co
(c)
(b)
(c)
14
5/
4
8
(b)
10
XoS
9 6 3 0
14 7 1
12
. . 0
(a)
41
---t-1N 81
13
4
8
> a e \,\15/
(d)
,,10
12
11
13
21
14
10
14
(f)
(e)
(d)
11
18 10
17
16
19
(e)
0 /
1208
13
21 14 2 2
1 5o
(h)
TABLE III
BIT REQUIREMENTS FOR THE DIFFERENT CHAINS OF FIG. 11
Code System
8 points
16
24
32
I.
MG Chain
Code
with Huffman
..4
(f)
18
0188
Fig. 11. Comparison of original contour (a) with different chain types: (b)
MG chain, (c) 8 point, (d) 16 point, (e) 24 point, (f) 32 point chain, (g)
24 point coding system, (h) MG chain coding system.
Chain Code
t18
714
(g)
Generalized
18
~
21213
Coding
Number of
Links
Bits per
Link
Total No.
of Bits
87
44
3
4
261
48
38
5
5
240
190
50
150
50
2.6
130
176
Fig. 12. Quantization scheme for the improved version of the generalized
chain (24 point) code: (a)-(c) labels for quantization points, (d) example,
(e) generalized chain (24 point) code, (f) improved version of the generalized chain code.
TABLE IV
BIT REQUIREMENTS FOR GENERALIZED CHAIN (24 POINT) CODE AND
IMPROVED VERSION OF THE GENERALIZED CHAIN CODE
Code System
Number of
Links
Bits per
Link
Total No.
of Bits
48
240
Improved Version of
Generalized Chain Code
with Huffman
48
192
48
2.9
139
codinig
[10], [161
One of the application fields of the chain code is a signal transmission in the electronic blackboard system. The simulation of the
275
IEEE TRANSACTIONS ON PATTERN ANALYSIS AND MACHINE INTELLIGENCE, VOL. PAMI-8, NO. 2, MARCH 1986
7J K
2%
'
)Y L
The Freeeman co
0.199
19.9T 16T
is illustrated
'1
Fig. 3
(a)
'.4i
kn )
( nF
(b)
(c)
TABLE V
COMPARISON BY bE
Freeman's Chain coding
1.35
1.22 - 1.19
MG Chain
coding
0.53
1.44
0.56
TABLE VI
SIMULATION RESULTS
Japanese
English
Circuit
10242 bits
6567 bits
8547 bits
2663(0.26)
1707(0.26)
2452(0.29)
3672(0.36)
2218(0.34)
2626(0.31)
5602(0.55)
3965(0.66)
4685(0.55)
6410(0.63)
5231(0.80)
4336(0.51)
5720(0.56)
5000(0.76)
6176(0.72)
Modified DPCM
[9],[16]
electronic blackboard signal transmission by chain codes was carried out with Japanese and English text, and a circuit diagram is
shown in Fig. 13. The Japanese text consists of 91 strokes with 3414
black pels, the English text consists of 2188 black pels, and the
circuit diagram 2849 black pels. The simulation results are shown
in Table VI. The numerals indicate the necessary number of bits to
encode Japanese text, English text, and the circuit diagram. In the
level code [12] and new segment chain code [11], the original texts
and circuit diagrams are encoded by Freeman's algorithm first, then
the redundancies are removed, and final codes are obtained. Numerals in the parentheses indicate the compression ratio of each
code relative to the chain code. Among these codes, the MG chain
code is extraordinarily good in coding efficiency.
V. CONCLUSION
The multiple grid chain code, which uses four different square
grids having quantization points on each side of a unit square, is
proposed to encode line drawings. It is shown that the coding efficiency of the MG chain code is significantly better than other chain
codes because of quantization points allocation to the vicinity of a
line drawing, availability of longer chain segments, and adoption of
the Huffman coding algorithm. As regards Huffman coding, the
probability of each code occurrence is investigated theoretically and
experimentally.
In addition to the coding efficiency, naturalness of the reproduced line drawings by MG chain coding is quite good on account
of the high density of straight line segments for quantization,
namely, smaller angles between straight line segments.
The performance of the MG chain code is investigated by encoding straight lines, circles, and contour maps and the superiority
of the MG chain code to other chain codes is ascertained. At last,
the possibility of applying the MG chain code to the electronic
blackboard is examined by simulation, and it is proved that the coding efficiency of the MG chain code is better than the efficiency of
any other codes.
REFERENCES
[1] H. Freeman, "On the encoding of arbitrary geometric configurations," IRE Trans. Electron. Comput., vol. EC-10, June 1961.
[2] -, "Computer processing of line-drawing data," Comput. Surv., vol.
6, Mar. 1974.
[3] -, "Application of the generalized chain coding scheme to map data
processing," in Proc. IEEE Comput. Soc. Conf Pattern Recognition
Map Data Processing, Chicago, IL, May 31-June 2, 1978.
[4] J. A. Saghri and H. Freeman, "Analysis of the precision of generalized chain codes for the representation of planer curves," IEEE Trans.
Pattern Anal. Machine Intell., vol. PAMI-3, Sept. 1981.
[5] A. Rosenfeld, Image Modeling. New York: Academic, 1981.
[6] H. Freeman and J. A. Saghri, "Comparative analysis of line-drawing
modelling schemes," Comput. Graph. Image Processing, vol. 12,
1980.
[7] A. Kegel and J. H. Bons, "On the digital processing and transmission
of handwriting and sketching," in Proc. Commun. IEEE Eurocon '77,
1977, p. 2.4.6.
[8] D. K. Scholten and S. G. Wilson, "Chain coding with a hexagonal
lattice," IEEE Trans. Pattern Anal. Machine Intell., vol. PAMI-5,
Sept. 1983.
276
19]
[101
I l]
[12]
113]
[14]
[15]
[16]
IEEE TRANSACTIONS ON PATTERN ANALYSIS AND MACHINE INTELLIGENCE, VOL. PAMI-8, NO. 2, MARCH 1986
In this section, the digitization and measurement process is described in detail. This is necessary to arrive at a precise formulation
of the optimal measurement methods.
All continuous straight lines form a set S12. An element I of this
set can be characterized by intercept e and slope et in a Cartesian
grid (1: v = ax + e). A property.f can be associated with each 1.
For instance, f(e, a) a represents the slope of 1.
Properties of the continuous line I are to be measured after digitization symbolized by the operator D. Digitization results in a
string c where c = Dl. Digitization of all lines in results in the
set of all straight chain-code strings C.
Given a string c? there is an equivalence class of continuous
lines, all having the same string c as its digitization. This equivalence class is called the domain OD(c) of c corresponding to the
digitization D.
Formal definition:
DD(C)
{l.12tlDl c}.
(I)
Thus, the set of domains indicates the finest distinction of the original continuous lines that is still possible after digitization.
The digitized line c can be represented in various ways, for instance, as a string of (x, v) coordinates, a series of run codes, or
the Freeman directional code [1]. Furthermore, one can digitize in
different ways, such as grid intersection quantization (GIQ) or object boundary quantization (OBQ) [2]. The difference between these
methods is not essential to the basic idea of the present paper. Specific results will be given for OBQ, 8-connected Freeman
chain codes. For this case, the domains have been given in a previous paper [5]. In Fig. 1, they are depicted for all lines having a
chain code consisting of 6 codes 0 or 1. The representation is in a
part of the parameter space (e, a) where each point (e, a) represents a continuous line l:y = ax + e.
The estimation of the original continuous propertyf is to be based
on the discrete string resulting from the digitization. This is done
by characterization and calculation. The characterization K reduces the chain-code string c to a tuple t of parameters (where t =
Kc) characterizing the string. For instance, one might characterize
a string by the number of odd and even Freeman codes in the string.
Characterizing all strings of eC leads to the set of all tuples 3. A
tuple can be used in an estimator g which attributes a value g (t) to
the tuple t. This value g (t) = g (Kc) = g (KDI) is used as an estimate of the original continuous property f(l), based on the digitization Dl. The recognition of the characterization K is essential in
optimizing the estimator g of the property f.
In the same way as domains are the equivalence classes into
which the set of lines is divided by digitization, we have equiva-