# Robust Analysis and Laser Stripe Center Extraction for Rail Images
## 2 Laser Stripe Center Extraction for Rail Images  
### Light Stripe Preprocessing  
The rail image is preprocessed by threshold segmentation. The Otsu algorithm is the optimal algorithm for threshold selection due to its efficient computation and robustness to image brightness and contrast. A rail image processed by the single-threshold Otsu method is displayed in Figure 3a. As can be seen, a portion of the stripe segments disappears because the grayscale of these pixels is similar to the background. To address this issue, a novel preprocessing method is proposed, which integrates self-adaptive threshold segmentation and image enhancement.  
First, the multiple-threshold Otsu method is adopted to segment the light stripe from the background. The number of thresholds is chosen, by enumeration from one to nine, as the value that can produce the maximum interclass variance. Then, the minimum value of the optimal multiple thresholds is selected to segment the light stripe from the background. As can be seen in Figure 3b, the segmentation result achieved with the proposed method can retain more complete light stripe information than the single-threshold Otsu method. Image enhancement is subsequently conducted to improve the contrast of dark segments of the stripe.  
Inspired by [PERSON] [25], a parameter related to exposure is defined to divide the light stripe into under-exposed and over-exposed regions. The value of stripe exposure can be calculated as  
\[\text{exposure}\ =\ \frac{1}{L}\frac{\sum_{k=t_{0}}^{t_{m}}h(k)k}{\sum_{k=t_{0}}^{ t_{m}}h(k)}, \tag{1}\]  
where \(k\) is the gray-level values of the light stripe, \(h(k)\) is the histogram of the image, \(L\) is the total number of gray levels, \(t_{0}\) is the threshold to segment the light stripe and the background, and \(t_{m}\) is the maximum gray level of the light stripe.  
\(t\) is another parameter related to exposure. It provides a value of the gray boundary, which can divide the image into sub-images of under-exposure and over-exposure.  
\[t=L(1-\ \text{exposure}) \tag{2}\]  
Figure 3: Different Otsu segmentation methods: (**a**) Single-threshold Otsu segmentation; (**b**) modified Otsu segmentation.  
Rows on the light stripe with a maximum value less than \(t\) are considered the under-exposed sub-image, and histogram equalization (HE) is subsequently applied to enhance this sub-image. The probability density function (PDF) is defined as  
\[p(k)=^{h(k)}/_{N},\quad\text{ for }t_{0}<k\leq t, \tag{3}\]  
where \(N\) is the total number of pixels in this sub-image. The corresponding cumulative density function (CDF) is defined as  
\[C(k)=\sum_{i=t_{0}+1}^{k}p(i). \tag{4}\]  
The transfer function for HE can then be defined as  
\[F=(t_{0}+1)+(t-t_{0}-1)C(k). \tag{5}\]  
For each point of the under-exposed sub-image, the corresponding gray value after enhancement can be calculated according to Equation (5).  
Comparative tests are carried out to verify the reliability of the proposed method, and the results are displayed in Figure 4. The MSR and CLAHE methods led to over-exposure to different extents, whereas the proposed method achieved better performance for stripe image enhancement. The dark area of the light stripe was recovered, especially the top section of the rail stripe; this can ensure the accuracy of light stripe center extraction, as well as the measurement of rail wear.