A data preprocessing method for rail image defect detection
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- CHONGQING UNIV OF POSTS & TELECOMM
- Filing Date
- 2026-03-10
- Publication Date
- 2026-06-09
Smart Images

Figure CN122176336A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of computer vision and relates to a data preprocessing method for detecting defects in railway track images. Background Technology
[0002] As a fundamental infrastructure of the railway system, the safety of railway tracks directly affects the safe operation of trains and the safety of people's lives and property. The quality and integrity of railway tracks are prerequisites for ensuring the safe and efficient operation of trains; therefore, any potential defects can pose a serious threat to the safety of railway transportation. During long-term use, railway tracks are prone to defects such as cracks, breaks, and gaps due to the immense pressure and friction they endure. If these defects are not detected and repaired in a timely manner, they may lead to serious accidents such as train derailments and derailments, resulting in significant casualties and property damage.
[0003] Therefore, strengthening the monitoring and maintenance of railway tracks, and employing advanced testing technologies for regular inspection and evaluation, is of paramount importance. A sound railway safety management system should be established, fully utilizing modern technology, particularly non-destructive testing techniques, intelligent monitoring systems, and big data analytics, to enhance real-time monitoring capabilities of railway track conditions. This will not only help to promptly identify potential hazards and ensure the safe operation of trains, but also improve the overall efficiency and reliability of railway transportation.
[0004] To achieve this goal, existing maintenance and repair processes need to be optimized, and scientifically sound testing standards and maintenance plans need to be developed. Simultaneously, regular safety and technical training should be provided to employees to improve their professional skills and emergency response capabilities. Building on this foundation, utilizing intelligent equipment for automated testing can reduce safety hazards caused by human error and ensure the accuracy and timeliness of test results. This makes the use of intelligent equipment for rail defect detection an unstoppable trend.
[0005] Significant progress has been made in artificial intelligence technology in recent years, with breakthroughs particularly in machine vision. This advancement has led to the emergence of various neural network models that offer high accuracy and fast response times. The introduction of these models provides a new solution for rail defect detection, significantly reducing investment in human and material resources while improving accuracy and efficiency. The You Only Look Once (YOLO) model series, as a widely used target detection framework, has been extensively applied in railway track defect detection, demonstrating good accuracy and performance. Therefore, researching how to utilize relevant methods for rail defect detection is particularly important. Summary of the Invention
[0006] In view of this, the purpose of this invention is to provide a data preprocessing method for railway track image defect detection, which improves the accuracy, real-time monitoring capability, adaptability and robustness of railway track defect detection.
[0007] First, improving detection accuracy is crucial, which means developing detection algorithms capable of efficiently identifying various types of defects, such as cracks. This typically involves utilizing advanced image processing techniques and deep learning algorithms to reduce false positives and false negatives, ensuring accurate defect identification even in complex environments. Real-time monitoring capabilities are equally important. In railway operations, the ability to rapidly analyze track conditions while trains are running is critical; therefore, one research objective is to design efficient detection systems to promptly identify potential safety hazards. This requires systems with rapid response capabilities, enabling real-time defect identification as trains pass.
[0008] Furthermore, adaptability and robustness are also important research directions. Research aims to improve the adaptability of detection systems under different environmental conditions, such as the effects of varying lighting and severe weather. Ensuring the system can accurately identify defects even under complex backgrounds will enhance its reliability in practical applications. Automation and intelligence are another goal of modern detection systems. By automating the detection process, research hopes to reduce human intervention and improve detection efficiency. This includes developing self-learning algorithms that can continuously optimize themselves based on data to improve detection performance.
[0009] Furthermore, the research focuses on versatility, aiming to design a system capable of simultaneously detecting multiple defect types, avoiding the development of independent detection schemes for each defect, thereby reducing maintenance costs and system complexity. This requires establishing a large-scale, diverse defect dataset to support the training of deep learning models, ensuring that the models maintain efficient detection capabilities in various real-world scenarios. System integration and field application are also important research objectives, aiming to effectively integrate the detection system with existing railway monitoring systems to ensure its feasibility and practicality in actual railway operations. This involves the coordination of hardware and software, as well as compatibility with existing maintenance procedures.
[0010] Finally, cost reduction and efficiency improvement are among the research goals. By developing efficient detection algorithms, this research aims to reduce overall detection costs while increasing detection frequency and coverage, thereby achieving more comprehensive track safety monitoring. Furthermore, designing an easy-to-use and understandable user interface, enabling railway staff to easily use the detection system and quickly obtain detection results and recommendations, is also an important consideration in this research.
[0011] By achieving these goals, rail defect detection technology will significantly improve the safety and reliability of railway transportation, providing important support for the sustainable development of the railway industry.
[0012] To achieve the above objectives, the present invention provides the following technical solution: Solution 1: A data preprocessing method for railway track image defect detection, which first reads the original railway track image collected on site and converts the original three-channel color image into a single-channel grayscale image; Next, the CLAHE method is used for illumination correction, where CLAHE represents adaptive histogram equalization with limited contrast. After completing the illumination correction, the direction-aware morphological opening operation is performed using the long strip morphological structural elements constructed along the vertical direction. By utilizing the operation characteristics of erosion followed by dilation, the image is smoothed while removing horizontally distributed small noise, isolated noise and irregular interference, and retaining the target defect structure such as typical longitudinal cracks and narrow gaps on the rail surface. Then, a multi-scale top-hat transformation is used to enhance defects of different scales in layers; Then, morphological gradient operations constructed along the vertical direction are used to extract edge and contour information distributed along the vertical direction in the image, and the boundary features of cracks and gaps are strengthened in a targeted manner while irrelevant background textures are weakened. Finally, the image is further refined through lightweight morphological reconstruction.
[0013] Furthermore, the CLAHE method specifically divides the image into multiple small blocks, performs histogram equalization on each small block independently, and avoids over-enhancement by limiting contrast.
[0014] Furthermore, the multi-scale top-hat transformation specifically includes: using structuring elements of three different sizes (small, medium, and large) to sequentially extract fine cracks, medium-sized gaps, and large-area defect areas from the image; then performing weighted fusion according to the strategy of assigning high weights to fine crack areas and low weights to large-area defect areas; and superimposing the multi-scale enhancement results onto the image processed by the directional opening operation.
[0015] Furthermore, the morphological reconstruction operation specifically includes: first, using small-sized structuring elements to perform slight erosion to remove residual tiny isolated noise points; then, restoring the original shape and size of the defect through moderate dilation; achieving accurate noise reduction without destroying the integrity of the slender and weak defect structure; finally obtaining a grayscale image with less noise, high contrast, and prominent defect features; and converting it back to the BGR three-channel format, which is then input into a target detection model (such as the YOLO model series) for subsequent network training and defect recognition.
[0016] Option 2: A railway track image defect detection system, comprising an image acquisition module, a preprocessing module, and a training and recognition module, wherein the preprocessing module is used to execute the data preprocessing method of Option 1.
[0017] The beneficial effects of this invention are as follows: This invention combines CLAHE adaptive illumination correction, directional morphological filtering, multi-scale top-hat transformation, and morphological reconstruction techniques to effectively address issues such as uneven illumination, reflections, shadows, numerous background noise points, and indistinct weak defects in actual railway track images. While removing noise and interference, it maximizes the preservation and enhancement of typical defect features such as longitudinal cracks, small gaps, medium gaps, and large gaps, significantly improving the contrast between the defect area and the background. This makes weak and subtle defects more clearly visible, avoiding missed or false detections due to poor image quality. The use of directional structuring elements for morphological operations allows for targeted preservation of longitudinal defects in the railway track, suppressing lateral noise interference and improving the scene adaptability and robustness of preprocessing. The multi-scale enhancement strategy can simultaneously adapt to the enhancement needs of defects of different sizes and shapes, ensuring that all types of defects are effectively highlighted. Finally, morphological reconstruction further purifies the image without destroying the defect structure, reducing redundant interference. The overall preprocessing process is stable, efficient, and highly practical for engineering applications. It can provide high-quality, high-recognition input images for subsequent YOLO detection models, effectively improving the model's detection accuracy, positioning accuracy, and generalization ability for rail defects. It is suitable for automatic rail defect detection tasks in complex industrial scenarios.
[0018] Other advantages, objectives, and features of the invention will be set forth in part in the description which follows, and in part will be apparent to those skilled in the art from the following examination, or may be learned from practice of the invention. The objectives and other advantages of the invention can be realized and obtained through the following description. Attached Figure Description
[0019] To make the objectives, technical solutions, and advantages of the present invention clearer, the preferred embodiments of the present invention will be described in detail below with reference to the accompanying drawings, wherein: Figure 1 Flowchart of the data preprocessing method provided by the present invention; Figure 2 Images showing the effects of different illumination correction methods; Figure 3 This is the original image of the railway track. Detailed Implementation
[0020] The following specific examples illustrate the implementation of the present invention. Those skilled in the art can easily understand other advantages and effects of the present invention from the content disclosed in this specification. The present invention can also be implemented or applied through other different specific embodiments, and various details in this specification can be modified or changed based on different viewpoints and applications without departing from the spirit of the present invention. It should be noted that the illustrations provided in the following embodiments are only schematic representations of the basic concept of the present invention. Unless otherwise specified, the following embodiments and features can be combined with each other.
[0021] The accompanying drawings are for illustrative purposes only and are schematic diagrams, not actual pictures. They should not be construed as limiting the invention. To better illustrate the embodiments of the invention, some parts in the drawings may be omitted, enlarged, or reduced, and do not represent the actual product dimensions. It is understandable to those skilled in the art that some well-known structures and their descriptions may be omitted in the drawings.
[0022] In the accompanying drawings of the embodiments of the present invention, the same or similar reference numerals correspond to the same or similar components. In the description of the present invention, it should be understood that if terms such as "upper," "lower," "left," "right," "front," and "rear" indicate the orientation or positional relationship based on the orientation or positional relationship shown in the drawings, they are only for the convenience of describing the present invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, the terms used to describe positional relationships in the drawings are only for illustrative purposes and should not be construed as limiting the present invention. For those skilled in the art, the specific meaning of the above terms can be understood according to the specific circumstances.
[0023] Please see Figures 1-3 This invention provides a data preprocessing method for detecting defects in railway track images. The specific processing flow is as follows: First, the original railway track image collected on site is read, and the original three-channel color image is converted into a single-channel grayscale image. During this process, color information unrelated to the defect structure is removed. While preserving the image brightness and texture features, the computational load of subsequent algorithms is greatly reduced, and the information dimension of the image is unified, laying a stable data foundation for a series of subsequent image enhancement, noise suppression, and defect enhancement operations.
[0024] Next, the contrast-limited adaptive histogram equalization (CLAHE) method is used for illumination correction. This method divides the entire image into several uniformly sized image blocks and performs histogram equalization independently within each sub-block. Simultaneously, by limiting the contrast parameter, it suppresses over-enhancement, effectively solving common problems in actual railway track images such as strong light reflection, local overexposure, large-area shadows, and uneven illumination distribution. This makes the brightness distribution of the entire image more uniform, preventing weak defect features from being obscured by bright or dark areas, and improving the overall analyzability of the image.
[0025] After illumination correction, direction-aware morphological opening operations are performed using vertically constructed elongated morphological structuring elements (e.g., 1×5). Leveraging the erosion-dilation operation, the image is smoothed while removing horizontally distributed fine specks, isolated noise, and irregular interference. Simultaneously, typical longitudinal cracks and narrow gaps on the rail surface are preserved to the greatest extent possible, achieving targeted noise reduction and key feature protection, ensuring the image is cleaned without losing weak defect information.
[0026] Based on this, a multi-scale top-hat transform is used to enhance defects of different scales in layers. Small, medium and large structuring elements (such as 3×3, 5×5 and 9×9) are used to extract fine cracks, medium-sized gaps and large-area defects in the image in sequence. Then, according to the strategy of giving higher weight to fine defects and appropriately reducing the weight of large structuring elements, the multi-scale enhancement results are superimposed on the image processed by directional opening operation to further improve the brightness and contrast of various defects and make the difference between the defect area and the background more obvious.
[0027] Subsequently, morphological gradient operations constructed along the vertical direction are used to extract edge and contour information distributed along the longitudinal direction in the image. The boundary features of cracks and gaps are enhanced in a targeted manner, while irrelevant background textures are weakened, making the contours of defects clearer and sharper. This is beneficial for the subsequent YOLO detection model to more accurately complete defect localization and boundary regression.
[0028] Finally, the image is further purified through lightweight morphological reconstruction. First, small-sized structuring elements are used for slight erosion to remove residual tiny isolated noise points. Then, moderate dilation is used to restore the original shape and size of the defect. Precise noise reduction is achieved without destroying the integrity of the slender and weak defect structure. Finally, a grayscale image with less noise, high contrast and prominent defect features is obtained. This image is then converted back to the BGR three-channel format to meet the input format requirements of the YOLO object detection model, so that it can be directly used for subsequent network training and defect recognition.
[0029] The whole process is as follows Figure 1As shown, closely focusing on the characteristics of rail defects such as longitudinal distribution, multi-scale changes, and susceptibility to lighting and noise interference, this paper organically combines adaptive lighting correction, orientation-aware morphological processing, multi-scale defect enhancement, and refined morphological reconstruction to construct an end-to-end, highly adaptive YOLO model-specific image preprocessing workflow for rail defects. This workflow can significantly improve the identification of weak and minute defects, effectively reduce the impact of lighting changes and noise interference on detection accuracy in complex field environments, and provide reliable data support for subsequent high-precision rail defect detection.
[0030] To verify the enhancement effect of the CLAHE illumination correction method used in this invention on rail defect images, three classic methods—Global Histogram Equalization (HE), Adaptive Histogram Equalization (AHE), and Gamma correction—were compared. While maintaining complete consistency between the subsequent preprocessing workflow and the detection model, the advantages and disadvantages of different illumination correction methods were evaluated from both subjective visual effects and objective detection accuracy to determine the most suitable illumination processing scheme for rail defect detection.
[0031] Global histogram equalization (HE) equalizes the global grayscale distribution of an image, improving overall contrast. However, it is prone to over-enhancing noise and can cause information loss in bright and shadowy areas, resulting in an image like... Figure 2 As shown in (a), Adaptive Histogram Equalization (AHE) performs local equalization in blocks, which can improve local illumination unevenness, but it has no contrast limitation and is prone to block artifacts and over-enhancement. The processed image is shown in (a). Figure 2 As shown in (b), gamma correction adjusts the overall brightness using a power function, but its ability to improve localized illumination unevenness is relatively weak. The processed image is as follows. Figure 2 As shown in (c), Limit Contrast Adaptive Histogram Equalization (CLAHE) with block equalization and contrast limiting effectively suppresses reflections, shadows, and uneven lighting, while protecting weak defects and suppressing noise amplification. The processed image is shown below. Figure 2 As shown in (d).
[0032] The YOLO11 object detection model was trained on a publicly available dataset from Robot.org, using original images viewed subjectively (e.g., ...). Figure 3The image exhibits significant uneven lighting, with some areas being too bright or too dark, making it difficult to distinguish weak defects. While the HE method improves contrast, it also significantly amplifies background noise, interfering with defect edges. The AHE method offers some improvement in local brightness, but noticeable block artifacts and texture distortion appear. Gamma correction only adjusts overall brightness, with limited effect on correcting local reflections and shadows. The CLAHE method effectively eliminates reflections and shadows on the rail surface, resulting in uniform brightness across the entire image while preserving the detailed texture of cracks and gaps. It also offers the best noise suppression effect, making it more conducive to subsequent defect feature extraction. Specific comparison results are shown in Table 1.
[0033] Table 1 Comparison of different illumination correction methods
[0034] Among the four illumination correction methods, CLAHE performs best in both objective detection accuracy and subjective visual effect. It can significantly improve the contrast of weak defects, suppress noise and artifacts, and effectively solve the complex lighting problems in industrial environments. Therefore, this invention selects CLAHE as the illumination correction module in the preprocessing method.
[0035] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the present invention, and all such modifications or substitutions should be covered within the scope of the claims of the present invention.
Claims
1. A data preprocessing method for detecting defects in railway track images, characterized in that, First, the original railway track images collected on-site are read, and the original three-channel color images are converted into single-channel grayscale images; Next, the CLAHE method is used for illumination correction, where CLAHE represents adaptive histogram equalization with limited contrast. After completing the illumination correction, the direction-aware morphological opening operation is performed using the long strip morphological structural elements constructed along the vertical direction. By utilizing the operation characteristics of erosion followed by dilation, the horizontally distributed small noise, isolated noise and irregular interference are removed while smoothing the image, and the target defect structure of longitudinal cracks and narrow gaps on the rail surface is preserved. Then, a multi-scale top-hat transformation is used to enhance defects of different scales in layers; Then, morphological gradient operations constructed along the vertical direction are used to extract edge and contour information distributed along the vertical direction in the image, enhance the boundary features of cracks and gaps, and weaken irrelevant background textures. Finally, the image was further refined through morphological reconstruction.
2. The data preprocessing method for railway track image defect detection according to claim 1, characterized in that, The CLAHE method specifically divides the image into multiple small blocks, performs histogram equalization on each block independently, and avoids over-enhancement by limiting contrast.
3. The data preprocessing method for railway track image defect detection according to claim 1, characterized in that, The multi-scale top-hat transformation specifically includes: using structuring elements of three different sizes (small, medium, and large) to sequentially extract fine cracks, medium-sized gaps, and large-area defect regions from the image; then performing weighted fusion according to the strategy of assigning high weights to fine crack regions and low weights to large-area defect regions; and superimposing the multi-scale enhancement results onto the image processed by the directional opening operation.
4. The data preprocessing method for railway track image defect detection according to claim 1, characterized in that, The morphological reconstruction operation specifically includes: first, using small-sized structuring elements to perform slight erosion to remove residual tiny isolated noise points; then, restoring the original shape and size of the defect through moderate dilation; achieving precise noise reduction without destroying the integrity of the slender and weak defect structure; finally obtaining a grayscale image with less noise, high contrast, and prominent defect features; and then converting it back to the BGR three-channel format.
5. The data preprocessing method for railway track image defect detection according to claim 4, characterized in that, The image converted back to BGR three-channel format is input into the object detection model for subsequent network training and defect identification.
6. The data preprocessing method for railway track image defect detection according to claim 5, characterized in that, The target detection models include the YOLO model family.
7. A railway track image defect detection system, comprising an image acquisition module, a preprocessing module, and a training and recognition module, characterized in that, The preprocessing module is used to perform the data preprocessing method according to any one of claims 1 to 4.