The Image Skeleton Extraction Algorithm Based on Highest Rectangle

. Currently, the thinning algorithms based on the template have no completeness, so there are more error-retention and error-deletion pixels in their thinning results. In this article, using the highest rectangle which can not be eliminated, we put forward a new image-skeleton-extraction algorithm. Because the highest rectangle has completeness, there are no error-retention and error-deletion pixels in its thinning results. The algorithm can effectively eliminate the fracture phenomenon that is generated in the traditional algorithm. At the same time, the skeleton-thinning width is only one pixel, and it achieved to the ideal state. Experiments proved that the thinning result of this algorithm is more effective, and its operational efficiency is better.


Introduction
With the adoption of medical imaging equipment, a growing number of medical image data is stored in the database [1] .The medical images can provide a variety of characteristic information for diseases and pathological diagnosis, and can provide functional information for identifying diseased tissue or organs.Today, how to quickly and effectively segment those images is a medical problem with challenging [2][3] .The commonly used algorithms include the quick thinning algorithm and OPTA (one-pass-thinning algorithm) algorithm.But we usually used the improved OPTA algorithm [4][5][6][7][8] .Currently, there many thinning methods based on PCNN (third-generation artificial neural network) were proposed.But these algorithms can easily produce error branch, break points and burrs.In this article, using the highest rectangle which can not be eliminated, we put forward a new image-skeleton-extraction algorithm.Because the highest rectangle has completeness, there are no error-retention and error-deletion pixels in its thinning results.The algorithm can effectively eliminate the fracture phenomenon.At the same time, the skeleton-thinning width is only one pixel, and it achieved to the ideal state.

The image skeleton extraction algorithm based on highest rectangle
The related definitions and theorems As shown in Figure 1, each small square is a pixel, the light-gray square is edge points and the white square is non-edge points.Figure1a is an image that will be extracted its skeleton.Definition 1, the highest rectangle: To scan each line in an image in order, When it scans the first edge-pixel point ) , ( 1 , look the coordinates ) , ( 11 j i as the upper left corner of a rectangular, continue to scan the line, until it metes the first non-edge points or the image border, and note the number of edge pixels in this line as 1 k .Then, scan the next line starting from the column 1 j , and note its edge-pixel number 2 k .Loop for scanning each line in the image as this, until the pixel in the next line is a non-edge point or the image border.Record the scanned number h and the edge-pixel number ) ,..., 2 , 1 ( 1 j i as the upper left corner coordinates, w as the width, h as the height of a rectangle, so this rectangle is called the highest rectangle.The highest rectangle a and b are shown in Figure 3b.As for the searched highest rectangle, in order to distinguish the pixels in highest rectangle with the other non-edge pixels and the non-edge pixels, we use a special color (such as ) as the pixel color in the highest rectangle.Definition 2, the excluding highest rectangle and non-excluding highest rectangle: while a top highest rectangle is on the top of the highest rectangle and a right-top highest rectangle is on its right, then we call this rectangle as excluding rectangle, other wise call it as non-excluding rectangle.As shown in the Figure 1, b and c are non-excluding rectangles, and e is an excluding highest rectangle.Definition 3, core: the center coordinates ) , ( j i in a non-excluding highest is called a core of the non-excluding rectangle.As shown in the Figure 1, the deep-color pixels is the core of the highest rectangle a.As for the searched non-excluding highest rectangle, in order to distinguish its pixels with other edge pixels, non-edge pixels and the highest rectangle pixels, we use a special color (such as ) 0 , 0 , 0 ( RGB ) as the pixel color of the non-excluding highest rectangle.Definition 4, edge-skeleton line: Considering the two cores in two non-excluding rectangles as the end points, the line connecting the two end points is called edge-skeleton line.Theorem 1, the highest rectangle has the completeness characteristic, that is to say that any edge image formed by edge detection, will be covered with highest rectangles.Prove: Suppose that there is an edge image formed by edge detection, and a pixel in it is not covered by any highest rectangle.From the definition of highest rectangle, when it scan the point in the image-scanning process, it can form a highest rectangle whose top-left corner is this pixel and its width and height are all 1 pixel.To use this rectangle to cover the edge points, then there is no edge point that is not covered by a highest rectangle.It is contradictory to the assumption there is a pixel not covered by any highest rectangle.So any edge image formed by edge detection， will be covered with highest rectangles.That is to say the highest rectangle has the completeness characteristic.Theorem 2, any edge pixel in an edge image belongs to one but only one highest rectangle.Prove: Assume the value of an edge pixel is ) , ( j i f , (Where i<= image width, j <= image height), from the definition 1, when we search the highest rectangles, the scanning order is from top to bottom and from left to right.The coordinates ) , ( j i belong to the coordinates in the image, so the point ) , ( j i will be scanned during the scanning process.Because the value ) , ( j i f of point ) , ( j i is the edge value, therefore, the point ) , ( j i may belong to the current highest rectangle.①When it belongs to the current highest rectangle, from the definition 3, we have to modify the value ) , ( j i f , that is to say this point is no longer an edge point, so it is not considered to belong to another highest rectangle at next scanning time.So it belongs to one but only one highest rectangle ②When it does not belong to the current highest rectangle, from the definition 3, we do not modify the value ) , ( j i f , that is to say this point is still an edge point, so it is considered to belong to another highest rectangle at next scanning time.So it belongs to one but only one highest rectangle So, any edge pixel in an edge image belongs to one but only one highest rectangle.Theorem 3, the edge-skeleton width of an edge image formed by any edge detection is only 1 pixel.Prove: A skeleton line is formed by a straight line, is the connection between the two core point.From the theorem 2, any edge pixel in an edge image belongs to one but only one highest rectangle, that is to say there is only one core in any non-excluding highest rectangle.Therefore, there is only one line between two highest rectangles.Because the size of the core point is a pixel, and coordinates of two end points of the line is the only two points, so, the width of the line must be one pixel, that is to say the edge-skeleton width is only 1 pixel.Therefore, the edge-skeleton width of an edge image formed by any edge detection is only 1 pixel.The data structure in the algorithm From the theorem 2: any edge pixel in an edge image is covered by one but only one highest rectangle.Therefore, when we search for the highest rectangles in an edge image, after an edge point are covered by a highest rectangle, and in order to make the point does not to be scanned again and does not to be covered by another highest rectangle, the algorithm using a special data structure to store the state that express if the point is covered by a highest rectangle.While connecting the edge-skeleton line, if the scanning highest is not a non-excluding highest rectangle, we should find if there are non-excluding highest rectangles on the top, left and right of this non-excluding highest rectangle.If there is one, we must connect the cores of the two non-excluding highest rectangles.In order to find these non-excluding rectangles, we must store the core coordinates ) , ( h h j i of the non-excluding rectangle in each pixel of the non-excluding rectangle.Therefore, the algorithm designs a data structure to store the three data of a non-excluding rectangular.Its definition is as follows: public struct zdzb// Define the storage structure of the highest rectangle { public bool zhongdian; public int zhongdianx; public int zhongdiany; }

Emerging Engineering Approaches and Applications
The basic steps of the algorithm As shown in Figure 1a, the image is the enlargement edge image that was dealt by edge detection and binarization, each square represents a pixel, a light gray square is an edge pixel, and a white square is a non-edge pixel.It is a skeleton-extraction process of an edge image as shown in figure 1.According to the above the storage structure of a highest rectangle, we can extract the skeleton of the image as following steps: ①To scan the image from left to right, and from top to bottom, and find out a highest rectangle, if it find a highest rectangle then go to the step ②, otherwise end the algorithm; ②After found out a highest rectangle, determine whether the highest rectangle is a non-excluding highest rectangle, if it is a non-excluding highest rectangle then go to the step ③, otherwise go to the step ⑦; ③ To fill the information of zhongdian, zhongdianx and zhongdiany in each pixel in the non-excluding rectangle; ④Determine whether there is a non-excluding highest rectangle on the left of this non-excluding highest rectangle, if there is one, then connect the line between the two cores of two non-excluding highest rectangle; ⑤Determine whether there is a non-excluding highest rectangle on the right of this non-excluding highest rectangle, if there is one, then connect the line between the two cores of two non-excluding highest rectangle; ⑥Determine whether there is a non-excluding highest rectangle on the top of this non-excluding highest rectangle, if there is one, then determine whether there are two non-excluding highest rectangles on the left and the right of this non-excluding highest rectangle, if there is none then connect the line between the two cores of this non-excluding highest rectangle and its top non-excluding highest rectangle; ⑦To fill the information of zhongdian in each pixel in the non-excluding rectangle; ⑧Go to step ① to scan the next pixel, until finish to scan the edge image.

The algorithm of searching for the highest rectangle
The step ① of the algorithm will search for all of the highest rectangle in the edge image, the searching process is as definition 1.The characteristic of the searching algorithm is that each searching line is relative to top-left-corner coordinates of the rectangle.Suppose the first searched edge pixel is ) , ( 11 y x , and the edge-pixel number which is along the vertical y is h , let h y y + = 1 2 .Assume the starting point of step i is column 1 x , the searched continuous pixel number in the line h i + is i k .So the rectangular height is: ) , ,..., , min( , then the coordinates of the top-left and right-bottom corner of the highest rectangle is respectively ) , ( 11 y x and ) , ( 11 y x .Thus, the searching algorithm of a highest rectangle is as follows: for i ← 1 to Height for j ← 1 to Width// To scan the edge image from left to right and from top to bottom c1 ←GetPixel(j, i);// Get the data of each pixel if (c1.R= 0) then lefty ← i;leftx ← j;gao ← 0;kuan ← Width ;c1 ←GetPixel(j, i); while (lefty < Height-1 && c1.R = 0) do gao++;kuan1 ← 0 while (leftx < Width && c1.R = 0) do c1 ←GetPixel(leftx, lefty) ; kuan1++;leftx++ if(kuan1-1<kuan) then kuan←kuan1-1 lefty++; leftx ← j ; c1 ←GetPixel(leftx, lefty) leftx ← I;lefty ← j;rightx ← i + gao -1;righty ← j + kuan -1 Advanced Engineering Forum Vol. 1 The judgment rules of non-excluding highest rectangle and its algorithm When searched a highest rectangle, we must first determine it is an excluding or non-excluding highest rectangle.Its judgment rules is as definition 4, and the algorithm is as follows: if(leftx-1>←0)// Determine whether the above line pixels is in the edge image then for j1 ← lefty to righty // Scan the above line of the highest rectangle c1 ←GetPixel(j1, leftx  1a, the image is the enlargement edge image that was dealt by edge detection and binarization, each square represents a pixel, a light gray square is an edge pixel, and a white square is a non-edge pixel.After the step ① of the algorithm, it gets the highest rectangles a-q which covered all the edge points of the edge image, it is shown as Figure 4b.After the step ② of the algorithm, it gets the non-excluding highest rectangles and their cores, the result is shown as Figure 4c.After the step ② of the algorithm, it used DDA algorithm to connect the cores of the two neighboring non-excluding highest rectangles, and fill them with the skeleton-filling color, so it gets the finally edge-skeleton line, it is shown as Figure 1d.According to the results in Figure 3, we can see that: The extraction skeleton form the algorithm in reference [8] is not robust, its break points is too many, the skeleton line is not too smooth, Accidentally deleted more skeleton points, its deformation is too much, and its time complexity is higher.At the same time, we can found that: The extraction skeleton form the algorithm based on highest rectangle is more robust, its break points is little, the skeleton line is more smooth, Accidentally deleted skeleton points is little, its deformation is small, and its time complexity is lower.

Emerging Engineering Approaches and Applications
-1) // Get the value of each pixel if (zd[j1,leftx-1].zhongdian= 1)// whether it is a non-excluding highest rectangle then tichushang←true; break if (righty +1 <= Width) // whether the right column line pixels is in the edge image then for (i1 ← leftx to rightx // Scan the right column of the highest rectangle c1 ←.GetPixel(righty+1,i1 ) // Get the value of each pixel if (zd[righty + 1, i1].zhongdian =1) then tichuyou ← true; break As shown in Figure 3b, b and c are non-excluding rectangles, and e is an excluding rectangle.An example of the image skeleton extraction algorithm based on highest rectangle As shown in Figure

aFig. 1
Fig.1 An example of the image skeleton extraction algorithm based on highest rectangleExperiment and comparative analysis of the algorithmsThe experimental environment is: CPU is AMD Athlon (tm) 64 X2 Dual Core Processor 3600+, its frequency is 2GHz; the memory is 1G; Operation system is Microsoft Windows XP Professional Service Pack 3; the programming language is Visual C#.net 2005.The experiment selected medical image database on China Medical Imaging, and selected 10images in it.After their edge detection, experiment them with the image skeleton extraction algorithm based on highest rectangle and the skeleton-extraction in reference[8].The result is as figure3.According to the results in Figure3, we can see that: The extraction skeleton form the algorithm in reference[8] is not robust, its break points is too many, the skeleton line is not too smooth, Accidentally deleted more skeleton points, its deformation is too much, and its time complexity is higher.At the same time, we can found that: The extraction skeleton form the algorithm based on highest rectangle is more robust, its break points is little, the skeleton line is more smooth, Accidentally deleted skeleton points is little, its deformation is small, and its time complexity is lower.