Equivalence of Chain Codes PDF
Equivalence of Chain Codes PDF
Hermilo Snchez-Cruz
Hiram H. Lpez-Valdez
Abstract. The representation of images is an active and very important area in image processing and pattern
recognition. Therefore, in the literature, different contour codes for binary images have been proposed, such as
F 4; F 8; V CC; 3OT , and AF 8. These codes have been used in many papers since the first chain code, F 8, was
introduced by Freeman in 1961. All the codes have been tried here as vector representations, including vertex
chain code (V CC). To know their properties, this paper provides an analysis of comparisons of each code, and
as an important contribution, we investigated the relationship between them and found a series of transformations that allow simple and efficient sets to go from one code to another. We found the equivalences between
F 4; V CC; 3OT ; F 8, and AF 8. As an important consequence of the transition matrix concept, we proposed a new
code for eight connectivity by observing a missing code in the state of the art and in the inspiration of the 3OT
code. 2014 SPIE and IS&T [DOI: 10.1117/1.JEI.23.1.013031]
Keywords: chain codes; vertex chain code; 3OT; contour; transition matrix.
Paper 13339 received Jun. 25, 2013; revised manuscript received Dec. 19, 2013; accepted for publication Jan. 23, 2014; published
online Feb. 28, 2014.
1 Introduction
Using chain codes is a common way for binary object-shape
representation. The Freeman code, proposed in 1961,1 is
known as Freeman chain code, and it is composed of
eight directions, so we call it here F8 code. It is a compact
way to represent binary object shapes, and it has the characteristic of going through a sequence of pixels of the contour on the basis of eight connectivity. Each movement
direction is codified using a symbol , where
0; 1; 2; : : : ; 7 in clockwise direction [see Fig. 1(b)].
Analogous to F8, F4 code visits the pixels of the contour
using four connectivity. A movement direction is codified
using a symbol , with 0; 1; 2; 3 [see Fig. 1(a)]. F4 is
also known as crack code because it covers the contour
shape along edges of border pixels.26
Since Freeman proposed the first chain code,1 a considerable amount of papers using chain codes for a wide variety
of issues have appeared.
One motivation to study chain codes is that, despite the
different chain codes that have been proposed independently,
a theoretical analysis is necessary to know if the codes are
related. Of course, implementing the codes takes some technical effort. For example, 3OT is more difficult to implement
than vertex chain code (VCC) because the former takes into
account relative changes regarding a reference vector, which
remains the same unless another change occurs. As can be
studied from the literature, different proposals have been
implemented independently. However, a question arises:
can a general scheme be constructed that relates the different
codes and predicts the existence of more?
Another motivation to study chain codes is that they can
be used particularly in compression of scanned documents.
For example, recently 3OT code has been utilized to compress image text documents, obtaining more than twice the
*Address all correspondence to: Hermilo Snchez-Cruz, E-mail: hsanchez@
correo.uaa.mx
013031-1
JanFeb 2014
Vol. 23(1)
Basic code
Derived codes
1961
F8; F4
1999
V CC
E V CC , C V CC , V V CC
2005
3OT
M3OT
2005
AF8
MDF9
Two vectors
Three vectors
4 connectivity
F4
V CC
3OT
8 connectivity
F8
AF8
013031-2
JanFeb 2014
Vol. 23(1)
Fig. 2 Bases used for the codes, all with vector representations, including V CC code. C F 4 f0; 0; 0; 0;
1; 1; 1; 0; 1; 1; 2; 1; 2; 1; 2; 2; 2; 2; 3; 2; 3; 3; 0; 0; 0; 3; 2; 2; 3; 3; 0; 3g, C V CC f1; 0; 0; 0; 1; 0; 0; 2; 1; 0; 1; 2;
1; 2; 1; 0; 0; 0; 1; 2; 1; 0; 1; 0; 0; 2; 2; 0; 1; 0; 1; 2g, C 3OT f0; 0; 0; 2; 0; 0; 1; 1; 0; 2; 1; 1; 1; 1; 0; 0; 0; 2; 1; 1;
0; 2; 0; 0; 1; 2; 0; 1; 0; 2; 1; 1g.
Journal of Electronic Imaging
013031-3
JanFeb 2014
Vol. 23(1)
JanFeb 2014
Vol. 23(1)
tpq 44 ;
if q f1; 2g
:
if q 3
B1
@
2
3
1
1
2
3
0
2
31
0C
A
1
2
Proof.
0
00
0
1
2
3
tpq 43 ;
p q 2 mod 4
p 2 mod 4
tpq
3
21
C
A
1
0
where
2
1
0
2
T tpq rs ;
VCC T F4
B2
@
1
1
1
0
2
For example, if we have in some place of F4: a symbol 2 followed by 3, in VCC we have 1.
F4 T VCC
0
00
0
1
2
3
tpq 44 ;
where
(
tpq
1 if p q;
2 if jp qj 2 :
otherwise
tpq 42 ;
013031-5
Proof.
Vol. 23(1)
Proof.
0
01
B
@
2
1
1
2
2
2
1
B7
B
B6
B
B5
B
B4
B
B3
@
2
1
1
1
0
7
6
5
4
3
2
2
2
1
0
7
6
5
4
3
3
3
2
1
0
7
6
5
4
4
4
3
2
1
0
7
6
5
5
5
4
3
2
1
0
7
6
6
6
5
4
3
2
1
0
7
7
71
6C
C
5C
C
4C
C
3C
C
2C
A
1
0
2
21
3C
A
0
1
0
00
0
1
2
3
4
5
6
7
with 0 r 7;
then CAF8 i r:
1
00
B1
@
2
3
3
1
2C
A
1
tpq 88 ;
tpq 88 ;
with 0 r 7;
013031-6
JanFeb 2014
Vol. 23(1)
matrix AF8 T F8 . The transition matrix can be read like a multiplication table.
0
1
2
3
4
5
6
7
0
00
B1
B
B2
B
B3
B
B4
B
B5
@
6
7
1
1
2
3
4
5
6
7
0
2
2
3
4
5
6
7
0
1
3
3
4
5
6
7
0
1
2
4
4
5
6
7
0
1
2
3
5
5
6
7
0
1
2
3
4
6
6
7
0
1
2
3
4
5
7
71
0C
C
1C
C
2C
C
3C
C
4C
A
5
6
F4 T F8
5, then CF8 i 0.
Example 1 In this example, we show how to use the transition matrix F8 T FA8 . The chain code CF8 of Fig. 5 is
CF8 f0; 0; 0; 2; 3; 4; 3; 5; 6; 7g, and the transition matrix
F8 T FA8 can be read like a multiplication table.
0
1
2
3
4
5
6
7
0
00
B7
B
B6
B
B5
B
B4
B
B3
@
2
1
1
1
0
7
6
5
4
3
2
2
2
1
0
7
6
5
4
3
3
3
2
1
0
7
6
5
4
4
4
3
2
1
0
7
6
5
5
5
4
3
2
1
0
7
6
6
6
5
4
3
2
1
0
7
7
71
6C
C
5C
C
4C
C
3C
C
2C
A
1
0
2
3
4
5
71
C
A
and
0 0 010 01 0121
03 1
1 121 12
3 C
B 10
C
B
10
1 121 12 1232
C
B
C
B
0
21
2 232 23
C
B
T
C:
B
F8 F4
21
2 232 23 2303 C
B
C
B
1
32
3 303 C
B 30
A
@
30 2010
32
3 303
0 010 01
2
03
Proof.
Let CF8 be the coding of the same figure with F8. For
i 1; 2; ; n, we find CF8 i with the help of CF4 i
and CF4 i 1, where CF4 0 CF4 n. We have to
analyze every two vectors in F4 and see how they become
in F8. Next conditions take place.
If CF4 i 1 0 and CF4 i 0, then CF8 i 0,
if CF4 i 1 0 and CF4 i 1, then CF8 i
empty, since for F8 we are in the center of the
same pixel, so we do nothing.
CF4 i 1 0 and CF4 i 2 never happens (for this
is used),
if CF4 i 1 0 and CF4 i 3, then CF8 i 7,
where i 1; : : : ; n. All these facts can be summarized
in the next transition matrix.
0
1
2
3
0
00
B1
@
2
3
2 3
71
C:
A
4
5 6
00
B1
@
013031-7
JanFeb 2014
Vol. 23(1)
It can also be read like a multiplication table. For example, if we have CF8 i 1 5 and CF8 i 3, then
CF4 i 1.
6 New Code
As an important application of the transition matrix concept,
we create a new code using a matrix. This code is inspired in
3OT, but the new code is obtained by visiting the centers of
pixels. Let us call the new code AAF8 (because it uses two
angles to determine a symbol).
0
1
2
3
4
5
6
7
0 0 010 01 0121
03 1
1 121 12
3 C
B 10
C
B
10
1 121 12 1232
C
B
C
B
0
21
2 232 23
C
B
C
B
21
2 232 23 2303 C
B
C
B
1
32
3 303 C
B 30
A
@
30 2010
32
3 303
0 010 01
2
03
Fig. 7 The set of allowed vector arrays of our proposed AAF 8 code.
Journal of Electronic Imaging
013031-8
JanFeb 2014
Vol. 23(1)
0
1
2
3
4
5
6
7
0
00
B7
B
B6
B
B5
B
B4
B
B3
@
2
1
1
1
0
7
6
5
4
3
2
2
2
1
0
7
6
5
4
3
3
3
2
1
0
7
6
5
4
4
4
3
2
1
0
7
6
5
5
5
4
3
2
1
0
7
6
6
6
5
4
3
2
1
0
7
7
71
6C
C
5C
C
4C
C
3C
C
2C
A
1
0
013031-9
JanFeb 2014
Vol. 23(1)
Size
Number of pixels
l4
l8
Bull
286 278
38,115
2122
1651
Map
310 213
21,747
1560
1120
Giraffe
197 505
36,945
2866
2316
Frog
183 151
12,789
1704
1172
Omega
187 184
14,565
1492
1178
VW
447 204
57,337
1388
1058
Bat
550 265
53,096
2054
1444
Motorcycle
853 695
289,672
5044
3689
Camel
293 285
32,202
1796
1330
Eagle
226 213
19,363
1214
816
Let CF8 be the coding of the same figure with F8. To find
the element CF8 i, for i 2; ; n 1, consider, again,
k < i and the condition that CF8 n and CF8 1 are known.
Dolphin
305 284
27,613
1394
1022
Pitbull
220 246
26,126
1328
1019
If CAAF8 i r;
Trex
431 287
34,053
2208
1651
Horse
238 174
11,886
1836
1277
Boot
269 359
45,787
1458
1144
Car
309 204
47,973
1202
1010
Star
259 244
28,244
1178
860
Chicken
184 180
17,946
966
678
Jump
203 244
13,776
1378
947
Hand
309 287
47,132
1864
1371
Penguin
122 160
8500
831
564
Car 2
406 221
1085
1378
1179
Dog
230 275
23,805
1562
1152
Fish
221 171
22,037
1158
841
Spiral
187 181
14,501
3128
2213
Guitar
24 77
584
240
186
CAAF8
fCF8 n;CF8 1;CAAF8 3;:::;CAAF8 i;:::;CAAF8 ng:
with 0 r 7;
0
00
B1
B
B2
B
B3
B
B4
B
B5
@
6
7
1
1
2
3
4
5
6
7
0
2
2
3
4
5
6
7
0
1
3
3
4
5
6
7
0
1
2
4
4
5
6
7
0
1
2
3
5
5
6
7
0
1
2
3
4
6
6
7
0
1
2
3
4
5
7
71
0C
C
1C
C
2C
C
3C
C
4C
A
5
6
Trice
356 164
25,758
1460
1056
Plane
355 109
13,306
1216
932
T-shirt
191 206
23,890
860
682
Jeans
220 297
35,541
1410
1121
013031-10
JanFeb 2014
Vol. 23(1)
013031-11
JanFeb 2014
Vol. 23(1)