# Track Line Recognition Based on Morphological Thinning Algorithm +
## 3 Methods
### Track Region Extraction Algorithm  
The algorithm for track region extraction based on track line matching is realized on the basis of track line recognition. The algorithm for track area extraction must first determine the starting point of the track, which may have multiple starting points. Secondly, each starting point is used as a reference point to search for new pixels, which connect to the starting point along its connected domain. The matching criterion is to find the matching points that meet the gauge characteristics in the transverse direction by using the position of the points found and the idea of connectivity, so as to determine the corresponding relationship between the track lines in the image--whether they belong to the same line. The interference track line is then eliminated. Finally, according to the complete matching relationship, the track area to be checked is obtained. The specific process is as follows, and the algorithm diagram is shown in Figure 13.  
Figure 12: Effect of Denoising Algorithm. (**a**) is the minimum circumscribed rectangle of all profiles. (**b**) is the results of the improved ZS algorithm processing. (**c**) is the results of the denoising algorithm processing. (**d**) is the results of track line extraction. Determine the starting point. As the train is moving along a line, the image usually extends from the bottom up (excluding the lack of image visual field angle in the process of turning--blind area). Next, search for the starting point on the track line binary map from the \(N\) row (\(N\) starts at the bottom of the image). All points are considered as possible starting points, and the search area is the lateral width of the whole image. If a point \(x_{i}\) (\(i=1,2,3\dots\)) is found with a pixel value of 255 (white dot) and the pixel next to the left has a value of 0 (black dot), it is the starting point. If no possible starting point is found in the \(N\) row, then continue to n-1 row. By analogy, if the starting point cannot be found in the \(N_{\text{max}}\) row (indicating the maximum fracture line acceptable for the starting position), the search for the starting point in this connected domain will be abandoned and this step will be repeated in the next connected domain. 1. Search for new pixels on the track line and match left and right in the transverse direction. After the initial point is determined in the first step, the new pixels \(x_{L_{i}}\) satisfying the conditions are searched upward in the connected area of each track line \(L_{i}\) (\(i=1,2,3\dots\)) in the \(f(x,y)\) image, and all the points (match points) on the same transverse surface with the point \(x_{L_{i}}\) are found on the left and right sides. At the same time, according to the trapezoidal characteristic of \"near wide and far narrow\" of the distance between the track lines, the maximum \(D_{\text{max}}\) and minimum \(D_{\text{min}}\) distance between the track lines are set, and the distance between the matching points is constantly updated in the process of matching from bottom to top, so as to reduce the mismatching rate. Considering the matching situation of track lines in complex side roads, this paper sets the limit that when the number of matching points on the same lateral surface exceeds the limit \(T\) number, the leftmost point is directly matched with the rightmost point to delimit the track area. By analogy, the track line is traversed from bottom to top, searching for all matching track lines. 2. Elimination of interference track lines. Not all the tracks in the image can match each other, and there will be tracks of different lengths. When searching for matching points on the track line, based on a large number of experiments, the track lines that can be fully matched are two or four matching points with little difference in the number of matching points (in the case of turnoff). Therefore, the most complete track lines are selected according to the number of matching points for the track area extraction. 3.