<<

ISSN: 1748-0345 (Online) www.tagajournal.com

Pattern-based Chain Code for Bi-level Shape Y. Arockia Raj Assistant Professor, Department of Computer Science and Engineering, PSNA College of Engineering and Technology, Dindigul, Tamil Nadu, India. E-mail: [email protected]

P. Alli Principal, Vellamal College of Engineering and Technology, Madurai, Tamil Nadu, India. E-mail: [email protected]

Abstract

Contour based shape coding schemes are outperforming other compression methods. This paper focuses on shape compression with bi-level images, where the edge follows fine curvatures unlike natural images. In general shape contour is saved either as Digital Straight Line Segments (DSLS) or in the form of chain codes. The DSLS techniques are working based on approximating the line segments and the chain code are constructed by finding the redundant patterns. This paper follows the chain code based approach and presents a novel shape coding scheme based on Pattern-based Chain Coding (PCC) to achieve better compression ratio. Initially the contours are extracted and coded with Binary Chain Code (BCC) based on 8-adjacent pixel neighborhood. Then the subsequent binary coding are searched to identify the patterns and their run-lengths. The patterns are replaced with new symbols along with their run-lengths to reduce the size of BCC. The performance of the proposed edge pattern based image compression method is analyzed with two benchmark datasets of shapes and compared with state-of-art edge encoders. The investigation shows that the proposed compression scheme achieves better compression ratio.

Keywords: image compression, edge detection, shape coding, edge decoding, compression rate.

I. INTRODUCTION

Advances in object-oriented coding using shape information [1], [2], [22] are increasingly facilitating more efficient retrieval, manipulation and interactive editing functionality for both natural and synthetic images. An efficient coder is expected to make of limited bandwidth for the applciations like medical imaging, surviellence, online streaming, multimedia contents, mobile video transmissions and smart televsions. For example, in object-oriented image retrieval applications, since shape is a key feature of objects, the accuracy of shape greatly impact the retrieval efficiency and accuracy. In medical image applications, accurate shape of an organ object can also help to diagnose a disease or undergo an operation. An effcetive shape coder can significantly improve the performance such applications and devices.

In general, objects in the image are defined by their shape as well as texture [10], hence shape coding has become an integral part of object-oriented image coding. There are two major approaches for shape coding: bitmap-based – where every pixel within the shape is encoded, contour-based, here only the boundary pixels are encoded.

© 2018 SWANSEA PRINTING TECHNOLOGY LTD 3064 TAGA JOURNAL VOL. 14 ISSN: 1748-0345 (Online) www.tagajournal.com

(a) (b) (c) Figure 1. Shape Coding example, (a) the object shape, (b) the shape contour, and (c) shape coding

For example, consider an object shape in Figure 1(a), the contour is displayed in Figure 1(b), and the resulting shape contour is displayed in Figure 1(c). The main objective of shape coding is to reduce the number of vertices to represent the contour. As shown in the figure 1(c), the decoded shape (solid line) requires only 13 vertices compared with the original 297 vertices (dotted line) with a small distortion. Reference [10] presented a review of shape coding approaches including the Context-based Arithmetic Encoding (CAE), and conclude that the vertex-based polynomial shape coding is optimal in an Operational Rate Distortion (ORD) sense. Reference [28] studied both distortion metrics and geometric distortion measurement techniques.

Generally, bitmap-based methods are fast and simple and can be used for both lossy and lossless shape coding. However, their coding efficiency usually is not high. Unlike bitmap-based techniques, contour-based methods only extract and encode the contours of objects and their coding efficiency are usually high. Typical methods of this kind include the chain coding techniques [17], the curve fitting techniques such as the polygon approximation techniques and the spline approximation techniques [11]; [26]. Generally, the curve fitting techniques can acquire higher compression efficiency than both the chain coding techniques and the bitmap- based techniques. However, both the chain coding techniques and the bitmap-based techniques can be used for both lossy and lossless applications, while the curve fitting techniques can only be used for lossy purposes. This paper follows chain coding approach, proposed a Pattern-based Chain Coding (PCC) technique to compress the shapes effectively. Here the redundant patterns in the chain codes are identified and replaced with a new symbol and its run-length to reduce the size of the original chain codes.

The rest of the paper is organized as follows: the following section presents the related works for shape coding. Section 3 explains the proposed PCC technique. Section 4 discusses the experimental setup and the results. Section 5 concludes the paper.

II. RELATED WORKS

There are two categories of techniques are available for shape coding: (i) straight line approximation and (ii) chain coding. This section presents a brief review on both techniques.

A. Straight Line Approximation based Techniques

Reference [30] proposed a shape-coding method based on skeleton and the boundary distance from the skeleton. The merit of this method is that it has lower approximation error and . Since the independent skeleton and distance signals are uncorrelated with each other, this encoding method is efficient. Reference [12] models the edges by Digital Straight Line Segments (DSLS). Compare to conventional algorithms like JBIG, JBIG-2 and MPEG4 CAE [10], DSLSC provides better results, as it fully explores the information given by the local straightness of the contour, which is not the case for the other methods. Reference [16] proposed an image- dependent shape coding algorithm, which encodes shape as dependent meta-data. Both the coding and the decoding processes are designed to be dependent on the underlying image. The correlation between image and shape can be effectively removed and the coding efficiency is improved on average by 300% over most of the

© 2018 SWANSEA PRINTING TECHNOLOGY LTD 3065 TAGA JOURNAL VOL. 14 ISSN: 1748-0345 (Online) www.tagajournal.com

existing techniques such as the JBIG, JBIG2, and MPEG-4 CAE. However, this is also a lossy coding scheme and cannot be used for lossless applications.

Reference [2] presented an efficient compression scheme for bi-level images containing locally straight edges. This method is based on a local analysis of the DSLS of the causal part of the object boundary, which is used in the context definition for arithmetic encoding. Coding is achieved in one single pass in raster scan order, which is possible because the local analysis of the source geometry is executed on the fly, without requiring a preprocessing step of vectorizing the source data. The result indicate the acceptable performance improvement. Reference [4] proposed to generate an optimal n-ary incomplete context tree by first constructing a complete tree up to a predefined path and creating the optimal tree by pruning out nodes that do not provide improvement in compression. This scheme is tested with map images, and the result indicate that this method achieves lowest bit rate comparatively. Reference [3] extended DSLSC coding method for gray-level alpha planes in object-based video. Here, the alpha plane is segmented into three layers: binary shape layer, opaque layer and intermediate layer. Different encoding methods are applied to code each layer and cross-layer correlations is utilized to reduce the bit-rate. Conventionally, the Sliding Window (SW) has been applied in vertex-based ORD to improve compression rate, as its length directly impacts upon the bit-rate. Reference [31] proposed a shape coding scheme that can deal with shapes with holes based on vertex chain code. Both polygon and quadratic B-spline based shape encoding strategies were developed ([27]; [13]; [10]) by selecting the set of control points that incurred the lowest bit rate. Reference [14] addressed the issue of distortion measurement for B-spline-based shape coding and proposed a new metric that is fairly perceptually consistent.

Reference [29] presented a technique to estimate the optimum SW-length within a rate-distortion framework. Investigation results show the significance improvement in shape coding. Reference [33] proposed a contour-based framework for near lossless shape coding. Here, for a given shape image, object contours are extracted and thinned first, then the contour is transformed into chain codes. The chain segments are encoded with two different coding modes, and the code with shorter length is chosen as final code. The result indicate the superior performance of the chain code. Recently, some new contour-based methods have also been proposed. Reference [8] presented a line fitting algorithm based on split-and-merge approach to fits a number of elongated ellipses to 2D points (DSaM). The major and minor axes of the ellipses are used to represent the points and the collinear major axes of the adjacent ellipses are merged together to reduce their number. This method does not require an ordering of the points and exactly represents the contour chains that contain joints and mixed structures. Reference [7] proposed a method for the efficient encoding and decoding of a shape with application to edge map image compression. The coder relies on starting and ending points of each contour segments and their length. The results indicate that this coder can achieve better results by making use of efficient line detection algorithm.

B. Chain Code based Techniques

Chain coding is widely used in contour-based shape coding as they effective, however, they require more memory space to store the chain codes. Hence, it is ubiquitous to reduce the chain code length. Reference [6] introduced the concept of chain code for shape encoding, it considers the correlation between successive pixels with length of the line segments and direction, followed by numerous techniques. Chain code is a sequence of symbols. The set in the Freeman Eight Directional Chain Code (FEDCC) consists of eight possible directions for each pixel’s neighbor, while the set in the Freeman Four Directional Chain Code (FFDCC) explores only four possible adjacent. Reference [5] proposed a cell based chain code rather than pixel based, called as Vertex Chain Code (VCC), here only three symbols are used to represent the contour. Further it is modified to reduce the storage space using compressed VCC (C_VCC). Reference [19] presented a proof that JBIG can be a successful coder with transition points. The simulation results indicate that Joint Bi-level Image experts Group (JBIG) image encoding outperforms the other chain coding approaches. This is important because it offers a straightforward approach for the implementation of the contour coding method based on transition points, avoiding the step of designing and implementing non-standard ad-hoc . Reference [18] attempted to perform shape coding using a multiple grid chain code was proposed, which can support both lossless and quasi- lossless coding. Reference [20] presented an efficient method for encoding arbitrary contours based on symbol based Adaptive Context-based Arithmetic Encoder (CAE) in binary domain. The simulation results indicate the superior performance over MPEG-4 shape coder. Reference [21] presented a near- based on regions and boundaries. The boundaries are encoded with transition points, and the regions are encoded based on entropy measures. The results indicate the significant improvement in compression ratio.

© 2018 SWANSEA PRINTING TECHNOLOGY LTD 3066 TAGA JOURNAL VOL. 14 ISSN: 1748-0345 (Online) www.tagajournal.com

Reference [15] proposed an Angle Freeman Chain Code (AF8), which considers eight possible adjacent along with to compress the chain code. Pattern substrings analysis to find high redundancy in binary shapes is carried out to improve compression levels in binary objects. Reference [24] proposed a code contour shape, called 3OT, and they found better compression properties than Freeman codes. An effort to improve C_VCC was done in [25], in which small strings of less than five ones and zeros were used to extend the alphabet in a called M_3OT code. Reference [23] further proposed the modified directional Freeman Chain code in eight directions by a set of nine symbols (MDF9), which modifies the contour at first and adapts the symbols to represent contours efficiently and improvement of the comrpession rate is reached by carrying out a pattern substrings analysis to find high redundancy in binary shapes. The comparative study with other exiting approaches state the significance of MDF9 coder. Reference [32], used the move-to-front transform and adaptive run-length encoding to compress VCC and other chain codes in a lower bit rate. Reference [9] modified the AF8 code with chain division and symbol substitution. Reference [9] applied a morphological operation to reduce the chain code, and the distribution transform is applied to rearrange the binary stream. Experimental results show that the morphological operation can reduce the code length.

III. PATTERN-BASED CHAIN CODING

This section illustrates the proposed shape coding for edge map based compression as depicted in Figure 2. At the first step, the contour of the shape is extracted and segmented to maintain the contours without overlap or intersection points. For every contour the starting point and their length are store into a vector. Then the contours are transformed into chain code and further compressed with pattern based coding.

Contour Classify the Segment the Bi-level Image Detection contour points contours

Store the contour starting points (ES)

Prepare the header for Construct the Pattern- Construct the compressed image based Chain Code Binary Chain Code

Figure 2. The Proposed Pattern-based Chain Coding Framework

A. Contour Extraction

There are numerous methods available to extract the object contours. Here we have used zero-cross edge detection operator to extract the object contours. Figure 3 shows a sample shape and its contour, where the bi- level image pixels values for foreground points and background points are 0 and 1 respectively.

(a) (b)

© 2018 SWANSEA PRINTING TECHNOLOGY LTD 3067 TAGA JOURNAL VOL. 14 ISSN: 1748-0345 (Online) www.tagajournal.com

(c) (d) Figure 3. Shape Contour, (a) fish shape, (b) fish contour, (c) apple shape, (d) apple contour

After extracting the contour map, the contour points are collected by storing their (x, y) position into an array CP. Each row of CP contains two columns to store the x- and y-location of the contour point. Then the contour points are classified into three classes: end-points (starting points), boundary-points, and intersection- points. The 4-connected (c4) and 8-connected (c8) count of each contour points is estimated to classify them as given below: If c8 <2 then the contour point is an end-point for a contour segment. If c8 == 2, If the neighbors are adjacent, and |c8 – c4|  0, then the contour point is an end-point, else it is a boundary point. If the neighbors are not adjacent, the contour point is also a boundary point. In case, if c8 > 2, If c4 >= 3, then the contour point is an intersection point else if |c8 – c4| <=2, then the contour point is also a boundary point, else the contour point is labeled as intersection point. Figure 4 explains the class label assignment, the black pixels represent the contour points, the green, blue and red pixels represent the labels end-point, boundary-point and intersection-point respectively.

For P1, c8 = 1  end-point For P2, c8 = 2, but the neighbors are not adjacent  boundary point For P3, c8 = 2, but the neighbors are not adjacent  boundary point For P4, c8 = 2, but the neighbors are not adjacent  boundary point For P5, c8 = 1  end-point

© 2018 SWANSEA PRINTING TECHNOLOGY LTD 3068 TAGA JOURNAL VOL. 14 ISSN: 1748-0345 (Online) www.tagajournal.com

For P1, c8 = 1  end-point For P2, c8 = 2, but the neighbors are not adjacent  boundary point For P3, c8 = 2, but the neighbors are not adjacent  boundary point For P4, c8 = 2, but the neighbors are not adjacent  boundary point For P5, c8 = 2, but the neighbors are not adjacent  boundary point For P6, c8 = 1 end-point

For P1, c8 = 1  end-point For P2, c8 = 2, but the neighbors are not adjacent  boundary point For P3, c8 = 3, c4 < 3, |c8 – c4| = 2  boundary point For P4, c8 = 2, neighbors are adjacent, |c8 – c4|== 0 boundary point For P5, c8 = 4, c4 < 3, |c8 – c4|=2  boundary point For P6, c8 = 2, neighbors are adjacent, |c8 – c4| == 0 boundary point For P7, c8 = 3, c4 < 3, |c8 – c4| = 1 boundary point For P8, c8 = 2, neighbors are adjacent, |c8 – c4| == 0  boundary point For P9, c8 = 2, neighbors are adjacent, |c8 – c4|  0  end-point

For P1, c8 = 1  end-point For P2, c8 = 3, c4 < 3, |c8 – c4| = 2  boundary point For P3, c8 = 3, c4 == 3intersection point For P4, c8 = 3, c4 < 3, |c8 – c4| = 1  boundary point For P5, c8 = 2, but the neighbors are not adjacent  boundary point

© 2018 SWANSEA PRINTING TECHNOLOGY LTD 3069 TAGA JOURNAL VOL. 14 ISSN: 1748-0345 (Online) www.tagajournal.com

For P6, c8 = 1  end-point For P7, c8 = 4, c4 < 3, |c8 – c4| = 3  intersection point For P8, c8 = 2, but the neighbors are not adjacent  boundary point For P9, c8 = 1  end-point Figure 4. Contour points class label assignment

B. Contour Segmentation

The contours with intersection or crossing points should be identified and segmented to construct efficient chain codes. At first, a label matrix of size same as the contour image is created and initialized with 0 for all the points. The corresponding location of every contour point in the label matrix is marked as either 1, 2, or 3 to represent the contour point is either as end-point, boundary-point or intersection point respectively. Basically the chain code is a sequence of symbols representing the contour direction from the starting point. It is necessary to segment the contours which has intersection points for efficient chain codes.

Figure 5. 8-connected Freeman chain code – traversal order of the pixels

With the label matrix, for an intersection point at (p, q) with the label 3, the list of 8-connected neighbors has label 2 are collected in the counter clockwise order according to 8-connected Freeman chain code. The length of the list is estimated, and if it has two adjacent boundary point, then the current contour point’s label is changed to 2 (mark it as boundary point), and change the other adjacent intersection points’ label as 1 (mark them as new contours). For example, consider the following contour map as shown in Figure 6(a).

(a) (b) (c) Figure 6. Contour Segmentation – sample1 (a) sample contour, (b) intersection point removal, (c) contours after segmentation

The intersection point at (6, 5), has two boundary points, hence the point is changed with the label 2, and the other adjacent intersection points are changed as starting-point as shown in Figure 6(b), thus the contour map is clearly marked as it has 4 contours as shown in Figure 6(c).

Suppose, if the intersection point has only one adjacent boundary point and the others are intersection points, then the intersection point which comes first in the traversal order is marked as boundary point, and the current

© 2018 SWANSEA PRINTING TECHNOLOGY LTD 3070 TAGA JOURNAL VOL. 14 ISSN: 1748-0345 (Online) www.tagajournal.com

intersection point label is also changed as 2, and the rest of the adjacent intersection points’ label are marked as 1 (represent them as new contours).

For example, consider a sample contour map as shown in Figure 7(a), for the intersection point at (6, 5), it has only one adjacent boundary point, so, the adjacent intersection point which is at (6, 6) is marked as boundary point, and the current intersection point is also marked as boundary point. The rest of the adjunct intersection points are marked as starting point as shown in Figure 7(b), hence the contours is segmented with 3 contours as depicted in Figure 7(c).

(a) (b) (c) Figure 7. Contour Segmentation – sample2 (a) sample contour, (b) intersection point removal, (c) contours after segmentation

The label matrix after the segmentation shown in Figure 6(c) & 7(c)indicates that the overlapped contours are segmented properly, so that the chain code construction can be done effectively.

C. Chain code representation

The chain codes are generated as sequence of symbols to represent the flow of the contours. In general, a contour point P, can have 8-adjancet points. Figure 8(a) shows the all possible direction of 8 neighbors. In the proposed chain code representation, the neighbors are marked with the numbers starts from 0 to 7, later encoded into binary strings of 3-bits each. Figure 8(b) depicts the binary string.

(a) (b) Figure 8. Contour-Point Neighbors (a) 8-adjancent directions, (b) Binary string for chain code

The possibilities are explored in the order of E, N, W, S, NE, NW, SW, and SE, as it never skips the contour pixels for the following condition. If the neighbors are explored either in clockwise or counter clockwise direction, the chain code might skip the pixels in the original path. Figure 9(a) shows a sample contour, ‘P’ is the current contour point. If the adjacent pixels are visited in clockwise direction, then the traversal is PP2P3, where the contour point P1 is missed as shown in Figure 9(b). Whereas, based on the proposed order of visit, the traversal is PP1P2P3, which covers all the pixels in the path as shown in Figure 9(c).

© 2018 SWANSEA PRINTING TECHNOLOGY LTD 3071 TAGA JOURNAL VOL. 14 ISSN: 1748-0345 (Online) www.tagajournal.com

(a) (b) (c)

Figure 9. Binary Chain Code construction (a) contour points, (b) Traversal in CW direction, (c) Traversal based on proposed order of directions.

D. Binary Chain Coding

After contour segmentation, the chain codes are constructed for each contour. Initially, from the label matrix, the starting points which has label 1 are collected and stored into an array called ES, where it stores the (x, y) position of the label and the length of the contour in third column. The length column is initialized with zero. For every starting point in E, the contour starts by finding and coding the next point in the contour. For a contour point P, the adjacent boundary-points are collected as given in the traversal order, and the one which comes first in the list is considered as the next point in the contour. Based on its traversal order index, the corresponding binary string is added to the chain code. It is noted that, as the adjacency is considered only with the boundary points, the other starting points are ignored automatically.

Once the contour point is added to chain code, its label will be updated as zero, to mark that the contour point is already visited. While continuing the contour, when a contour point ends up no adjacent boundary- points, it means that the contour ends at the next point. The last point is identified by finding the adjacent starting-point, and add the corresponding binary string to the chain code. At the same time, the corresponding starting-point entry is removed from the array ES. And for every contour, the number of contour points are calculated as length of the contour and updated in the third column of ES. This procedure is repeated for all the contours, and their binary chain codes are collected to form the complete chain code. Consider a sample contour as shown in Figure 10.

Figure 10. Sample contour map The contour starts with P1, and it has the next adjacent at 111, . P2 has its adjacent at 111 (as P1 has been visited already), . P3 has the first adjacent at 000 (as P5 comes later in list) . P4 has the adjacent at 011 (as P3 has visited already), . P5 has the first adjacent at 011 (it has 4-adjacents, where, P3 & P4 are already visited, and for P6 & P7, P6 comes first in the adjacent list), . P6 has its adjacent at 010, . P7 has its adjacent at 010, . P8 has its adjacent at 011,

© 2018 SWANSEA PRINTING TECHNOLOGY LTD 3072 TAGA JOURNAL VOL. 14 ISSN: 1748-0345 (Online) www.tagajournal.com

. Contour ends at P9. With these adjacent location, the Binary Chain Code (BCC) is constructed by arranging them in sequence as given below: {111, 111, 000, 011, 011, 010, 010, 011}

E. Pattern-based Chain Coding

The chain codes are efficient than DSLS method, however it suffers with redundancy. The redundant chain codes can be simplified by finding the pattern in the chain code and replace them with special symbols. A simple and efficient Pattern-based Chain Coding(PCC) approach to remove the redundant code is proposed here.

It is a four step algorithm to reduce the chain code length, the basic idea of this pattern finding approach is replace the successive multiple occurrences with its run-length and finding the pattern of two successive symbols with another new symbol. Initially the binary chain code is replaced with uppercase alphabets starting from A to H. This is to avoid the when the binary strings are replaced with its run-length. Table 1 shows the uppercase alphabet substituted for each binary string in the chain code.

TABLE I. ALPHABETS FOR BINARY CHAIN CODES Binary String Alphabet 000 A 001 B 010 C 011 D 100 E 101 F 110 G 111 H

At the first step of chain code compression, for each alphabet, its successive count is calculated and the chain code is replaced with the alphabet-symbol followed by its run-length. The run-length coding is done only for the symbol-alphabet which has more than one count.

For example, consider the following chain code of 90 symbols, it has 6 different symbols {A, B, C, D, E, F}, requires 3-bits to code each, hence it takes 90 × 3 = 270 bits of storage space.

‘AAAAAAFFDADADADADADADADADADADADADADADABBBBBBBBBBBBBBEBEBEBCCEE EEEEEFFBBBAAABBBAAABBBFFABCD’

changed the following chain code as A occurs 6 times, F occurs 2 times, B occurs 14 times, C occurs 2 times, and E occurs 7 times, etc., for the alphabets which are occurring without successive occurrence, are copied once without their run length. The reduced chain code is

'A6F2DADADADADADADADADADADADADADADAB14EBEBEBC2E7F2B3A3B3A3B3F2ABCD'

For the memory usage, the code has 12 distinct symbols {1, 2, 3, 4, 6, 7, A, B, C, D, E, F} needs 4-bits to code each, and for the length of 65 symbols it takes, 65 × 4 = 260 bits of memory space.

© 2018 SWANSEA PRINTING TECHNOLOGY LTD 3073 TAGA JOURNAL VOL. 14 ISSN: 1748-0345 (Online) www.tagajournal.com

In the next step, the reduced chain code is searched for two-symbol pattern and if it has multiple occurrence, then the pattern is replaced with a next symbol estimated from the ASCII sequence. A symbol table T1 is constructed to store the two-symbol pattern, and the starting ASCII symbol for T1 is stored as pattern symbol s1. For example, consider the chain code from the previous step,

'A6F2DADADADADADADADADADADADADADADAB14EBEBEBC2E7F2B3A3B3A3B3F2ABCD'

The two-symbol patterns identified from the above chain code are DA and EB, they are replaced with the next ASCII symbols I and J respectively, since we have reserved the alphabets A to H for binary coding. Hence the code is changed as

'A6F2IIIIIIIIIIIIIIIB14JJJC2E7F2B3A3B3A3B3F2ABCD'

where the symbol table, T1 is constructed as shown below, DA EB and the pattern symbol s1 is assigned with the symbol ‘I’. For the memory usage, the current code has 14 unique symbols {1, 2, 3, 4, 6, 7, A, B, C, D, E, F, I, J} requires 4 bits to code, so for the length of 47 symbols it occupies, 47 * 4 = 188 bits of space, with 20 bits of space for two symbol table and one pattern symbol entries. In total, this code would take 188+20 = 208 bits.

Further, the pattern with one symbol followed by a number is identified and if it has more than one occurrence, then the pattern is replaced with the next ASCII symbol in the sequence. Another symbol table T2 is created to store the new patterns identified in this step, and the starting ASCII symbol for T2 is stored as pattern symbol s2.

For example, consider the previous chain code, the identified symbol-number pattern are F2, B3 and A3, they will be replaced with the next ASCII symbols K, L and M, and the pattern-symbol is stored with ‘K’.

'A6KIIIIIIIIIIIIIIIB14JJJC2E7KLMLMLKABCD'

And the symbol table T2, will be updated as F2 B3 A3 For the memory usage, the reduced code has 15 distinct symbols {1, 2, 4, 6, 7, A, B, C, D, E, I, J, K, L, M}, takes a memory space 39 * 4 + 20 (for T1 & s1) + 28 (for T2 & s2) = 204 bits of storage space, and still it is costlier than the original.

In the final step, the reduced chain code is further searched for symbols with multiple occurrences. The identified symbols are then replaced with their run-length as discussed in the first step. Consider the previous chain code, it will be reduced as

'A6KI15NB14J3NC2E7KLMLMLKABCD' In the overall, the reduced chain code has 18 distinct symbols {1, 2, 3, 4, 5, 6, 7, A, B, C, D, E, I, J, K, L, M, N}, which requires 5 bits to code each. For the memory usage, for the length of 28 symbols, it takes, 28 * 5 + 5*5 + 7*5 = 200 bits of memory space, which is 26% less than the original chain code of 270 bits of storage. Thus the pattern based chain code reduces the length & memory space effectively.

The pattern based compression ends up with the reduced chain code after 4 levels of reduction, the code will have the following data for the compressed file.  Image dimension

© 2018 SWANSEA PRINTING TECHNOLOGY LTD 3074 TAGA JOURNAL VOL. 14 ISSN: 1748-0345 (Online) www.tagajournal.com

 Edge array ES, contains starting point & length of each contour  Reduced chain coded after pattern based compression  Symbol tables T1, T2, and the pattern-symbols s1 & s2.

The following text summarizes the proposed chain coding technique. Input – the shape image Output – the compressed file with the corresponding headers 1. Read a shape image 2. Find its contour by applying zero-crossing edge detection operator 3. Store the edge contour points into an array, CP 4. Label the edge points into three classes: starting-points, boundary-points & intersection-points 5. Collect the intersection-points and label them effectively to segment the contours 6. Store all the starting points into an array, ES 7. For each starting point in E a. Construct the binary chain code with adjacent boundary-points b. Mark the last point as end-point, and remove this point from ES c. Also, store the length of the contour in ES 8. Collect the binary codes of each contour to form the complete chain code 9. Pattern-based chain code compression a. Replace the binary strings with the uppercase alphabets from A to H b. Find the successive occurrence of each alphabet and replace them with the symbol followed by its run-length c. Find the two-symbol pattern and replace them with a new symbol d. Find the symbol-number pattern and replace them with a new symbol e. Find the successive occurrence of each symbol and replace them with the symbol and its run- length. 10. Store the appropriate headers: image dimension, ES, reduced chain code, symbol tables and the pattern- symbols.

The decoding step starts with the pattern-based chain code. At the first step, the symbols followed with a run-length are identified and they are replaced by duplicating the symbol for the specified number of times. For example, consider the PCC at the last step of pattern-based chain code, 'A6KI15NB14J3NC2E7KLMLMLKABCD' will be decoded as'A6KIIIIIIIIIIIIIIIB14JJJC2E7KLMLMLKABCD' Similarly the remaining levels of PCC are performed in reverse order to reach the original chain code. A blank image is constructed with white background to draw the contours. For each starting point in ES, the contour starts by plotting the contour point at initial (x,y) followed by finding the next contour points direction from the binary chain code and plot them till the end of the contour length. And this procedure is repeated to decode the original shape.

IV. EXPERIMENTS & RESULTS

The experiments are carried out with two benchmark shape datasets: Gatorbait contains the silhouettes of 38 fishes belonging to 8 categories, and the MPEG7 dataset contains 1400 object contours belonging to 70 categories, with 20 members per each category. All the images are in binary form. Figure 11 & 12 shows the random shape samples taken from both the dataset.

https://www.cise.ufl.edu/~anand/GatorBait_100.tgz http://www.dabi.temple.edu/~shape/MPEG7/MPEG7dataset.zip

© 2018 SWANSEA PRINTING TECHNOLOGY LTD 3075 TAGA JOURNAL VOL. 14 ISSN: 1748-0345 (Online) www.tagajournal.com

Figure 11. Shapes from Gatorbait Dataset

Figure 12. Shapes from MPEG7 Dataset

Table 2 presents the performance comparison between Binary Chain Coding (BCC) and Pattern-based Chain Coding (PCC) based on length of the code, number of symbols used and its memory size for a set of sample shapes from Gatorbait dataset. The lower length and the minimal memory space requirement of PCC states the significant performance improvement.

TABLE II. PERFORMANCE COMPARISON BETWEEN BCC AND PCC

Binary Chain Coding Pattern-based Chain Coding

Chain code Memory size (in Chain code Memory size (in No. of symbols No. of symbols Length kB) Length kB) Fish1 22176 2 2.73 2379 133 2.32 Fish2 19791 2 2.44 2140 124 2.09 Fish3 23133 2 2.85 2412 138 2.35 Fish4 22584 2 2.78 2400 129 2.34 Fish5 15960 2 1.97 1452 112 1.42 Fish6 15687 2 1.94 1464 105 1.43 Fish7 16533 2 2.04 1472 105 1.43 Fish8 17985 2 2.22 1486 119 1.45 Fish9 27840 2 3.43 1918 123 1.87 Fish10 23316 2 2.88 1577 113 1.54

The coding performance is measured with the compression ratio achieved by the proposed method and compared with the existing methods JBIG, MJBIG, MDF9, DSLSC and DSaM where the first three approaches are lossless compression methods and the later are lossy compressions. Table 3 and 4 depicts the compression ratio of the shape coding method for Gatorbait and MPEG7 datasets. The average performance for each dataset is shown in Table 5. Figures 13 & 14 depicts the performance comparison for both dataset. The proposed PCC method has lower compression ratio than any other method, indicates the superior performance of it

© 2018 SWANSEA PRINTING TECHNOLOGY LTD 3076 TAGA JOURNAL VOL. 14 ISSN: 1748-0345 (Online) www.tagajournal.com

.

TABLE III. PERFORMANCE COMPARISON ON COMPRESSION RATIO FOR GATORBAIT DATASET SHAPES

PCC MDF9 MJBIG JBIG DSaM DSLSC Fish1 0.0604 0.0772 0.0843 0.0858 0.0890 0.0980 Fish2 0.0505 0.0556 0.0722 0.0733 0.0892 0.0908 Fish3 0.0555 0.0718 0.0835 0.0941 0.1004 0.1049 Fish4 0.0594 0.0643 0.0752 0.0908 0.1014 0.1197 Fish5 0.0632 0.0818 0.1001 0.1188 0.1221 0.1252 Fish6 0.0646 0.0716 0.0773 0.0799 0.0919 0.1085 Fish7 0.0563 0.0603 0.0754 0.0868 0.0921 0.1028 Fish8 0.0482 0.0532 0.0683 0.0777 0.0907 0.1107 Fish9 0.0484 0.0607 0.0683 0.0686 0.0823 0.0839 Fish10 0.0506 0.0600 0.0714 0.0781 0.0931 0.1019

TABLE IV. PERFORMANCE COMPARISON ON COMPRESSION RATIO FOR MPEG7 DATASET SHAPES

PCC MDF9 MJBIG JBIG DSaM DSLSC Apple 0.0275 0.0362 0.0532 0.0616 0.0772 0.0819 Bat 0.0446 0.0629 0.0753 0.0763 0.0841 0.0911 Butterfly 0.0255 0.0291 0.0361 0.0542 0.0590 0.0755 Camel 0.0409 0.0462 0.0564 0.0753 0.0834 0.0837 Chicken 0.0417 0.0447 0.0527 0.0625 0.0644 0.0653 Crown 0.0428 0.0455 0.0470 0.0568 0.0594 0.0628 Deer 0.0271 0.0445 0.0493 0.0560 0.0749 0.0879 Elephant 0.0334 0.0450 0.0475 0.0655 0.0846 0.0992 Tree 0.0306 0.0416 0.0453 0.0527 0.0642 0.0771 Turtle 0.0414 0.0443 0.0491 0.0513 0.0525 0.0615

TABLE V. AVERAGE PERFORMANCE COMPARISON ON COMPRESSION RATIO

PCC MDF9 MJBIG JBIG DSaM DSLSC Gatorbait 0.0617 0.0756 0.0876 0.0854 0.0972 0.1246 MPEG7 0.0415 0.0484 0.0576 0.0723 0.0992 0.1078

0.1400

0.1200

0.1000

0.0800

0.0600

0.0400

0.0200

0.0000 0 2 4 6 8 10 12

PCC MDF9 MJBIG JBIG DSaM DSLSC

Figure 13. Compression Performance Analysis for Gatorbait dataset

© 2018 SWANSEA PRINTING TECHNOLOGY LTD 3077 TAGA JOURNAL VOL. 14 ISSN: 1748-0345 (Online) www.tagajournal.com

0.1200

0.1000

0.0800

0.0600

0.0400

0.0200

0.0000 0 2 4 6 8 10 12

PCC MDF9 MJBIG JBIG DSaM DSLSC

Figure 14. Compression Performance Analysis for MPEG7 dataset

V. CONCLUSIONS

A novel shape coding is proposed here for edge contour based image compression. At first the shape contour is extracted and segmented. Then the initial contour is constructed with binary strings to represent the adjacent contour points. The Binary Chain Code (BCC) is compressed further by finding the redundant pattern in it. The Pattern-based Chain Code (PCC) is performed at four different levels to reduce the length and size of BCC. The experiments are carried out with two benchmark datasets, and the compression ratio of the proposed PCC based shape coding is compared with other recently proposed shape coding techniques. The simulation results indicate that the proposed PCC outperforms the shape coding methods.

References

[1] Aghito, S. M., &Forchhammer, S. (2004, March). “Context based coding of binary shapes by object boundary straightness analysis” In Conference, 2004. Proceedings. DCC 2004 (pp. 399-408). IEEE. [2] Aghito, S. M., &Forchhammer, S. (2006). “Context-based coding of bilevel images enhanced by digital straight line analysis” IEEE Transactions on Image Processing, 15(8), 2120-2130. [3] Aghito, S. M., &Forchhammer, S. (2007). “Efficient coding of shape and transparency for video objects” IEEE Transactions on Image Processing, 16(9), 2234-2244. [4] Akimov, A., Kolesnikov, A., &Fränti, P. (2007). “Lossless compression of map contours by context tree modeling of chain codes” Pattern Recognition, 40(3), 944-952. [5] Bribiesca, E. (1999). “A new chain code” Pattern Recognition, 32(2), 235-251. [6] Freeman, H. (1974). “Computer processing of line-drawing images” ACM Computing Surveys (CSUR), 6(1), 57-97.

© 2018 SWANSEA PRINTING TECHNOLOGY LTD 3078 TAGA JOURNAL VOL. 14 ISSN: 1748-0345 (Online) www.tagajournal.com

[7] Gerogiannis, D. P., Nikou, C., &Kondi, L. P. (2015, September). “Shape encoding for edge map image compression” In Image Processing (ICIP), 2015 IEEE International Conference on (pp. 1563-1567). IEEE. [8] Gerogiannis, D., Nikou, C., &Likas, A. (2014). “Modeling sets of unordered points using highly eccentric ellipses” EURASIP Journal on Advances in Signal Processing, 2014(1), 11. [9] Hsiao, C. W., Ding, J. J., & Chen, P. J. (2015, December). “Lossless contour compression using morphology, chain coding, and distribution transform” In Signal and Information Processing Association Annual Summit and Conference (APSIPA), 2015 Asia-Pacific (pp. 915-918). IEEE. [10] Katsaggelos, A. K., Kondi, L. P., Meier, F. W., Ostermann, J., & Schuster, G. M. (1998). “MPEG-4 and rate-distortion-based shape-coding techniques” Proceedings of the IEEE, 86(6), 1126-1154. [11] Kim, K. J., Suh, J. Y., & Kang, M. G. (2000). “Generalized interframe vertex-based shape encoding scheme for video sequences” IEEE transactions on image processing, 9(10), 1667-1676. [12] Klette, R., & Rosenfeld, A. (2004). “Digital straightness—a review” Discrete Applied Mathematics, 139(1-3), 197-230. [13] Kondi, L. P., Melnikov, G., &Katsaggelos, A. K. (2004). “Joint optimal object shape estimation and encoding” IEEE Transactions on Circuits and Systems for Video Technology, 14(4), 528-533. [14] Lai, Z., Zuo, Z., Wang, Z., Yao, Z., & Liu, W. (2011, September). “Accurate distortion measurement for B-spline-based shape coding. In Image Processing (ICIP)” 2011 18th IEEE International Conference on (pp. 225-228). IEEE. [15] Liu, Y. K., &Žalik, B. (2005). “An efficient chain code with Huffman coding” Pattern Recognition, 38(4), 553-557. [16] Luo, H. (2005). “Image-dependent shape coding and representation” IEEE transactions on circuits and systems for video technology, 15(3), 345-354. [17] Neuhoff, D., & Castor, K. (1985). “A rate and distortion analysis of chain codes for line drawings” IEEE Transactions on , 31(1), 53-68. [18] Nunes, P., Marqués, F., Pereira, F., &Gasull, A. (2000). “A contour-based approach to binary shape coding using a multiple grid chain code” Signal Processing: Image Communication, 15(7-8), 585-599. [19] Pinho, A. J. (2000). “A JBIG-based approach to the encoding of contour maps” IEEE transactions on image processing, 9(5), 936-941. [20] Pinho, A. J. (2001a). “Adaptive context-based of arbitrary contour maps” IEEE Signal Processing Letters, 8(1), 4-6. [21] Pinho, A. J. (2001b). “Region-based near-lossless image compression” In Acoustics, Speech, and Signal Processing, 2001. Proceedings.(ICASSP'01). 2001 IEEE International Conference on (Vol. 3, pp. 1761-1764). IEEE. [22] Richardson, I. E. (2004). “H. 264 and MPEG-4 video compression: video coding for next-generation multimedia” John Wiley & Sons. [23] Sanchez-Cruz, H. (2010). “Proposing a new code by considering pieces of discrete straight lines in contour shapes” Journal of Visual Communication and Image Representation, 21(4), 311-324. [24] Sanchez-Cruz, H., & Rodriguez-Dagnino, R. M. “Compression bi-level images by means of a 3-bit chain code” Optical Engineering SPIE. 44 (9) 097004 (2005) 1–8.

© 2018 SWANSEA PRINTING TECHNOLOGY LTD 3079 TAGA JOURNAL VOL. 14 ISSN: 1748-0345 (Online) www.tagajournal.com

[25] Sanchez-Cruz, H., López-Cruces, M., &Puga, H. (2008, February). “A proposal modification of the 3OT chain code” In Proceedings of the 10th IASTED International Conference on Computer Graphics and Imaging (pp. 6-11). ACTA Press. [26] Schuster, G. M., &Katsaggelos, A. K. (1998). “An optimal polygonal boundary encoding scheme in the rate distortion sense” IEEE Transactions on Image Processing, 7(1), 13-26. [27] Sohel, F. A., Dooley, L. S., &Karmakar, G. C. (2007). “New dynamic enhancements to the vertex- based rate-distortion optimal shape coding framework” IEEE Transactions on Circuits and Systems for Video Technology, 17(10), 1408-1413. [28] Sohel, F. A., Karmakar, G. C., Dooley, L. S., &Bennamoun, M. (2011). “Geometric distortion measurement for shape coding: A contemporary review” ACM Computing Surveys (CSUR), 43(4), 29. [29] Sohel, F. A., Karmakar, G. C., Dooley, L. S., &Bennamoun, M. (2012). “Sliding-window designs for vertex-based shape coding” IEEE Transactions on Multimedia, 14(3), 683-692. [30] Wang, H., Schuster, G. M., Katsaggelos, A. K., & Pappas, T. N. (2003). “An efficient rate-distortion optimal shape coding approach utilizing a skeleton-based decomposition” IEEE Transactions on Image Processing, 12(10), 1181-1193. [31] Wulandhari, L. A., &Haron, H. (2009, April). “Characteristic of rectangular vertex chain code for shapes with hole” In Information Management and Engineering, 2009. ICIME'09. International Conference on (pp. 648-650). IEEE. [32] Žalik, B., &Lukac, N. (2014). “Chain code lossless compression using move-to-front transform and adaptive run-length encoding” Signal Processing: Image Communication, 29(1), 96-106. [33] Zhu, Z., & Jiang, G. (2014). “Hybrid scheme for efficient shape coding” Digital Signal Processing, 30, 131-140.

© 2018 SWANSEA PRINTING TECHNOLOGY LTD 3080 TAGA JOURNAL VOL. 14