# Texture Construction Edge Detection Algorithm
## 2 Texture Construction Edge Detection Algorithm
### Optimal Edge Thinning Process  
The optimal edge thinning process includes the two steps of non-maximum suppression and the thinning texture template process to achieve optimal edge thinning. Since the edge segments obtained by the pre-processing steps have different thicknesses, to simplify the subsequent analysis and determine the texture change combination required for edge construction, the edge thinning processing is indispensable. First, the non-maximum suppression method uses the gradient angle obtained by Equation (6) and divides it into four directions, according to the degree of approximation: \(0^{\circ}\) (i.e., horizontal), \(45^{\circ}\) (i.e., upper right and lower left), \(90^{\circ}\) (i.e., vertical), and \(135^{\circ}\) (i.e., upper left and lower right). Then, it compares the gradient amplitude of the two pixels adjacent to the center pixel according to the gradient direction of the center pixel. When the gradient amplitudes of the two adjacent points are smaller than that of the center pixel, the center pixel is included as a candidate edge point. Conversely, the center pixel is not included as a candidate edge point. Although the method of non-maximum suppression can achieve preliminary thinning processing, there are still many redundant pixels in the candidate edge image after non-maximum suppression. To filter the redundant pixels processed by the maximum suppression method, a block texture distribution with a center pixel as a redundant pixel is proposed to develop a set of thinning texture templates and a thinning texture template is used to filter out redundant pixels to achieve optimal edge thinning. The redundant pixel filtering process uses a raster-scan method to perform a 3 \(\times\) 3 pixels block texture comparison on the non-maximum suppressed candidate edge image. When the block texture matches the defined thinning texture template, the redundant pixel in the center of the block is deleted. Figure 2 shows an example of the thinning process. Figure 1: Noise filtering process. (**a**) Original image (\(640\times 427\)) [17]; (**b**) gradient change image before noise filtering; (**c**) gradient change image after noise filtering. When the block texture of the \(3\times 3\) pixels covered by the center pixel \(x\) conforms to the proposed thinning texture template, it is judged as a redundant pixel and gets filtered out. Then, it gets right-shifted to make the judgment of the block texture change of the next point, until the processing of the entire candidate edge image is completed; thus, the image with optimal edge thinning can be obtained. Next, a method of binarizing the edge texture changes in the block will be described to facilitate subsequent analysis and processing. Figure 3 illustrates the binary coding method showing the change in block texture. When the pixel gradient amplitude value is not 0, the code is \"1\", and otherwise, it is \"0\". The coding order starts from the upper left corner of the block and goes in order from left to right and top to bottom. There are up to four texture changes through angle rotation, i.e., 0\({}^{\circ}\), 90\({}^{\circ}\), 180\({}^{\circ}\), and 270\({}^{\circ}\), in the block. Therefore, after the process of binarization coding is completed, the block binarization coding of the four rotation angles is obtained by changing the bit arrangement order. Figure 4 shows the coding order of the different angles in the block. Figure 4a shows the block coding order of 0\({}^{\circ}\) and a coding order of 123456789. Figure 4b shows the block coding order of Figure 4a with a rotation of 90\({}^{\circ}\) to the left and a coding order of 369258147. Figure 4c shows the block coding order of Figure 4a with a rotation of 180\({}^{\circ}\) to the left and a coding order of 987654321. Figure 4d shows the block coding of Figure 4a with a rotation of 270\({}^{\circ}\) to the left and a coding order of 741852963. Figure 4: Binary coding order of different angles in a block.