# Robust Analysis and Laser Stripe Center Extraction for Rail Images
## 2 Laser Stripe Center Extraction for Rail Images
### Light Stripe Extraction  
After the preprocessing procedure is conducted, the laser stripe center for each row can be calculated with subpixel precision by using the center of mass, as given by Equation (6):  
\[P_{i}=\frac{\sum_{I(i,j)>t_{0}}I(i,j)*j}{\sum_{I(i,j)>t_{0}}I(i,j)}, \tag{6}\]  
where \(P_{i}\) is the center of the light stripe in row \(i\), and \(I(i,j)\) is the pixel value in row \(i\) and column \(j\).  
The detection results are presented in Figure 5. As is evident, most parts of the light stripe were successfully detected. However, the centerlines in the curved parts are not very smooth, which mainly resulted from the reflectivity. Another reason is that the detection method does not take into account the continuity between adjacent center-points; this can be overcome by laser stripe centerline optimization, which is subsequently elaborated.  
Piecewise fitting is selected to optimize the center-points, but light stripe segmentation must first be conducted. The neighborhood difference method is used to segment the laser stripe into the rail head region and rail waist region. First, an array is constructed, the elements of which are horizontal coordinates of the centers detected previously. The neighborhood difference is then calculated by Equation (7):  
\[\text{d}=P_{i+1}-P_{i}. \tag{7}\]  
The position at which the maximum value is located is considered as the segmentation point between the rail head and rail waist. The distribution of the neighborhood difference values is displayed in Figure 6, and the segmentation results are shown in Figure 7.  
Figure 4: Results of comparative tests on light stripe image enhancement: (**a**) The original image; (**b**) the result of the proposed method; (**c**) the result of MSR; (**d**) the result of contrast-limited adaptive histogram equalization (CLAHE).  
Figure 5: Light stripe center detection results.  
According to the geometric characteristics of the rail profile, the rail head and rail waist regions are respectively subdivided into three parts. For the laser stripe segment of the rail head, the first and last center-points are used to estimate the coefficients of the line that links them. The distance between the approximation function and the detected center-points can be calculated based on these coefficients, and the largest distance is located at the corner of the region, which is indicated by the blue point in Figure 8a. The points in the neighborhood of the blue point compose the middle part of the rail head, while the points at the ends of this section compose the other two parts. Considering speed and accuracy, and taking advantage of the profile feature and experimental research, three-order and two-order polynomials are selected to fit the subsection curves for the middle and end parts, respectively. The same procedures are applied for the segment of the rail waist. The  
Figure 6: The distribution of the absolute values of the neighborhood difference.  
Figure 7: Rail head and rail waist segmentation.  
results of segmentation and piecewise approximation are shown in Figure 8. The proposed method takes only 14% of the time required by the iterative endpoint method to perform centerline optimization.