Improved Vertex Chain Code Based Mapping Algorithm for Curve Length Estimation

: Problem statement: Image representation has always been an important and interesting topic in image processing and pattern recognition. However, curve tracing and its relative operations are the main bottleneck. Approach: This research presents the mapping algorithm that covers one of the vertex chain code cells, the rectangular-VCC cell. The mapping algorithm consists of a cell-representation algorithm that represents a thinned binary image in rectangular cells, a transcribing algorithm that transcribes the cells into vertex chain code and a validation algorithm that visualizes vertex chain code into rectangular cells. Results: The algorithms have been tested and validated by using three thinned binary images: L-block, hexagon and pentagon. Conclusion/Recommendations: The results show that this algorithm is capable of visualizing and transcribing them into vertex chain code.


INTRODUCTION
Image representation is an important component in image processing and pattern recognition. One of the ways to represent an image simply and efficiently is by using chain code. The first use of chain code was introduced by Freeman known as Freeman chain code (FCC). The code follows the contour counter-clockwise and keeps track of the direction from one contour pixel to the next (Saaid et al., 2009;Habibi et al., 2009;Jahanshah et al., 2009). The codes involve 4-connected and 8-connected paths. Figure 1(a) shows 4-connected and Fig. 1

(b) shows 8-connected FCC
In the 8-connected FCC, each code can be considered as the angular direction, in multiples of 45 0 , through which we must move to go from one contour pixel to the next. Figure 2 shows an example of Freeman Chain Code using an 8-connected path.
In general, a coding scheme for line structures must satisfy three objectives (Abdullah et al., 2009). First, it must faithfully preserve the information of interest; second, it must permit compact storage and be convenient for display. Finally, it must facilitate any required processing. The three objectives are somewhat in conflict with each other, and any code necessarily involves a compromise among them.  Some important characteristic of the VCC as described in Qicai et al., 2009;Al-Omari et al., 2009;Selvan et al., 2010) are first, the VCC is invariant under translation and rotation, and optionally may be invariant under starting point and mirroring transformation. Second, using the VCC it is possible to represent shapes composed of triangular, rectangular, and hexagonal cells (Fig. 3). Thirdly, the chain elements represent real values not symbols such as other chain code; are part of the shape; indicate the number of cell vertices of the contour nodes; and may be operated for extracting interesting shape properties. Finally, using VCC it is possible to obtain relations between contours and the interior of the shape.
In the Vertex Chain Code, the boundaries or contours of any discrete shape composed of regular cells can be represented by chains. Therefore, these chains represent closed boundaries. The minimum perimeter of a closed boundary corresponds to the shape composed of only one cell. An element of a chain indicates the number of cell vertices, which are in touch with the bounding contour of the shape in that element position (Kumar et al., 2009). Figure 4 shows the Vertex chain code of Rectangular-VCC cells, indicating the number of cell vertices, in touch with the bounding contour of the rectangle in that element position. This paper presents an algorithms used to derive the rectangular cells of VCC from a thinned binary image, transcribed cells into vertex chain code and visualize the vertex chain code again into rectangular cells for validation. The algorithm is tested and validated using three thinned binary images: L-block, hexagon, and pentagon.

MATERIALS AND METHODS
The mapping algorithm of rectangular-VCC consists of four processes: pre-processing, cellrepresentation, transcribing, and validation, as shown in Figure 5. Pre-processing is the step of thinning a binary image into a thinned binary image. The thinned binary image is then represented by rectangular-VCC cells in the cell-representation process. The next process is to transcribe the rectangular-VCC cells into vertex chain code, the transcribing process. Last is the validation process; in which the vertex chain code is visualized into rectangular cells to validate the cell-representation and transcribing algorithms. The result of the validation will show the similarity between the visualization thinned binary image into rectangular cells and the visualization vertex chain code into rectangular cells. These last three processes, the cell-representation, transcribing and validation algorithms are called the mapping algorithm. Finally, mapping algorithm is presented. Pre-processing: This algorithm takes thinned binary image as input. Binary images have only two possible intensity values pixels and are normally displayed as black and white. Numerically, the two values are normally 0 for black and, either 1 or 255 for white. In the simplest case, an image may consist of a single object or several separated objects of relatively high intensity. In order to create the two-valued binary image, a simple threshold may be applied so that all the pixels in the image plane are classified into foreground (actual object) and background pixels. A binary image function can then be constructed such that pixels above the threshold are foreground ("1") and below the threshold represent background ("0") ( Fig. 6).
For several purposes a binary image needs to be thinned. A thinned binary image is a binary image whose width is reduced to a single pixel (Fig. 7). The thinning process (Sikong et al., 2010) is an important pre-processing step in pattern analysis because it reduces memory requirements for storing the essential structural information presented in pattern. For this purpose, the thinning algorithm is created in ) is applied. This thinning algorithm uses two-valued connectivity rules. The pixel of 1 will be replaced by pixel 0 when the number of pixels 1 of the neighbouring eight directions of connectivity pixel is greater than 3.
In this algorithm, every element of the thinned binary image is declared as an array variable. And all the operations of the images are according to rows and columns.
The mapping algorithm of rectangular-VCC: The Cell-representation Algorithm: The visualizing algorithm of Rectangular-VCC is an algorithm that represents a thinned binary image as rectangular cells. The algorithm has two-valued connectivity thinned binary images as input. Each code 1 in the thinned binary image represents each form of the rectangular cell. The direction of code 1 adjacent to another code 1 leads to the formation of the next rectangle. Figure 8 shows the representation of Rectangular-VCC formatted by the direction of code 1 adjacent to another code 1. When each code in the binary image is visualized, a line drawing consisting of rectangle cells will be created (Sarabian and Lee, 2010).
The algorithm considers eight directions of code adjacent to the others. Each code 1 is compared with the other eight directions. Table 1 shows the eightdirection connectivity used in this research. Each code 1 fills one rectangle of the length 1. In this algorithm, every horizontal line is drawn from the left to the right, and every vertical line is drawn from the bottom to the top.  Based on these rules, the visualizing algorithm of rectangular VCC is created. The pseudo code of cellpresentation is presented in Appendix 1.

Appendix 1:
Input = thinned binary image image ≠ 0 for row = 1 to row = maxrow for column = 1 to column = maxcolum if image (row,column)= 1 then column _A = column+1 row_A = row +1 column_B = column -1 row_B = row -1 if image (row, column_A) = 1 then for x = column to x<=column_A y = row draw a horizontal line whose length = 1 from coordinate (x,y) end for end if if image (row_A, column)=1 then for y= row to y<=row_A x= column draw a vertical line whose length = 1 from coordinate (x,y) end for end if if image (row_A, column_A)=1 then x = column_A y = row_A draw a vertical line whose length = 1 from coordinate (x,y) x = column y = row_A draw a horizontal line whose length = 1 from coordinate (x,y) end if if image(row, column_B) = 1 then for x = column_B to x<= column y = row draw a horizontal line whose length = 1 from coordinate (x,y) end for end if if image(row_A, column_B) = 1 then x = column y = row draw a vertical line whose length = 1 from coordinate (x,y) x = column_B y = row_A draw a horizontal line whose length = 1 from coordinate (x,y) end if if image(row_B, column_B)=1 then x= column_B y= row draw a horizontal line whose length = 1 from coordinate (x,y) x = column y = row draw a vertical line whose length = 1 from coordinate (x,y) end if if image(row_B,column) =1 then for y = row_B to y<=row x = column draw a vertical line whose length = 1 from coordinate (x,y) end for end if if image(baris_B, column_A) then x = column_A y = row_B draw a vertical line whose length = 1 from coordinate (x,y) x = column y = row draw a horizontal line whose length = The transcribing algorithm: The transcribing algorithm converts the rectangular cells into vertex chain code. The algorithm uses 8-directions connectivity. Rectangular Vertex chain code has three different codes, namely 1, 2, and 3. The code indicates the number of cell vertices, which are in touch with the bounding contour of the shape in that element position. The algorithm focuses on the corner of each rectangular cell; the corners are named by A, B, C, and D (Fig. 9). The algorithm covers every corner of rectangle the by its own rules according to the eight-direction connectivity (Yang and Mareboyana, 2009). The algorithm that is to transcribe a thinned binary image into vertex chain code is shown in Appendix 2.
The validation algorithm: The validation algorithm of rectangular-VCC is used to validate the visualizing and transcribing algorithms. It visualizes the vertex chain code into rectangular cells again (Sarabian and Lee, 2010). It is developed by dividing the direction in two ways, namely clockwise and counter-clockwise. The algorithm visualizes the vertex chain code into rectangular cells.  It is formed according to 24 shapes of rectangular cells. Every eight-shape represents every code 1, 2, and 3. Every code except the starting point code is used by previous code. This algorithm is invariant under the starting point, so it is immaterial which that is chosen as the starting point. Table 2 shows the shape of rectangular VCC according to direction (Yang and Mareboyana, 2009). Based on Table 2, the validation algorithm of rectangular VCC is created, also divided into two directions, because the difference in direction influences the next shape of the cells. Appendix 3 shows the validation algorithm of rectangular VCC.

RESULTS
All algorithms are tested and validated using three thinned binary images, L-block, hexagon, and pentagon. Thinned binary images are transformed into rectangular-VCC by using the cell-representation algorithm, rectangular-VCC is transcribed into Vertex Chain Cod using the transcribing algorithm, and finally Table 3 shows experimental results using the cellrepresentation, transcribing, and validation algorithms. The cell-representation and transcribing algorithms are validated by using the validation algorithm that visualizes the vertex chain code into rectangular cells again. The entire algorithm is termed as mapping algorithm.
The interface: The interface of the mapping algorithm of the rectangular VCC system is programmed in Visual Basic 6. Figure 10 shows the interface for testing and validating the mapping algorithm.
Part 3 in Fig. 10 is the interface of the validation algorithm. The input is vertex chain code, then visualized into rectangular cells. The interface shows that the rectangular cell from the vertex chain code visualizing is similar to the rectangular cells from the thinned binary image visualizing. The interface shown in Fig. 10 consists of three processes involved in the mapping algorithm. The input is a thinned binary image. It is further represented as rectangular-VCC cells. The process continues by transcribing the rectangular-VCC cells into vertex chain code. The last process is to visualize the vertex chain code back into rectangular cells. The rectangular cell and code will be displayed automatically when the process is finished.

CONCLUSION
The mapping algorithm tested and validated in cellrepresentation and transcribing thinned binary images into VCC by using three thinned binary image objects, L-block, hexagon and pentagon. The results show that the cell-representation algorithm is capable of representing thinned binary image as rectangular-VCC cells. Reciprocally the transcribing algorithm is capable of transcribing the rectangular-VCC cells into vertex chain code and the validation algorithm result shows a rectangular cell that is similar with the rectangular cell from cell-representation algorithm. The entire algorithm is called the mapping algorithm of rectangular vertex chain code.