Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention more apparent, the embodiments of the present invention are further described in detail below with reference to the accompanying drawings. The exemplary embodiments and descriptions of the present invention are provided to explain the present invention, but not to limit the present invention.
The invention provides a detection scheme of steel rail contact fatigue cracks, which is an automatic detection method of the steel rail contact fatigue cracks based on image processing, and aims to overcome the defects of high manual inspection cost, low detection speed, poor accuracy and the like in the prior art and avoid the problems that the existing steel rail contact fatigue crack detection technology based on machine vision is easily influenced by objective environments such as illumination and the like and the identification accuracy is difficult to guarantee. The detection scheme of the steel rail contact fatigue crack provided by the embodiment of the invention realizes automatic, efficient and accurate detection of the steel rail contact fatigue crack, and provides a reliable basis for maintenance and repair of the rail. The following describes the detection scheme of the rail contact fatigue crack in detail.
Fig. 1 is a schematic flow chart of a method for detecting contact fatigue cracks of a steel rail in an embodiment of the invention, as shown in fig. 1, where fig. 1 includes the following steps:
step 101: determining an image of a steel rail area to be detected from the acquired track image;
step 102: dividing the determined steel rail area image to be detected into a plurality of unit areas, and determining a gradient direction histogram of each unit area;
step 103: and detecting whether the contact fatigue crack exists in each unit area according to the preset gradient direction characteristic of the steel rail contact fatigue crack and the gradient direction histogram of each unit area.
The method for detecting the contact fatigue cracks of the steel rail provided by the embodiment of the invention realizes that the gradient direction characteristic of the contact fatigue cracks in the steel rail image is utilized, whether the contact fatigue cracks exist in the steel rail is judged by calculating the gradient direction histogram of the unit area in the steel rail area image, the gradient direction characteristic of the contact fatigue cracks in the steel rail image is fully utilized, meanwhile, the method is insensitive to the change of the gray value of a single pixel of the image, the influence of factors such as illumination and the like on the image is reduced, the accuracy of the detection of the contact fatigue cracks of the steel rail in a specific application scene is ensured, the contact fatigue cracks of the steel rail are efficiently and accurately detected, and the scientific and reliable basis is provided for the maintenance and the repair of the rail.
The method for detecting contact fatigue cracks of a steel rail provided by the embodiment of the invention is described in detail below with reference to fig. 2 to 7, and comprises the following steps:
step a, acquiring a track image, and marking an image of a steel rail from the track image, namely step 101.
In one embodiment, determining the image of the rail region to be detected from the acquired track image may include: and determining the image of the steel rail area to be detected from the acquired rail image according to the preset gray value characteristic and the width value characteristic of the top surface of the steel rail.
During specific implementation, the implementation mode of determining the steel rail area image to be detected from the acquired track image further improves the efficiency and accuracy of determining the steel rail area image to be detected, and further improves the detection efficiency and accuracy of the steel rail contact fatigue crack.
Specifically, a track image may be taken from above the rails, and the taken track image may be read as shown in fig. 2. The captured rail image includes a non-rail region in addition to the rail portion. The grey value of the top surface of the steel rail is high due to long-term friction between the wheel and the surface of the steel rail, meanwhile, the width of the top surface of the steel rail in the image is a fixed value (marked as R), and the image of the steel rail is marked from the image of the rail by using the characteristics, and the method comprises the following steps:
[1] the method includes the steps of dividing a track image into a certain number of longitudinal areas with the width of R of the top surface of a steel rail in a mode that a moving step length is one column of the longitudinal width of the image from the left side of the track image, specifically, dividing the track image into a plurality of columns according to pixel points, moving the first longitudinal area from the left side of the track image to the left side of the R, moving the width of one column of the longitudinal width of the image to the right side of the track image to obtain the second longitudinal area from the left side of the track image to the left side of the R +1, and moving the width of one column of the longitudinal width of the image to the right side of the track image in the same mode until the longitudinal area with the width of R reaches the right side of the image.
[2] Calculating the average value of the gray levels of the pixels of each longitudinal area with the width of R of the track image;
[3] and marking the steel rail image according to the gray average value of the pixels of each longitudinal area.
And counting the average value of the gray levels of the pixels of each longitudinal region with the width of R in the track image, and determining the longitudinal region with the width of R with the maximum average value as the region where the steel rail is positioned, thereby marking the image of the steel rail.
As can be seen from the above, in an embodiment, determining the image of the rail region to be detected from the acquired track image according to the preset gray value feature and the width value feature of the top surface of the rail may include:
dividing the track image into a plurality of longitudinal areas with the width being the width of the top surface of the steel rail in a mode that the moving step length is one row of the width of the image in the longitudinal direction from one side of the track image which is longitudinally parallel to the steel rail;
determining the gray average value of each pixel of a longitudinal area with the width of the top surface of the steel rail of each rail image;
and determining a steel rail area image according to the gray average value of the pixels of each longitudinal area.
During specific implementation, the further implementation mode for determining the image of the steel rail area to be detected further improves the efficiency and accuracy for determining the image of the steel rail area to be detected, and further improves the detection efficiency and accuracy of the contact fatigue crack of the steel rail.
As can be seen from the above, in an embodiment, determining a rail region image according to a gray-scale average of pixels of each longitudinal region may include:
determining the longitudinal area with the maximum average value width as the width of the top surface of the steel rail as the area where the steel rail is located according to the gray average value of the pixels of the longitudinal area with the width of the top surface of the steel rail of each rail image, and determining the image of the steel rail area according to the area where the steel rail is located.
In specific implementation, the embodiment of determining the rail region image according to the gray average of the pixels of each longitudinal region further improves the efficiency and accuracy of determining the rail region image to be detected, and further improves the detection efficiency and accuracy of the rail contact fatigue crack.
And b, dividing the marked image of the steel rail into a plurality of unit areas, and counting the gradient direction histogram of each unit area, namely the step 102.
Image of marked rail as shown in fig. 3, the image of the rail is divided into a plurality of unit areas, for example, each unit area is 32 × 32 pixels. For each unit region, counting a gradient direction histogram of the unit region, specifically including the following steps:
[1] and calculating the gradient direction of each pixel point of the unit area.
Convolving two sobel edge detection operators with each pixel point of the unit area respectively, and calculating the gradient value sum of the pointsThe direction of the gradient. The two sobel edge detection operators used are shown in fig. 4a and 4b, where sobel edge detection operator 1 (first sobel edge detection operator) shown in fig. 4a is used to calculate the horizontal gradient g
xThe sobel edge detection operator 2 (second sobel edge detection operator) shown in FIG. 4b is used to calculate the vertical gradient g
y. Gradient value of each pixel
Direction of gradient
θ∈(-90°,90°]。
[2] And counting the gradient direction histogram of the unit area.
Gradient direction theta of each pixel point in unit area belongs to (-90 DEG, 90 DEG)]Firstly, the gradient direction range is divided into 18 (a plurality of gradient direction range groups), each gradient direction range group is formed by every 10 degrees, and each pixel point of the unit area is classified into one group according to the gradient direction. For example, if the gradient direction θ of a pixel is 45 °, the pixel is classified into a group of 40 ° to 50 °. Then, the gradient values corresponding to all the pixel points in each group are accumulated to obtain 18 numerical values. The histogram of gradient directions is an array [ h ] composed of the 18 values1,h2,h3,…,h18]The angle range corresponding to the gradient direction is [ -90 DEG to-80 DEG, -80 DEG to-70 DEG, -70 DEG to-60 DEG, - … DEG, 80 DEG to 90 DEG]. The histogram representation method is insensitive to the change of the gray value of a single pixel, reduces the influence of illumination and the like on an image, and improves the detection efficiency and accuracy of the contact fatigue crack of the steel rail.
As can be seen from the above, in one embodiment, determining a gradient direction histogram of each unit region may include:
determining the gradient value and gradient direction of each pixel point of each unit area;
and determining a gradient direction histogram of each unit region according to the gradient value and the gradient direction of each pixel point.
In specific implementation, the implementation mode of determining the gradient direction histogram of each unit area improves the detection efficiency and accuracy of the steel rail contact fatigue crack.
As can be seen from the above, in an embodiment, determining the gradient value and the gradient direction of each pixel point of each unit region may include:
convolving the first Sobel edge detection operator with each pixel point of each unit area to obtain a horizontal gradient;
convolving the second sobel operator edge detection operator with each pixel point of each unit area to obtain a vertical gradient;
and determining the gradient value and the gradient direction of each pixel point according to the horizontal gradient and the vertical gradient.
In specific implementation, the implementation mode of determining the gradient value and the gradient direction of each pixel point of each unit area improves the detection efficiency and accuracy of the steel rail contact fatigue crack.
As can be seen from the above, in an embodiment, determining a gradient direction histogram of each unit region according to the gradient value and the gradient direction of each pixel point may include:
classifying each pixel point into one of a plurality of pre-divided gradient direction range groups according to the gradient direction of each pixel point;
accumulating the gradient values corresponding to all the pixel points in each group to obtain a plurality of gradient accumulated values;
and determining a gradient direction histogram of each unit region according to the plurality of gradient accumulated values and the angle range of the gradient direction corresponding to each gradient accumulated value.
In specific implementation, the implementation mode of determining the gradient direction histogram of each unit region according to the gradient value and the gradient direction of each pixel point further improves the detection efficiency and accuracy of the steel rail contact fatigue crack.
And c, judging whether the contact fatigue crack exists in each unit region according to the gradient direction characteristic of the contact fatigue crack, namely the step 103.
The undamaged rail surface is smooth and flat, while the rail surface with contact fatigue cracks has obvious abnormal characteristics. The contact fatigue crack has obvious directionality, the crack and the longitudinal direction of the steel rail form a certain angle, the crack is shown on an image of the steel rail, and the gradient direction of a pixel point at the position of the contact fatigue crack forms a certain angle with the longitudinal direction of the steel rail. The method for judging whether contact fatigue cracks exist in each unit area by utilizing the characteristics comprises the following steps:
[1] the gradient direction histogram of each unit area is normalized.
For the ith unit area, calculating the gradient direction histogram [ h ] of the unit areai1,hi2,hi3,…,hi18]Sum ofih:
The following formula is then utilized:
performing histogram normalization of gradient direction on the histogram of gradient direction of the unit region, [ h _ normi1,h_normi2,h_normi3,…,h_normi18]The histogram of the normalized gradient direction of the unit area is obtained, and the angle ranges corresponding to the gradient direction are [ -90 DEG to-80 DEG, -80 DEG to-70 DEG, -70 DEG to-60 DEG, - … DEG, and 80 DEG to 90 DEG]。
[2] And calculating the sum of the normalized gradients of the normalized gradient direction histograms of each unit region in a gradient direction range of-80 DEG to-10 DEG (a first preset gradient direction range).
For the ith unit area, the normalized gradient direction histogram of the unit area is the sum of normalized gradients in the gradient direction range of-80 DEG to-10 DEG
[3] The sum of the normalized gradients of the normalized gradient direction histogram of each unit region in the gradient direction range of 10 ° to 80 ° (second preset gradient direction range) is calculated.
For the ith unit area, the normalized gradient direction histogram of the unit area is the sum of the normalized gradients in the gradient direction range of 10-80 DEG
[4] Comparing the sum of the normalized gradients of the normalized gradient direction histograms of the unit areas in the gradient direction range of-80 DEG to-10 DEG and the sum of the normalized gradients in the gradient direction range of 10 DEG to 80 DEG with a significance ratio (a preset characteristic ratio), and judging whether contact fatigue cracks exist in each unit area.
The cell region a in the rail image shown in fig. 5 has contact fatigue cracks, and the cell region B has no contact fatigue cracks. Fig. 6 is a normalized gradient direction histogram of the cell region a, and it can be seen from the histogram that the gradient direction occupies a large proportion in the range of 10 ° to 80 °, and the sum of the normalized gradients in the range of 10 ° to 80 ° in the gradient direction is calculated to be 0.6067. Fig. 7 is a normalized gradient direction histogram of the cell region B, and it can be seen from the histogram that the proportion of the gradient directions in each group is approximately the same, and the sum of the normalized gradients in the gradient direction in the range of 10 ° to 80 ° is calculated to be 0.3857 between 0.05 and 0.06.
By using the above feature, the sum of normalized gradients of the normalized gradient direction histogram of each cell region in the gradient direction range of-80 ° to-10 ° and the sum of normalized gradients of the normalized gradient direction histogram of 10 ° to 80 ° are compared with the saliency ratio (here, the saliency ratio is 0.55), and if the sum of normalized gradients of the normalized gradient direction histogram of the cell region in the gradient direction range of-80 ° to-10 ° or the sum of normalized gradients of the normalized gradient direction histogram of the cell region in the gradient direction range of 10 ° to 80 ° is greater than the saliency ratio, it is determined that the contact fatigue crack exists in the cell region.
From the above description, in an embodiment, the detecting whether the contact fatigue crack exists in each unit region according to the preset gradient direction characteristic of the contact fatigue crack of the steel rail and the gradient direction histogram of each unit region may include:
normalizing the gradient direction histogram of each unit area to obtain a normalized gradient direction histogram of each unit area;
determining the sum of normalized gradients of the normalized gradient direction histogram of each unit area in a first preset gradient direction range;
determining the sum of the normalized gradients of the normalized gradient direction histogram of each unit area in a second preset gradient direction range;
and comparing the sum of the normalized gradients in the first preset gradient direction range and the sum of the normalized gradients in the second preset gradient direction range with a preset characteristic proportion to determine whether the contact fatigue crack exists in each unit region.
In specific implementation, the embodiment of detecting whether the contact fatigue crack exists in each unit area further improves the detection efficiency and accuracy of the contact fatigue crack of the steel rail.
In summary, the method for detecting contact fatigue cracks of a steel rail provided by the embodiment of the invention utilizes the gradient direction characteristics of the contact fatigue cracks in the steel rail image, and automatically and accurately detects whether the contact fatigue cracks exist in the steel rail by calculating the normalized gradient direction histogram of the unit area in the steel rail image.
The embodiment of the invention also provides a detection device for the contact fatigue crack of the steel rail, which is described in the following embodiment. Because the principle of solving the problems by the device is similar to the detection method of the contact fatigue cracks of the steel rail, the implementation of the device can refer to the implementation of the detection method of the contact fatigue cracks of the steel rail, and repeated parts are not described again.
Fig. 8 is a schematic structural diagram of a detection apparatus for contact fatigue crack of a steel rail according to an embodiment of the present invention, as shown in fig. 8, the apparatus includes:
the steel rail image determining unit 01 is used for determining an image of a steel rail area to be detected from the acquired track image;
the histogram determining unit 02 is used for dividing the determined steel rail area image to be detected into a plurality of unit areas and determining a gradient direction histogram of each unit area;
the detecting unit 03 is configured to detect whether a contact fatigue crack exists in each unit region according to a preset gradient direction characteristic of the steel rail contact fatigue crack and a gradient direction histogram of each unit region.
In an embodiment, the rail image determination unit may be specifically configured to: and determining the image of the steel rail area to be detected from the acquired rail image according to the preset gray value characteristic and the width value characteristic of the top surface of the steel rail.
In an embodiment, the rail image determination unit may be specifically configured to:
dividing the track image into a plurality of longitudinal areas with the width being the width of the top surface of the steel rail in a mode that the moving step length is one row of the width of the image in the longitudinal direction from one side of the track image which is longitudinally parallel to the steel rail;
determining the gray average value of each pixel of a longitudinal area with the width of the top surface of the steel rail of each rail image;
and determining a steel rail area image according to the gray average value of the pixels of each longitudinal area.
In one embodiment, determining the rail region image according to the gray-scale average of the pixels of each longitudinal region may include:
determining the longitudinal area with the maximum average value width as the width of the top surface of the steel rail as the area where the steel rail is located according to the gray average value of the pixels of the longitudinal area with the width of the top surface of the steel rail of each rail image, and determining the image of the steel rail area according to the area where the steel rail is located.
In one embodiment, the histogram determination unit may be configured to:
determining the gradient value and gradient direction of each pixel point of each unit area;
and determining a gradient direction histogram of each unit region according to the gradient value and the gradient direction of each pixel point.
In one embodiment, determining the gradient value and gradient direction of each pixel point of each unit region may include:
convolving the first Sobel edge detection operator with each pixel point of each unit area to obtain a horizontal gradient;
convolving the second sobel operator edge detection operator with each pixel point of each unit area to obtain a vertical gradient;
and determining the gradient value and the gradient direction of each pixel point according to the horizontal gradient and the vertical gradient.
In one embodiment, determining a gradient direction histogram of each unit region according to the gradient value and the gradient direction of each pixel point may include:
classifying each pixel point into one of a plurality of pre-divided gradient direction range groups according to the gradient direction of each pixel point;
accumulating the gradient values corresponding to all the pixel points in each group to obtain a plurality of gradient accumulated values;
and determining a gradient direction histogram of each unit region according to the plurality of gradient accumulated values and the angle range of the gradient direction corresponding to each gradient accumulated value.
In an embodiment, the detection unit may be specifically configured to:
normalizing the gradient direction histogram of each unit area to obtain a normalized gradient direction histogram of each unit area;
determining the sum of normalized gradients of the normalized gradient direction histogram of each unit area in a first preset gradient direction range;
determining the sum of the normalized gradients of the normalized gradient direction histogram of each unit area in a second preset gradient direction range;
and comparing the sum of the normalized gradients in the first preset gradient direction range and the sum of the normalized gradients in the second preset gradient direction range with a preset characteristic proportion to determine whether the contact fatigue crack exists in each unit region.
The embodiment of the invention also provides computer equipment which comprises a memory, a processor and a computer program which is stored on the memory and can run on the processor, wherein the processor executes the computer program to realize the detection method of the steel rail contact fatigue crack.
Embodiments of the present invention also provide a computer-readable storage medium storing a computer program for executing the method for detecting a rail contact fatigue crack.
The detection scheme of the steel rail contact fatigue crack provided by the embodiment of the invention has the beneficial effects that:
the automatic detection method for the contact fatigue cracks of the steel rail based on the image processing can automatically and accurately detect the contact fatigue cracks of the steel rail from the acquired track image, and effectively reduces the manual input of the detection of the contact fatigue cracks of the steel rail. Compared with the existing method for the contact fatigue crack of the steel rail based on machine vision, the detection scheme provided by the embodiment of the invention utilizes the gradient direction characteristic of the contact fatigue crack in the steel rail image, and judges whether the contact fatigue crack exists in the steel rail by calculating the normalized gradient direction histogram of the unit area in the steel rail image. The detection method based on the gradient direction histogram fully utilizes the gradient direction characteristics of the contact fatigue cracks in the steel rail image, is insensitive to the change of the gray value of a single pixel of the image, reduces the influence of factors such as illumination and the like on the image, ensures the accuracy of the detection of the contact fatigue cracks of the steel rail in a specific application scene, and has simple algorithm and easy realization. The invention realizes the automatic, efficient and accurate detection of the contact fatigue cracks of the steel rail and provides reliable basis for the maintenance and repair of the rail.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
The above-mentioned embodiments are intended to illustrate the objects, technical solutions and advantages of the present invention in further detail, and it should be understood that the above-mentioned embodiments are only exemplary embodiments of the present invention, and are not intended to limit the scope of the present invention, and any modifications, equivalent substitutions, improvements and the like made within the spirit and principle of the present invention should be included in the scope of the present invention.