Infrared image segmentation of cracks in the rail foot

With the rapid development of socio-economy, railway safety operation has attracted increasing attention. Currently, the most widely used crack detection method on railways is still ultrasonic testing. However, the traditional ultrasonic testing method has certain blind zones and cannot detect cracks on both sides of the rail foot. This paper uses infrared non-destructive testing equipment to detect the temperature distribution on the surface of the rail foot, obtains the infrared image of the temperature distribution on the surface of the rail foot, and uses iterative threshold segmentation method to segment the infrared image. The skeleton of rail cracks is extracted from the temperature information of the infrared image, and the length of rail cracks is calculated based on the coordinate temperature information at the edge of the rail. This improves the accuracy of calculating the geometric characteristics of rail foot cracks.


Introduction
In recent years, with the rapid development of science and technology, infrared image processing technology has become more mature.Currently, infrared detection technology is widely used in various industries, such as aviation composite material defect detection [1], pressure vessel fatigue crack detection, and decoration coating thickness measurement.The infrared thermal imaging of rail foot crack images has the characteristics of low contrast and insufficient detail information of crack edges due to infrared thermography and equipment itself.To overcome this disadvantage, the process of infrared thermal wave non-destructive testing technology is usually to first use an infrared camera to capture the target image, and then use suitable infrared image processing methods to enhance the contrast and detail pixels of the target image.This article mainly introduces the use of infrared image processing technology to segment the original rail foot crack infrared images and calculate the geometric dimensions of rail foot cracks in the segmented images.In the segmentation of rail foot crack infrared images [2] , the iterative threshold segmentation method is used to segment the original crack images, extract the rail crack skeleton from the temperature coordinate information of the infrared images, calculate the crack length based on the temperature coordinate information of the edge pixels of the rail crack skeleton, and calculate the crack area by summing up the pixels within the connected region surrounded by the crack skeleton, thus greatly improving the accuracy [3] .

Iterative threshold segmentation method
The original track foot crack infrared image captured by the infrared thermal imager has low contrast due to its own equipment and thermal imaging, and the pixels at the crack edge are also very blurry, which is very unfavorable for determining the geometric shape of the crack.In order to obtain more accurate geometric dimensions, after comparing various image segmentation methods, this article 2 chose the iterative threshold segmentation method to process the captured original crack image.Comparison between Iterative Threshold Segmentation Method and other infrared image segmentation methods shows that it has the advantage of dividing the segmented rail foot crack infrared image into two regions: one is the crack pixel, and the other is the background pixel.This segmentation method is very helpful for extracting cracks [4] .The iterative threshold method compresses the image before segmenting the infrared image, which is another advantage.This makes its segmentation speed much faster than other segmentation methods and has a significant enhancing effect on edge and detail information of cracks.The iterative threshold segmentation method is divided into two regions based on the difference in grayscale levels between crack and background pixels [5] .Assuming that the original infrared image of rail foot crack is ( , ) f x y , the grayscale level of pixels in the crack image and the background pixels are different.Based on this feature, the feature value T is found.At this point, the steel rail foot crack image will be divided into two regions by the feature value T : the crack pixel and the background pixel.The mathematical expression of the feature value T in iterative threshold segmentation method can be expressed as: In the formula, 0 b = 0 (black), 1  b =1 (white).
The segmented infrared image of rail track foot cracks using iterative threshold segmentation method can be viewed as a mathematical function that includes three parameters: the first one is the coordinate of crack pixels, the second one is the grayscale level of crack pixels, and the third one is the local neighborhood features of crack pixels.hence, the mathematical expression of the iterative threshold segmentation method is [6] : ( , , ( , ), ( , )) T T x y n x y f x y = (2) In the formula, ( , ) f x y is the grayscale level of pixel ( , ) xy; ( , ) n x y is the local neighborhood feature of pixel ( , )  xy.According to different constraints of the characteristic value T , three different thresholds can be obtained from the segmented infrared images of rail foot cracks: pixel-related threshold

( ( , )) T T f x y =
, which is only affected by the grayscale level of the pixel.Region-related threshold refers to the size of the global threshold

( ( , )) T T f x y =
, which not only affected by the grayscale level of the pixel but also affected by the characteristics of some adjacent pixels.The local threshold, also known as a dynamic threshold, ( ( , )) T T f x y = is influenced not only by the grayscale level of the pixel and the characteristics of some adjacent pixels but also by the position of the pixel.
The segmentation process of the rail foot crack infrared image based on the iterative threshold segmentation method mainly includes the following four parts: • ① After segmentation, the gray level Z of the infrared image of the rail foot crack can be obtained, the maximum gray value is recorded as max is calculated; =+ , the result is based on the iterative threshold segmentation method, otherwise, the iterative calculation can continue in step ②.Due to the limitations of infrared thermal imaging and equipment itself, the captured infrared images have the characteristics of low contrast and insufficient information on crack edge details, making it more difficult to extract crack details from the images.Therefore, it is necessary to use appropriate infrared processing techniques to process the original image.This article proposes using infrared image segmentation to process rail foot crack images to enhance the details of crack edge pixels, which is beneficial for extracting the skeleton of rail foot cracks and improving computational accuracy.The original infrared image of the crack on the track support foot was obtained using an infrared detection device, as shown in Figure 1.
On the Matlab_2017b simulation platform, the iterative threshold method is used to segment and process the infrared image of rail foot cracks.After segmentation, the detailed information of the edge of the rail crack inside the image is enhanced, greatly improving the accuracy of extracting the geometric region of the crack.The segmented image is shown in Figure 2.  Comparing Figure 1 with Figure 2, the following conclusions can be drawn: Figure 1 is the original infrared image captured by an infrared imager.It can be clearly seen from the figure that there are fewer detail pixels in the cracks, which will directly affect the calculation of crack geometric dimensions [7] ; Figure 2 is the segmented infrared image.It can be intuitively seen from the figure that there are more detail pixels, indicating that the iterative threshold segmentation method can enhance the detail pixels of rail foot cracks.The quantitative analysis of image segmentation results is shown in

Extraction of rail foot crack skeleton
The extraction of the cracked skeleton of the rail foot is carried out on the infrared image after the iterative threshold method.According to the heat conduction theory, the surface temperature of the cracked and the crack-free rail is different.The surface temperature of the cracked rail inside the rail foot is higher than the surface temperature of the internal crack-free rail.Determine the coordinates of the crack edge pixels according to the temperature information in the infrared image of the rail foot crack, and then determine the crack skeleton according to the pixel coordinates of the crack edge.Finally, the extracted crack skeleton is uploaded to the online image processing software.Through the analysis software, the final rail foot crack skeleton can be drawn, so that Calculate the geometric size of the rail foot crack [8] .
The detail pixels of the cracked infrared image of the split rail foot are enhanced.It can be seen that there are many detail pixels on the edge of the crack.When extracting the rail crack skeleton according to the temperature coordinate information, these pixels may cause the deviation of the crack skeleton extraction.In order to improve the accuracy of the pixel points at the edge of the crack skeleton, this paper uses the mathematical morphological refinement method to refine the pixel points at the edge of the crack skeleton.The advantage of the mathematical morphological refinement method is that it reduces the deviation caused by the edge pixels and best maintains the original shape of the crack skeleton.The infrared image processed by the mathematical morphology refinement method has more interest in the extraction of the crack skeleton.In the refined image, 468 edge pixels are extracted, and the coordinates of 468 pixels are uploaded to the online image processing software.The coordinates of each pixel can be connected to draw a crack skeleton with a higher accuracy level.Table 2 shows the temperature information of the pixels at the edge of the rail foot crack.

Calculation of crack length of rail foot
The length of the rail foot crack is obtained by crack skeleton analysis and calculation.First, load the coordinate information of 468 edge pixels of the crack skeleton in the online analysis software, initialize the information of the labeled pixels, connect each pixel according to the label, and obtain the connected region of the crack skeleton.The length of the rail foot crack skeleton is calculated by pixel accumulation method.Multiply the length of the obtained crack skeleton by the correction coefficient of the infrared image of the rail foot crack, and the true length of the crack can be obtained [9] .The flow chart for calculating the length of the crack at the foot of the rail is shown in Figure 3.The calculation of the crack skeleton is based on the accumulation of 468 edge pixels.The principle of the pixel accumulation method is: first initialize the crack skeleton information in the online image analysis software, and then determine whether the 468 pixels belong to the one-way neighborhood or the two-way neighborhood one by one, and mark the identified pixels.One-way proximity means that only one of the horizontal coordinates x or vertical coordinates y of the two adjacent pixels is transformed.When calculating the length of the crack skeleton, the distance between the two one-way adjacent pixels is recorded as pd .Bidirectional neighboring refers to the transformation of both the horizontal coordinates x and the vertical coordinates y in the two adjacent pixels.When calculating the length of the crack skeleton, the distance between the two adjacent pixels in both directions is recorded as 2 pd.By counting the 468 edge pixels of the rail crack skeleton, the number of one-way adjacent pixels is e N , and the number of two-way adjacent pixels is o N .According to e N and o N , the length of the rail foot crack skeleton can be calculated.Figure 4 shows the distance between pixels.
In the formula, l is the length of the crack skeleton; e N is the number of one-way adjacent pixels; o N is the number of two-way adjacent pixels.
According to the above formula, as long as the number of one-way adjacent pixels e N and the number of two-way adjacent pixels o N are determined, the length of the crack skeleton can be calculated as l (pixel), and then multiplied by the correction coefficient Scale (mm/pixel) of the infrared image, the actual length of the crack L (mm).Through the calculation of formula (4), the actual crack length is 57mm.

Calculation of the area of cracks in the rail foot of the rail
Area is the second characteristic information of rail crack.The calculation method of area for rail foot cracks is very similar to that of length calculation for rail foot cracks.Both are obtained by analyzing the crack skeleton.First, the coordinate information of 468 edge pixels of the crack skeleton is loaded into an online analysis software.The labeled pixels are initialized based on the label number and connected.Multiple connected regions of the crack skeleton will be obtained.The area of each connected region is calculated based on the number of pixels inside it, then adding up the areas of multiple connected regions to obtain the area of the rail foot crack.The flow chart of rail foot crack area calculation is shown in Figure 5 [10].The crack area of the rail foot is obtained by accumulating the number of pixels inside each connected area.First of all, multiple connected areas are determined by the coordinates of the edge pixels of the cracked skeleton.By calculating the number of pixels inside each connected area, the area of this connected area can be obtained by accumulating the surface of multiple connected areas.The product can calculate the size of the crack in the derailment foot.The formula for calculating the crack area of the rail foot is as follows: ( , ) 1 In the formula, A is the area of the crack in the rail foot; R is the connected area of the crack skeleton.
From formula (5), it can be seen that by accuming the area of all connected areas R inside the rail rail foot crack skeleton, the rail foot crack area A can finally be obtained.The calculation process is: First, multiple connected areas are determined by the pixel coordinates of the edge of the crack skeleton, and the area of this connected area is calculated by calculating the number of pixels inside each connected area.By accumulating the area of multiple connected areas, the actual size of the cracked crack can be calculated.The area of each pixel is about 1.This method has very good calculation accuracy for the calculation of rail foot cracks with multiple connected areas, and the final calculation is that the crack area is 76mm 2 .The on-site measured crack area is 78.5 mm 2 , which is close to the experimentally calculated crack length of 76 mm 2 , indicating that the experimental method can improve the accuracy of crack area calculation.

Conclusion
Infrared images of rail foot cracks have the characteristics of low contrast and insufficient edge details of cracks due to infrared thermography and equipment factors.This article mainly introduces the use of iterative thresholding method to segment the original image of rail foot crack, and the segmented crack image is divided into crack pixels and background pixels according to the gray level.This can better separate the detailed edge pixels of cracks during segmentation and greatly help calculate the geometric size of cracks in later stages.According to the heat conduction theory, the surface temperature of steel rails with cracks and without cracks is different, and the surface temperature of steel rails with cracks in the rail foot is higher than that inside without cracks.The coordinates of crack edge pixels are determined based on the temperature information in the infrared image of rail foot cracks, and then the crack skeleton is determined according to the crack edge pixel coordinates.Finally, the extracted crack skeleton is uploaded to online image processing software, and the final rail foot crack skeleton can be drawn by analyzing software.The accuracy level of calculating rail foot crack can be greatly improved based on the extracted crack skeleton.
f x y .Pixel-related threshold refers to the size of the global threshold

Z•② 3 •
and the minimum gray value is recorded as min Z , and the calculation result of the initial threshold is According to the initial threshold calculated in step ①, the infrared image of the rail foot crack will be divided into two parts, one is the crack pixel and the other is the background pixel.The average gray value of the crack is calculated as o Z , and the average gray value of the background is calculated as b Z ..1088/1742-6596/2589/1/012009 ③ Then calculate the average gray value of the crack obtained in step ② as o Z , the average gray value of the background is calculated as b Z , and the new threshold ob +1 = ( + ) / 2 TK Z Z

Figure 1 .
Figure 1.Original infrared image of rail foot crack.

Figure 2 .
Figure 2. Infrared image segmented by iterative threshold method.

pd p 2 dFigure 3 .
Figure 3. Flow chart for calculating the length of the crack at the foot of the rail.

Figure 4 .
Figure 4. Schematic diagram of distance between pixels.

Figure 5 .
Figure 5. Flow chart for the calculation of the crack area of the rail foot.The crack area of the rail foot is obtained by accumulating the number of pixels inside each connected area.First of all, multiple connected areas are determined by the coordinates of the edge pixels of the cracked skeleton.By calculating the number of pixels inside each connected area, the area of this connected area can be obtained by accumulating the surface of multiple connected areas.The product can calculate the size of the crack in the derailment foot.The formula for calculating the crack area of the rail foot is as follows:

Table 1 .
Quantitative analysis of image segmentation results

Table 2 .
Coordinate temperature information of crack edge of rail.