# A UAV-Based Visual Inspection Method for Rail Surface Defects
## 2 Methodology
### The Local Weber-Like Contrast Algorithm for Rail Images Enhancement
Figure 5a shows \(LWLC\) value with the mean range [100, 255] due to higher brightness of UAV rail images. And Figure 5b,c present the curve with \(E\) = 100 and the curve with \(E\) = 220, respectively. In Figure 5b, the low range [0, 100] of \(I\) maps to [\(-1\), 0], while the high range [100, 255] of \(I\) maps to (0, 155/100). In contrast, the curve with \(E\) = 220 in Figure 5c shows that the greater low range [0, 220] of \(I\) maps to [\(-1\), 0] due to its low slope. Thereby, along with the brightness increasing, the LWLC value is progressively reduced and the stretch of the range of \(I\) is weakened. These characteristics are similar to the human vision system, that is likely to discern contrast under the darker illuminance [30,44]. Figure 4: The gray value along longitudinal line of an image. (**a**) The gray value of 10 th (red), 80 th (blue), 110 th longitudinal line (green) of an UAV rail image form slight defects dataset. (**b**) The gray value of 10 th, 80 th, 110 th longitudinal line of an UAV rail image form datasets of serious defects. Figure 5: The surface of LWLC (Local Weber-like Contrast) measure. (**a**) The surface of LWLC. (**b**) The curve with \(E\) = 100. (**c**) The curve with \(E\) = 120. The gray value \(I(x,y)\) of the pixels in an image can be approximately determined by:  
\[I(x,y)\ =\ L(x,y)\times R(x,y) \tag{4}\]  
where \(L(x,y)\) is light source intensity on the camera lens, and \(R(x,y)\) is the coefficient of reflection attribute [45]. In a local window \(T\), \(L(x,y)\) can be regarded as a constant \(L\) due to the fact that the sunlight intensity in this small \(T\) reflected by the surface of a rail track is barely change under sunlight illumination. Therefore, Equation (3) can be replaced by:  
\[ \begin{split} LWLC_{(x,y)}&=\ \frac{L\times R(x,y)-L \times\overline{\mu}_{R}(\widetilde{x},\widetilde{y})}{L\times\overline{\mu} _{R}(\widetilde{x},\widetilde{y})}\\ &=\ \frac{R(x,y)-\overline{\mu}_{R}(\widetilde{x},\widetilde{y})}{ \overline{\mu}_{R}(\widetilde{x},\widetilde{y})}\ \ \,\ \ (\widetilde{x},\widetilde{y})\in\ T\end{split}  \tag{5}\]  
where \(\overline{\mu}_{R}(\widetilde{x},\widetilde{y})\) is the mean of reflection attribute coefficient \(R(x,y)\) in a local window \(T\). From this Equation (5), \(LWLC\) is just dependent on \(R(x,y)\) and \(\overline{\mu}_{R}(\widetilde{x},\widetilde{y})\) rather than light source intensity \(L(x,y)\). As a result, it is supposed that \(LWLC\) can keep steady under the change of sunlight illuminance. On the other hand, \(R(x,y)\) generally varies less in a local window \(T\). This means that the value of \(R(x,y)-\overline{\mu}_{R}(\widetilde{x},\widetilde{y})\) approximates 0. Thereby, when there are a smooth background window \(T_{1}\) with a large \(\overline{\mu}_{R}(\widetilde{x},\widetilde{y})\) and a coarse background window \(T_{1}\) with a small \(\overline{\mu}_{R}(\widetilde{x},\widetilde{y})\) in a rail image, the difference of their \(LWLC\) matrix is not obvious. Therefore, a uniform background can be achieved by \(LWLC\). Briefly, rail surface defects and backgrounds can be highlighted and homogenized by \(LWLC\). Based on these features, \(LWLC\) can enhance the UAV-based rail images of non-uniformity brightness due to the various reflection attribute of rail surfaces under various sunlight intensity. A transformed image can be obtained by Equation (3), which has contrast enhancement. The choice of window \(T\) size is very important, because it affects the quality and efficiency of this algorithm. Based on UAV rail image features in the same longitudinal direction presented in the above characteristics, this study adopted a lined (longitudinal direction) window \(T\) (\(100\times 1\)) in this paper. The experiment in [30] also proves the excellent performance of this local line window. In a local line window, gray value of defects is considered to be lower than the other areas on rail surface, because the light of the window is equal and less light can be reflected by defects.