Steel rail surface defect classification method based on fractal theory and co-occurrence matrix
Through the method based on fractal theory and symbiotic matrix, fractal characteristics and energy characteristics of rail surface defects are extracted, and efficient classification of rail surface defects is achieved, the problem of inefficient detection in the prior art is solved, and the accuracy and efficiency of detection are improved.
Patent Information
- Application Number
- CN202411962191.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-30
- Publication Date
- 2025-05-30
AI Technical Summary
The existing rail surface defect detection methods are inefficient and require a large number of data sets to train neural networks, resulting in inefficient detection.
The classification method based on fractal theory and symbiosis matrix is adopted, fractal features are extracted through the box counting method, the fractal dimension is estimated to initially determine the depression defect, and the energy characteristics are calculated using the grayscale symbiosis matrix to distinguish between wave milling and abrasion.
It improves the accuracy and efficiency of rail defect category detection, reduces dependence on data sets, can detect and deal with rail defects early, and ensures the safe and efficient operation of the railway system.
Smart Images

Figure CN120070937A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image processing and target detection, and particularly to a method for classifying rail surface defects based on fractal theory and co-occurrence matrix. Background Art
[0002] In urban rail transit, the track is an important part, which plays a guiding and bearing role for the train running. Therefore, it is crucial to detect track damage to improve the operation safety of the track. In this process, it is particularly important to detect the defects on the rail surface. Because the defects on the rail surface will accelerate the wear of the wheels, cause problems such as spalling, and at the same time increase the risk of vehicle derailment. Railway defects may lead to huge economic and personnel losses.
[0003] Nondestructive testing techniques are widely used in the railway system. Common nondestructive testing methods for detecting defects in rails in the railway system include ultrasonic testing, magnetic flux leakage testing, electromagnetic ultrasonic method, laser scanning testing, etc. Currently, the detection of rail surface defects usually adopts methods based on structured light detection, acoustic wave-based detection, and image-based detection. In the existing technology, the rail surface defects need to be analyzed after being trained by a neural network, but ensuring the accuracy of the neural network requires a large amount of data sets. Therefore, the detection efficiency of rail surface defects is relatively low. Summary of the Invention
[0004] The purpose of the present invention is to provide a method for classifying rail surface defects based on fractal theory and co-occurrence matrix to improve the detection efficiency of rail defect categories.
[0005] A method for classifying rail surface defects based on fractal theory and co-occurrence matrix, the method comprising the following steps:
[0006] Step 1, preprocess and denoise the rail defect image to be recognized to obtain the preprocessed image;
[0007] Step 2, based on fractal theory, use the box-counting method to extract features from the preprocessed image to generate fractal features, estimate the fractal dimension of the fractal object. If the fractal dimension is less than the dimension threshold A, it is determined that the rail defect is a depression, otherwise, execute S3;
[0008] Step 3, calculate the energy feature of the fractal feature based on the gray-level co-occurrence matrix. If the energy feature is greater than the energy threshold B, it is determined that the rail defect is a corrugation, otherwise, it is determined that the rail defect is a scratch.
[0009] Further, the specific steps of S2 are:
[0010] Step 2.1, cover the fractal object of the preprocessed image with square boxes of different sizes;
[0011] Step 2.2: Count the number of boxes required to cover the fractal object;
[0012] Step 2.3: Estimate the fractal dimension of the fractal object based on the relationship between the box size and the number of required boxes. If the fractal dimension is less than the dimension threshold A, it is determined that the rail defect is a depression; otherwise, S3 is executed.
[0013] Further, the specific steps for estimating the fractal dimension of the fractal object based on the relationship between the box size and the number of required boxes are as follows:
[0014] Assume that the number of grids encountered by the fractal object at a magnification is A, the magnification is s, and the fractal dimension of the fractal object is N, satisfying the following relationship:
[0015] A = cS N
[0016] where c is a constant;
[0017] Take the logarithm of both sides of the relationship. The relationship curve between log(A) and log(S) after taking the logarithm is a linear function, and the slope k of this linear function is the fractal dimension.
[0018] Further, the box is a square or a rectangle.
[0019] Further, the gray-level co-occurrence matrix starts from the pixel (x, y) with a fractal feature gray value of i, and counts the frequency P(i, j, d, θ) of the simultaneous occurrence of the pixel (x + a, y + b) with a distance of d and a gray value of j. θ represents the formation direction of the gray-level co-occurrence matrix.
[0020] Further, the matrix features of the gray-level co-occurrence matrix include angular second moment W 1 , contrast W 2 , correlation W 3 and entropy W 4 .
[0021] Further, the energy feature is the occurrence frequency of gray levels in the horizontal and vertical directions of the gray-level co-occurrence matrix.
[0022] Further, Step 1 is specifically as follows:
[0023] Step 1.1: Preprocess the rail defect image to be recognized and convert the image into a grayscale image;
[0024] Step 1.2: Use the Gaussian filtering algorithm to denoise the grayscale image and enhance the contrast;
[0025] Step 1.3: Smooth and filter the denoised and contrast-enhanced image using the Canny edge recognition algorithm. Further, the pixel value of the grayscale image is:
[0026] Y = 0.299×R + 0.587×G + 0.114×B
[0027] Wherein, Y represents the pixel value of the grayscale image, and R, G, and B are the pixel intensities of the three color channels of red, green, and blue respectively.
[0028] Furthermore, the specific steps for performing smoothing filtering on the denoised and contrast-enhanced image using the Canny edge recognition algorithm are as follows:
[0029] Perform Gaussian filtering, calculate the gradient, non-maximum suppression, double-threshold detection, and edge tracking on the denoised and contrast-enhanced image in sequence to achieve smoothing filtering.
[0030] Compared with the prior art, the present invention has the following beneficial effects:
[0031] The present invention first uses the fractal dimension to detect the concave defects preferentially, and then uses the energy parameter in the gray-level co-occurrence matrix to classify the corrugation and abrasion, improving the accuracy of defect type detection. Compared with the existing neural network training model detection method, the method of the present invention first identifies a type of defect based on mathematical fractals, and then analyzes based on the gray-level co-occurrence matrix. The overall steps are simple, do not rely on the data set, improve the detection efficiency of rail surface defects, and play a role in detecting and dealing with rail defects early, which is crucial for urban rail transit, facilitating regular inspection and maintenance work to ensure the safe, stable, and efficient operation of the railway system. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] Figure 1 It is a schematic diagram of the method flow;
[0033] Figure 2 It is a schematic diagram of the comparison before and after image grayscale processing;
[0034] Figure 3 It is a schematic diagram of the comparison before and after image denoising and contrast enhancement processing;
[0035] Figure 4 It is a schematic diagram of contour extraction;
[0036] Figure 5 It is an image sample of each defect on the rail surface;
[0037] Figure 6 It is the fractal dimension of different types of defects. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0038] The present invention will be described in detail below with reference to the accompanying drawings and specific embodiments. This embodiment is implemented on the premise of the technical solution of the present invention, and the detailed implementation manners and specific operation processes are given, but the protection scope of the present invention is not limited to the following embodiments.
[0039] The present invention proposes a method for classifying rail surface defects based on fractal theory and co-occurrence matrix. The main steps of this method are as follows: (1) Preprocess the rail defect image to be recognized, convert the image into a grayscale image, and generate a grayscale value wave to remove noise by calculating the weighted average of the RGB values of each pixel to improve the image quality; (2) Based on fractal theory, use the box-counting method for feature extraction, combined with the complex geometric structure and irregularity of the rail surface defects, so as to generate fractal features, covering the number of square box statistical graphs required for different sizes, generate the fractal dimension from the statistical data of different magnification factors, and classify the rail surface defects; (3) Use co-occurrence matrix features to generate a gray-level co-occurrence matrix, analyze the image texture according to the spatial relationship of pixel gray values, calculate the eigenvalues of the matrix, such as angular second moment, contrast, correlation, and entropy, so as to describe different texture features, and can effectively realize the automatic detection and classification of rail surface defects, improving the accuracy and efficiency of detection.
[0040] The specific steps of the present invention are as follows:
[0041] Step 1: Preprocess and denoise the rail defect image to be recognized to obtain the preprocessed image;
[0042] Step 2: Based on fractal theory, use the box-counting method to extract features from the preprocessed image, generate fractal features, estimate the fractal dimension of the fractal object. If the fractal dimension is less than the dimension threshold A, it is determined that the rail defect is a depression, otherwise execute S3;
[0043] Step 3: Calculate the energy feature of the fractal feature based on the gray-level co-occurrence matrix. If the energy feature is greater than the energy threshold B, it is determined that the rail defect is a corrugation, otherwise, it is determined that the rail defect is a scratch. The flow chart of the present invention is as Figure 1 shown
[0044] Step S1 specifically includes the following steps:
[0045] S11, convert the image into a grayscale image, specifically as follows:
[0046] For a color photo, the value of each pixel point can be expressed in the form of (R, G, B), where R, G, and B are the pixel intensities of the red, green, and blue color channels. The pixel values of these three channels are weighted and averaged according to a certain weight to obtain the pixel value of the grayscale image.
[0047] The pixel value calculation formula of the grayscale image is:
[0048] Y = 0.299×R + 0.587×G + 0.114×B
[0049] Among them, Y represents the pixel value of the grayscale image. The derivation of this formula stems from the fact that the human eye is more sensitive to different colors. The weight of red is the highest, followed by green, and blue is the lowest;
[0050] S12. Using the Gaussian filtering algorithm for image denoising and contrast enhancement, the image can be subjected to Gaussian smoothing processing to effectively remove Gaussian noise. Its mathematical expression is:
[0051]
[0052] Among them, I smoothed represents the pixel value of the smoothed image, I(x, y) represents the pixel value of the original image, σ represents the standard deviation of the Gaussian kernel, and k represents the size of the Gaussian kernel;
[0053] S13. Through the Canny edge recognition algorithm, the image is moderately smoothed and filtered to reduce the influence of noise and extract the contour of the defective part of the rail surface. Its main steps include Gaussian filtering, calculating the gradient, non-maximum suppression, double-threshold detection, and edge tracking. The formula for calculating the gradient is as follows:
[0054]
[0055] θ(x,y) = tan -1 2(G y (x,y),G x (x,y))
[0056] Step S2 specifically includes the following steps:
[0057] In the feature classification work, the image classification work can be carried out by the box-counting method based on the fractal theory. The box-counting method can effectively measure the complex geometric structures and irregularities in the image, thus providing a rich description of the image features.
[0058] When calculating the fractal dimension of an image using the box-counting method, in the present invention, a solid disk graph is placed in a grid graph, and the number of grids in contact with the graph is counted. Then, the grid density is increased by a certain multiple, and the number of grids in contact with the graph is counted again. The above process is continuously repeated, and finally, a function relationship graph of the magnification of the graph and the grid and the number of grids in contact can be obtained.
[0059] S21. Cover the fractal object with boxes of different sizes, which can be squares or rectangles;
[0060] S22. Count the number of boxes required to cover the fractal object;
[0061] S23. Calculate according to the relationship between the size of the square box and the required number of square boxes using a mathematical formula to estimate the dimension of the fractal object. Specifically as follows:
[0062] Suppose the number of grids encountered by the graph at a magnification factor is A, the magnification factor is s, and the fractal dimension of the graph is N. Then there is such a relational expression: A = cS N
[0063] where c is a constant. Obtain a curve function of the magnification factor and the number of grids it encounters, and take the logarithm of both sides for direct observation: log(A) = log(c) + Nlog(S)
[0064] From the above formula, the function can be transformed into a relationship curve between log(A) and log(A), which is a linear function, and the slope k represents the fractal dimension N of the image.
[0065] Such as Figure 5 From left to right are typical pictures of rail depression, corrugation, and abrasion. Calculate the fractal characteristic values of these typical pictures, and the results shown in Table 1 can be obtained:
[0066] Table 1 Fractal characteristic values of typical pictures
[0067]
[0068] It can be seen from the above results that through the analysis of the fractal characteristic values of the grayscale image and the contour image, the difference in the characteristic values calculated on the same image of the two is an integer 1. Therefore, the detection effects of the two methods for calculating the fractal characteristic values on the three types of defects are the same. Next, by calculating 360 different defects on the rail surface, among which there are 120 depressions, 120 corrugations, and 120 abrasions, to determine the stability and threshold interval of the fractal dimension of its grayscale image. The results are shown in Table 2, where the green line is for abrasion, the red line is for corrugation, and the blue line is for depression:
[0069] Table 2 Stability and threshold interval of the fractal dimension of the grayscale image
[0070] Indentation Waviness Scratch Mean value 2.107 2.206 2.266 Variance 0.004 0.003 0.001 Standard deviation 0.063 0.057 0.031
[0071] By analyzing the fractal characteristic values of the three types of defects, it can be seen that the fractal characteristic value of the depression is significantly smaller than the other two. Therefore, the depression of the rail can be effectively distinguished through the fractal characteristics. It can be observed that there are obvious differences between the depression and the other two types of rail surface defects, and this difference is collective. The fractal dimension of the depression must be smaller than that of the other two defects. However, the difference in the fractal dimension between the corrugation and the abrasion is not significant, and there is even a certain overlap in the numerical range. Based on this property, by sorting out the data after the execution of the above program, a threshold value is obtained, and this threshold value can be used to initially determine which type of surface defect this rail has.
[0072] From Figure 6 It can be obtained that the fractal dimension of the abrasion is between 2.2 and 2.3, the fractal dimension of the corrugation is between 2.15 and 2.25, and the fractal dimension of the depression is between 2.02 and 2.12. Through this method, the depression can be effectively identified and classified, but there is a certain instability in the detection of abrasion and corrugation.
[0073] Step S3 specifically includes the following steps: According to the original dataset of the track defect image, a corresponding gray-level co-occurrence matrix is generated for this image. The gray-level co-occurrence matrix can be defined as starting from the pixel (x, y) with the gray value i in the image, and statistically counting the frequency P(i, j, d, θ) of the simultaneous occurrence of the pixel (x + a, y + b) with the distance d and the gray value j. The mathematical expression is:
[0074] P(i, j, d, θ) = {[(x, y), (x + a, y + b) | f(x, y) = i; f(x + a, y + b)
[0075] = j]}
[0076] Here, θ represents the formation direction of the gray-level co-occurrence matrix; the characteristics of the gray-level co-occurrence matrix are calculated through the angular second moment W 1 , contrast W 2 , correlation W 3 , entropy W 4 . The calculation formulas are as follows:
[0077]
[0078]
[0079] Among these four gray-level co-occurrence matrix characteristic indexes, there is the angular second moment, which can measure the average distribution of the image gray level and the fineness of the pattern; the contrast can evaluate whether the pattern quality of the image is clear; through correlation analysis, we can determine the pattern trend in the image; finally, the entropy value can be used to measure the complexity level of the image pattern. For the classification of surface defects on rails, such as corrugation and abrasion, corrugation presents continuous wavy textures, while abrasion shows irregular wear lines composed of granular black dots. There are significant differences in the thickness uniformity of the textures of corrugation and abrasion. Therefore, this method uses the energy parameter in the gray-level co-occurrence matrix to classify corrugation and abrasion.
[0080] By extracting the energy features of the gray-level co-occurrence matrix for two types of defects, corrugation and abrasion, the following results can be obtained:
[0081] Table 3 Energy Features
[0082]
[0083] It can be seen from the above results that by comparing the energy feature values of the gray-level co-occurrence matrix of corrugation and abrasion, it can be found that the energy of corrugation is much smaller than that of abrasion, and corrugation and abrasion can be classified by this method. In this invention, 100 images of different surface defects on rails, 50 of corrugation and 50 of abrasion, are calculated to determine the stability of their fractal dimensions and the threshold interval, and the results are shown in Table 4.
[0084] Table 4 Stability of Fractal Dimension and Threshold Interval
[0085] Waviness Scratch Mean value 0.0059 0.0315 Variance 0.000001 0.0001 Standard deviation 0.0011 0.0116
[0086] After 200 verifications of existing images, the experimental results are shown in Table 5:
[0087] Table 5 Experimental Results
[0088]
[0089]
[0090] All 200 fasteners are divided into samples of rail depression, rail corrugation, and rail abrasion. The recognition results are shown in the table. From the table, we can know that the recognition accuracy of the three types of defects, rail depression, corrugation, and abrasion, based on the fractal theory and the energy features of the gray-level co-occurrence matrix is relatively high.
[0091] The present invention classifies three common defects on the rail surface, namely dents, corrugations, and abrasions, through fractal features and gray-level co-occurrence features. Among them, the fractal feature is a mathematical tool for describing self-similar structures, capable of capturing complex texture and shape features in images, and having a good expression ability for irregular and complex surface defects. The gray-level co-occurrence matrix (GLCM) is a commonly used method for describing image texture features by studying the spatial correlation of gray levels, and has a good effect on image texture detection, which can further detect surface defects on the rail.
[0092] Figure 2 Schematic diagram of the comparison before and after image grayscale processing; Figure 3 Schematic diagram of the comparison before and after image denoising and contrast enhancement processing; Figure 4 Schematic diagram of contour extraction.
[0093] The preferred specific embodiments of the present invention have been described in detail above. It should be understood that those of ordinary skill in the art can make many modifications and variations based on the concept of the present invention without creative labor. Therefore, all technical solutions that can be obtained by those skilled in the art in the technical field of the present invention through logical analysis, reasoning, or limited experiments based on the concept of the present invention on the basis of the prior art should be within the protection scope determined by the claims.
Claims
1. A rail surface defect classification method based on fractal theory and co-occurrence matrix, characterized in that: The method comprises the following steps: Step 1: preprocessing and denoising the rail defect image to be identified to obtain a preprocessed image; Step 2: Based on the fractal theory, the box counting method is used to extract features from the preprocessed image, generate fractal features, and estimate the fractal dimension of the fractal object. If the fractal dimension is less than the dimension threshold A, the rail defect is determined to be a depression, otherwise, S3 is executed; Step 3: Calculate the energy feature of the fractal feature based on the gray level co-occurrence matrix. If the energy feature is greater than the energy threshold B, the rail defect is determined to be corrugation. Otherwise, the rail defect is determined to be abrasion.
2. The rail surface defect classification method based on fractal theory and co-occurrence matrix according to claim 1 is characterized in that: The specific steps of S2 are: Step 2.1, covering the fractal object of the preprocessed image with boxes of different sizes; Step 2.2, count the number of boxes required to cover the fractal object; Step 2.3: Estimate the fractal dimension of the fractal object based on the relationship between the size of the square box and the required number of square boxes. If the fractal dimension is less than the dimension threshold A, the rail defect is determined to be a depression. Otherwise, execute S3.
3. The rail surface defect classification method based on fractal theory and co-occurrence matrix according to claim 2 is characterized in that: According to the relationship between the box size and the number of boxes required, the specific steps for estimating the fractal dimension of a fractal object are: Assume that the number of grids encountered by the fractal object at a certain magnification is A, the magnification is s, and the fractal dimension of the fractal object is N, satisfying the following relationship: A=cS N Where c is a constant; Take the logarithm of both sides of the relationship, and the relationship curve between log(A) and log(S) after taking the logarithm is a linear function, and the slope k of the linear function is the fractal dimension.
4. The rail surface defect classification method based on fractal theory and co-occurrence matrix according to claim 3 is characterized in that: The box is square or rectangular.
5. The rail surface defect classification method based on fractal theory and co-occurrence matrix according to claim 1 is characterized in that: The gray-level co-occurrence matrix starts from the pixel (x, y) with gray-level value i of the fractal feature, and counts the frequency P(i, j, d, θ) of the simultaneous occurrence of the pixel (x+a, y+b) with a distance d and gray-level value j. θ represents the formation direction of the gray-level co-occurrence matrix.
6. The rail surface defect classification method based on fractal theory and co-occurrence matrix according to claim 5 is characterized in that: The matrix features of the gray-level co-occurrence matrix include angular second-order moment W1, contrast W2, correlation W3 and entropy W4.
7. The rail surface defect classification method based on fractal theory and co-occurrence matrix according to claim 6 is characterized in that: The energy feature is the occurrence frequency of gray levels in the gray level co-occurrence matrix in the horizontal and vertical directions.
8. The rail surface defect classification method based on fractal theory and co-occurrence matrix according to claim 1 is characterized in that: Step 1 is as follows: Step 1.1, preprocessing the rail defect image to be identified, and converting the image into a grayscale image; Step 1.2, using Gaussian filtering algorithm to perform image denoising and contrast enhancement on the grayscale image; Step 1.3: Use the Canny edge recognition algorithm to smooth and filter the denoised and contrast enhanced images.
9. The rail surface defect classification method based on fractal theory and co-occurrence matrix according to claim 8, characterized in that: The pixel value of the grayscale image is: Y=0.299×R+0.587×G+0.114×B Among them, Y represents the pixel value of the grayscale image, and R, G, and B are the pixel intensities of the three color channels of red, green, and blue.
10. The rail surface defect classification method based on fractal theory and co-occurrence matrix according to claim 9, characterized in that: The specific steps of smoothing and filtering the denoised and contrast enhanced images using the Canny edge recognition algorithm are as follows: The denoised and contrast enhanced images are subjected to Gaussian filtering, gradient calculation, non-maximum suppression, dual threshold detection and edge tracking to achieve smooth filtering.
Citation Information
Cited By
Sliding rail quality inspection method and system based on artificial intelligence
CN121121439A