## 5 Element Technologies for Line Recognition
### Detection of Continuous Lines in a Diagram  
The continuous lines in a diagram have various thicknesses. When detecting continuous lines using the Hough transform ([PERSON] and [PERSON], 1995), a line with 2-pixel-or-more thickness may be detected as multiple lines. In order to prevent this problem, the line thinning process, as shown in Figure 11, is necessary so that the thickness of all lines in the diagram is set to 1 pixel. When the line after line thinning is called a skeleton line, the skeleton line should have the following features. First, the thickness of the skeleton line should be 1 pixel. Additionally, the skeleton line should be located at the center of the line. In addition, the skeleton line must maintain the connectivity of the original image. For this purpose, the length of the skeleton line must not be reduced compared to the length of the original line. In this study, the algorithm of [PERSON] and [PERSON] (2017) was applied for line thinning. Horizontal and vertical continuous lines are searched using pixel processing techniques. For vertical lines, black pixels are searched while moving from the top to the bottom of the image. If the coordinate of the current kernel location is (x, y), the pixel value of (x, y + 1) is investigated repeatedly until the black pixel is no longer detected. For horizontal lines, black pixels are searched while moving from the leftmost to the right of the image. The pixel value of (x + 1, y) is investigated repeatedly until no black pixel is detected. When the detection process of the horizontal and vertical lines is completed, the start and end points of the line are defined by recording the coordinates of the last pixel. Figure 11: Lining thinning. Figure 10: Removal of outline border and title area. (**a**) An image of P&ID. (**b**) After detecting one pixel of the outline, all connected pixel values are stored. (**c**) Detects and removes the title and outline area by performing the opening operation of the morphology operation. (**d**) Result of removing outline and title area of image drawing. The above pixel processing technique is effective when searching horizontal and vertical continuous lines. However, it is not easy for diagonal lines to apply this method, so a different method is applied. The method of diagonal line detection is illustrated in Figure 12. First, all continuous lines in the diagram are searched using the Hough transform. Then, horizontal and vertical lines are removed from the searched lines to construct a candidate set of diagonal lines. One line of the candidate set is drawn on an empty image. Then, the bitwise AND(\(\mathbf{\kappa}\)) operation is performed between the diagonal line drawn on the empty image and the original image so that the diagonal line overlapping with a line of the original image is found. Finally, the start and end points of the detected diagonal lines are measured. Since the results of continuous line detection include lines incorporated with the symbol or text, these must be removed after the detection of continuous lines. For this, after detecting continuous lines, the continuous lines located in the bounding box of symbols and texts are removed using the symbol and text recognition data. Figure 13 shows the method of eliminating continuous lines overlapping with the symbol and text area. In this figure, the rectangle represents the bounding box of a symbol or text. As shown in Figure 13a, if both points of a continuous line are within the bounding box, this continuous line is removed. On the other hand, continuous lines with only one point within the bounding box or both points outside the bounding box are not removed. Figure 12: The process to recognize continuous diagonal lines. (**a**) Construct a diagonal candidate set using the Hough transform. (**b**) Draw a continuous diagonal line on the empty image. (**c**) Find a diagonal line from the candidate set that overlaps for a diagonal line of the diagrams. (**d**) Find the start and end points of the detected diagonal line.