You are on page 1of 7

The First Scientific Symposium Of Electrical And Electronic Engineering (EEES) 2016

An Efficient Methods Comparison for Arabic


Words Contours Approximation
A. Ukasha
Faculty of Engineering, Department of
Electronics & Computer Engineering
Sebha University Sebha, Libya
Email: elokshy@yahoo.com

Abstract This paper presents a comparison between three an


efficient algorithms for Arabic contour approximation and
compression. The oldest method known as Ramer algorithm
will be used for contour approximation in addition with
Trapezoid & Adaptive-Triangle methods. These algorithms are
introduced & compared. The single step parallel contour
extraction (SSPCE) method will be used in this work to
achieve Cartesian representation of the object. The main idea
of the analyzed approaches are discussed to obtain contour
compression. For comparison, the mean square error and
signal-to-noise ratio criterions are used. Experimental results
are obtained both in terms of image quality, compression
ratios and speed. The main advantage of the analyzed
algorithm (Adaptive-Triangle) is the short computational time
of operations compared with Ramer, but it has less quality. On
the other side it has better quality and quite less speed than
that of Trapezoid algorithm.
Index Terms Contour representation, contour compression, polygonal approximation, Ramer, Trapezoid and
Adaptive-Triangle methods.

1. INTRODUCTION
Contours play an important role in processing medical
images, image compression, etc. Hence, a new efficient
algorithm called Adaptive-Triangle approach is presented
to solve the problem of speed in time of operations. The
Cartesian representations are mostly used for the contour
approximation procedures. In this paper the method
known as single step parallel contour extraction method
SSPCE is using to extract contours from binary image
(A. Dziech, et al 1998). The fundamental goal of the
digital signal compression is to reduce the bit rate for
transmission and storage without significant loss of
information. The well-known algorithm in spatial domain
is Ramer who has presented repeated end points that suit
the algorithm. Connecting a number of points by joining
all the line end points give the approximation of such data
and that is the basic idea of this algorithm. The analyzed
methods corresponds to a family of polygonal methods in
image and signal data processing. The two other analyzed
algorithms Trapezoid & Adaptive-Triangle for contour
compression will compared and discussed with Ramer
method.

R. Albahi
Faculty of Engineering, Department of
Electronics & Computer Engineering
Sebha University Sebha, Libya
Email: Rog_albahi2008@yahoo.com

2. SINGLE STEP PARALLEL CONTOUR


EXTRACTION METHOD
The following three steps are needed for the extraction
procedure of single step parallel contour extraction
(SSPCE) [7]:
1.
2.
3.

To ensure the closure of all extracted contours, the


image should be framed with zeros.
Eight rules of edge extraction are applied and coded
using 8-directional chain code.
Sorting the extracted contour edges and storing them
to become ready for applications.

3. METHODS OF CONTOUR COMPRESSION


IN SPATIAL DOMAIN
There are several algorithms available for determining
the number and location of the vertices and also to
compute the polygonal approximation of a contour. In
this work the contour compression in spatial domain
based on polygonal approximation using three different
methods are discussed in the next sections.
The notable step here; before applying any of contour
compression methods we need to get extracted contours
using (SSPCE) method.
A. Ramer Method
This algorithm has been introduced by Ramer [1], it
based on extracted contours using polygonal
approximation of two-dimensional digitized curves. For a
closed contour as in (Fig. 1.a), the working procedure of
the algorithm started with split the original contour into
two parts (lower and upper curves) by a straight-line;
which connect two points on the contour known as start
point (point which has minimum value of X-axis from
left side), and end point (point which has maximum value
of X-axis from right side). Then, for the lower side
(Fig.1.b) we begin to compute the perpendicular distance
from each point along the segment to the straight -line. If
this distance greater than certain threshold, we break the
line at the point of greatest distance to obtain new
segments see (Fig. 1.b). Thereafter, repeat the last step
recursively with each of the two new lines separately;

The First Scientific Symposium Of Electrical And Electronic Engineering (EEES) 2016

until there is no need to break any more when the


maximum distance of any point to the poly-line falls
below a certain threshold. After that, repeat the same
process steps for upper side too (Fig. 1.c).
Finally connect the vertices (Fig. 1.d) of the
reconstructed contour by drawing lines between them to
obtain the polygonal approximating contour.
The main advantage of the Ramer method is its good
quality. While, the main disadvantages is the large
complexity and the long computational time compared
with other algorithms.
31

33

102

36 35

100

37

38

98

30

27

28

34

26

41

20

42
18

94

92

16

5
4

90

11

88
40

42

44

46

13

10

48

96

14 15

52

54

56

58

3
5

46

10

48

38

98

y
90

22

44

46

58

11

13

10

12

48

50

52

28

98

21

19
18 (x ,y )
1 1
16

56

100

23

l2(18,28)

l1(18,1)
3
4 5

54

102

25

20

42

27
24

l3(28,1)

88
40

28

26

42
(x2,y2) 1

92

104

29
30

34

41

96

52

(b)

37

39

40

12

96

100

94

32

50

17

14 15

Figure 2. Illustration of the basic idea for the Trapezoid method.

31

33
36 35

13

11

9
8

44

16

42

21
20
19
18 (x ,y )
2 2

l1(1,18)
l3(1,7)
l (7,18)

(a)
102

23
22

104

25
24

88
40

27
26

90

12

50

94

41
42
(x1,y1) 1

92

17

28

39

40

21
19

30

34

37

38

98

22

29

32

36 35

100

23

24

31

33

102

25

39

40
96

104

29

32

104

of the trapezoid, then draw a new segment. The stored


points will determine the vertices of an edge of the
approximating polygon.

94

18

92

17

14 15

90

88

54

56

58

40

42

44

46

48

50

52

54

56

58

The main advantage of this algorithm is its fast


manipulation of data compared with other algorithms;
this is because the ability of algorithm to scan the contour
points only once, and does not require storing the
analyzed contour points; because the points of the
original contour will be eliminated immediately. But the
quality of extracted contours will be less than Ramer
algorithm [2, 3]. The flowchart of this method is shown
in Fig. 3.

(d)

(c)

START

i=1; VA=[1];
SP=CC(:,i); B; C;
EP=CC(:,i+3*f);

Figure 1. Contour Compression using Ramer method: a) The original


contour, b) The curve segments for the lower side, c) The curve
segments for the upper side, d) The approximated contours.

B. Trapezoid Method
This algorithm belongs to the polygonal approximation
methods of contour representation. Segmentation of the
contour points to get trapezoid shapes as in (Fig. 2) is the
basic idea of this algorithm. The first point of each
segment is called starting point (SP) and the last one is
called ending point (EP).
The ratio between the perpendicular distances (dB)
from point B to the line (SP C) to the perpendicular
distance (dC) from point C to the line (B EP) is the fit
criterion of the trapezoid method as in equation (1), and
trigonometric formula is used to calculate these values.
(dB/dC)<th

dB
th
dC

i LCC

VA=[VA B C EP];
SP=EP; i=i+3*f;

VA=[VA C EP];
SP=EP;
i=i+3*f;

(1)
END

where: th is the given threshold value.


If the condition in equation (1) is verified; store the
third and ending points of the trapezoid, and shift the SP
to the EP; then draw a new segment. Otherwise store the
second, third and ending points and shift the SP to the EP

Figure 3. Flowchart of Trapezoid method.

The First Scientific Symposium Of Electrical And Electronic Engineering (EEES) 2016

C. Adaptive-Triangle Method
This section presents a suggestion of a new algorithm
for contour compression of black-white images in time
domain based on polygonal approximation. The idea of
this algorithm based on choosing two points (Sp, Ep) on
the contour curve as in (Fig. 4) [4]. Sp is point number 1
on the curve, Ep is point number 12 on the same curve.
Now; the straight line that connecting (Sp, Ep) is used to
compute the maximum perpendicular distance (
)
from this line to contour curve points from Sp to Ep to as
shown in (Fig. 4), compare this distance (
) with
given threshold ( ) by the equation (2).
The flowchart of this method is shown in Fig. 5.

2.

Vertex Points= [Sp S1/2 S2/2 Ep], and start


point Sp is shifted to the end point Ep and open
new segment, as shown in (Fig. 4).
Otherwise we will store Vertex Points = [Sp
Slargest/2 Ep] as a vertex points of compressed
contour, and start point Sp shifted to end point Ep
and open new segment, as shown in (Fig. 4).
Second case, if condition of equation (2) fails,
i.e.
(4)
(d max th1 )
We will store (Sp, Ep) as a vertex points, and
shift Sp to Ep and open new segment, as shown
in (Fig. 4).

Figure 4. Illustration of the basic idea for the Adaptive-Triangle


method.

>

(2)

There are two possible cases:


1.

If the distance (
) is larger than ( ) and
equation (2) comes true, we will open two new
line segments (S1 , S2), S1 is the direct line that
connect Sp to
point, and S2 the direct line
that connect
point to Ep . Now, compare the
length of S1 , S2 lines:
If (S1 > S2) we will compare the ratio between
(Lo :direct length) of largest segment, with the
(LN : real length) of the same segment with a
given threshold (th2) according to equation (3)

( LO LN ) th2

(3)

If the condition of equation (3) comes true


choose two additional points on the (S1, S2) lines
as a vertex points of compressed contour, so the
vertex points will be:

Figure 5. Flowchart of Adaptive-Triangle method.

The First Scientific Symposium Of Electrical And Electronic Engineering (EEES) 2016

4. APPLIED MEASUREMENTS
In order to evaluate the compression ability, the
following compression ratio equation (5) was used
[5], [6].

CR

( LCC LAC )
.100%
LCC

Letters' image. Test images and their extracted contours


illustrated in (Fig.6). The comparison is made with
respect to the consuming time and number of points that
used to represent the extracted contour as shown in
(Table. I).

(5)
Original image

original binary image

Extracted Contours
using SSPCE (3x3)

where:
LCC - length of the input contour C.
LAC - length of the approximating polygon CC.

LCC

d
i 1

2
i

(6)

original binary image

di - is the perpendicular distance between i point on the


input contour curve segment and straight line between
each two successive vertices on edge of the
approximating polygon; if the edge is a part of a straight
line described by a common equation:

A.xi B. yi C
A2 B 2

Arabic Letters

where:

di

original binary image

Libya map

1
MSE
LCC

Ain

The mean square error (MSE) and signal-to-noise ratio


(SNR) criterions were used for quality measure to
evaluate the distortion introduced during the
approximating procedure. The mean square error (MSE)
is defined by the equation (6).

Figure 6. Contour extraction using SSPCE method.

(7)
TABLE I.

CONTOUR EXTRACTION USING SSPCE (3X3 WINDOWS)

Signal-to-noise ratio (SNR) criterion is defined by the


following equation.

MSE
SNR 10. log10 (
)
VAR

(8)

where:

Image name

Consumed
time (ms)

Contour
points No.

Ain

32.3

307

Libya map

92.2

687

Arabic Letters

943.7

7920

VAR - variance of the input sequence


3

Performed analysis and experiments show that SNR


should be greater than 30 dB to obtain the expected
compromise between compression ratio and quality of
reconstruction. In the case of high threshold level, the
contour details are eliminated and level of introduced
distortion cannot be accepted.

5. EXPERIMENTAL RESULTS & DISCUSSION


A. Contour Extraction using SSPCE Method
To show the results of contour extraction using SSPCE
methods a set of three binary test images are used; two of
them have a single contour as: 'Ain', 'Libya map' images.
The other one have a multi contour named as 'Arabic

Fig.6 & Table. I presents the contour extraction using


SSPCE (33 windows) & it shows the ability of extract
contours from binary images that has a few details like
Ain image, as well as many details images like 'Arabic
Letters' image. The extracted contours contains all details
of the original image even small ones like points.
Although, time needed to obtain contours depends on the
complexity of image contents, short time for executing
the operations and get contours is the other characteristic
that distinguishes this method. The above mentioned
properties made this algorithm suitable for real time
applications.

The First Scientific Symposium Of Electrical And Electronic Engineering (EEES) 2016

B. Contour Compression Methods


After extracting contours using SSPCE (3x3windows),
we can apply contour compression methods on it. A code
is written with MATLAB (2010) programming is used to
obtain all results; the block diagram of the compression
procedure for all methods is shown in (Fig. 7).

Ramer
Adaptive-Triangle
Trapezoid
38
37
36
35
34
33

Cartesian
Description of
Contour

Binary image

SNR(dB)

32

Contour
Extraction Using
SSPCE Method
[[

31
30
29
28
27
26
25
24

Contour
Signal

23
22
80

81

82

83

84

85

86

87

88

89

90

91

CR(%)

Compressed
Contour

Apply Contour
Compression
Procedure

Figure 9. SNR versus CR for Ramer, Trapezoid, and AdaptiveTriangle compression algorithms of 'Ain' image.

Ramer
Triangle-Adaptive
Trapezoid

Figure 7. Block diagram of contour compression procedure.


50

Consumed time(ms)

45

Next Tables (II , III, IV) presents the experimental


results of applying (Ramer, Trapezoid, AdaptiveTriangle) compression methods on extracted contours
of images shown previously on (Fig.6) & results of
compressed images are shown in (Fig. 8, 9, 10, 11, 12,
13, 14, 15, 16) respectively.

40
35
30
25
20
15
10
5
0

80

85

CR(%)

90

95

Figure 10. Results of compression versus time for 'Ain' contour using
(Ramer, Trapezoid, Adaptive-Triangle) methods.

TABLE II.

(a)

RESULTS OF COMPRESSION FOR 'AIN' CONTOUR


Compression
Method

(b)

CR%

SNR
(dB)

Time
'ms'

80.1303

36.3303

48.21

85.6678

35.9573

44. 86

90.5537

30.8402

44. 7

95.114

21.029

41.86

80.1303
85.6678

34.3447
29.8325

42.88
42.61

90.5537
95.53
80.456
85.6678
90.5537
95.439

24.5376
17.577
32.4243
28.4939
22.4442
13.700

41.36
34.15
32.32
31.35
30.65
30.052

Ramer

Ain

(c)

AdaptiveTriangle

(d)
Trapezoid

Figure 8. (a) Original Contour of 'Ain, (b, c, d) Compressed contour


at CR= 85% using (Ramer, Trapezoid, Adaptive-Triangle) methods
respectively.

The First Scientific Symposium Of Electrical And Electronic Engineering (EEES) 2016

TABLE III.

RESULTS OF COMPRESSION FOR 'LIBYA MAP' CONTOUR


Compression
Method

CR%
79.9127

SNR
(dB)
44.9098

Time
'ms'
69.2

85.5895
90.1019
98.2533
79.7671
85.1528
90.393
97.8166
79.6215
85.444

45.0827
43.108
28.2568
45.4323
43.1515
39.032
25.6039
42.7478
42.1536

61.11
56.7
52.26
47.7
46
45.9
40.09
39
36.7

90.1019
97.8166

36.147
22.087

36.08
34.1

Ramer
Triangle-Adaptive
Trapezoid
70

Libya map

AdaptiveTriangle

Trapezoid

Consumed Time(ms)

Ramer

60
50
40
30
20
10
0

80

85

90

98

CR(%)

Figure 13. Results of compression versus time for 'Libya map' contour
using (Ramer, Trapezoid, Adaptive-Triangle) methods.

TABLE IV.
RESULTS OF COMPRESSION FOR
'ARABIC LETTERS' CONTOUR
(b)

(a)

Compression
Method
Ramer
Arabic Letters

(c)

(d)

AdaptiveTriangle

Trapezoid
Figure 11. (a) Original contour of 'Libya map, (b, c, d) Compressed
contour at CR= 85% using (Ramer, Trapezoid, Adaptive-Triangle)
methods respectively.

CR%
75.101

SNR
(dB)
45.46

Time
'ms'
5,849

80.2778
84.6075

44.394
41.6075

4,834.1
5,814.4

74.899
80
85.1263

45.3307
43.936
41.1687

5,337
7,383.5
4,976.6

75.0253
80.0379
85.101

44.4665
41.9843
39.6863

5,788
6,354
4,852

SNR (dB)

Ramer
Adaptive-Triangle
Trapezoid
47
46
45
44
43
42
41
40
39
38
37
36
35
34
33
32
31
30

(a)

82

83

84

85

86

87

88

89

90

91

92

93

94

(b)

95

CR (%)

(c)
Figure 12. SNR versus CR for Ramer, Trapezoid, and AdaptiveTriangle compression algorithms of 'Libya map' image.

(d)

Figure 14. (a) Original contour of 'Arabic Letter, (b, c, d) Compressed


contour at CR= 85% using (Ramer, Trapezoid, Adaptive-Triangle)
methods respectively.

The First Scientific Symposium Of Electrical And Electronic Engineering (EEES) 2016

Ramer
Trapezoid
Adaptive-Triangle

45

44

SNR(dB)

43

42

41

with other two algorithms. Trapezoid algorithm is the


fastest algorithm, but its compression quality is lowest
among the other methods (Ramer, Adaptive-Triangle).
Adaptive-Triangle method makes balance between speed
and compression quality. The short computational time
and good quality of compression are the main features of
the proposed algorithm.

Arabic Letters

40

39

6. CONCLUSIONS

38
80

81

82

83

84

85

86

87

88

CR(%)

Figure 15. SNR versus CR for Ramer, Trapezoid, and AdaptiveTriangle compression algorithms of 'Arabic Letters' image.

Ramer
Triangle-Adaptive
Trapezoid
300

250

SNR(dB)

200

150

100

50

80

85

90

97

CR(%)

Figure 16. Results of compression versus time for 'Arabic Letters'


contour using (Ramer, Trapezoid, Adaptive-Triangle) methods.

In this paper, a three algorithms of Ramer, Trapezoid


& Adaptive-Triangle methods for compressing Arabic
words contours are introduced and analyzed. The
methods drawbacks and advantages were discussed in
detail. This study concludes that the analyzed algorithms
gives higher compression for single as well as for multicontours with some small significant loses of contour
approximation quality. The compression ratio obtained by
these algorithms can be greater than or equal to 96% with
accepted significant visible distortion. The presented
results show that the Trapezoid algorithm for Arabic
contour approximation are many times faster than Ramer
and Adaptive-Triangle methods.
The Adaptive-Triangle method is suitable in various
applications of contour compression, where both speed
and quality are significant at the same time. The
simplicity of algorithms is also an important feature of
the analyzed methods in terms of both memory
requirements and fitting with in complication criterion.

REFERENCES
[1]

[2]

The results in comparison between compression


methods are listed below:
Figures show the relationship between compression ratio
(CR) and signal to noise ratio (SNR) using (Ramer,
Trapezoid, Adaptive-Triangle) compression methods for
all tested contours.
From these figures we can see that in all presented
compression methods, the compression quality is good,
even at higher compression ratios which caused some
distortion in the compression quality in the contours.
Ramer algorithm achieves the highest quality of
compression compared with the other two algorithms
(Trapezoid, Adaptive-Triangle). However, this algorithm
needs longer time to execute the operations compared

[3]

[4]

[5]
[6]
[7]

U. Ramer, An iterative procedure for the Polygonal


approximation of plane curves, Computer Graphic and Image
Processing, Academic Press, 1972, pp. 244-256, 1972.
A. Ukasha, E. Saffor and M. Hassan, Contour Compression using
Trapezoid method, International Symposium Computer and
Information Sciences (IEEE/ISCIS), Istanbul, Turkey, 2008.
A. Ukasha, Arabic Letters Compression using New Algorithm of
Trapezoid method, International Conference on Signal
Processing, Robotics and Automation (ISPRA'10), Cambridge,
United Kingdom, 2010, pp. 336-341.
M. El Bireki, R. Albahi, Ali Ukasha, M. Abdullah, An AdaptiveTriangle Method for Contour Data Approximation, International
Journal of Theoretical and Applied Information Technology
(JATT), ISSN: 1992-8645, 2015, pp. 343-348.
A. K. Jain, Fundamentals of Digital Image Processing, New
Jersey: Prentice Hall International, 1989.
R. C. Gonzalez, Digital Image Processing, Second Edition,
Addison Wesley, 1987.
A. Dziech, W. Besbas, A. Nabout, and H. Nour Eldin, Fast
algorithm for closed contour extraction, Proc. of the 4th
International Workshop on Systems, Signals and Image
Processing, Pozna, Poland, 1997, pp. 203-206.