Crack image segmentation method and system
By employing multi-scale feature extraction, global self-attention, and topology-aware structure reconstruction, the problems of structural breakage and edge blurring in crack segmentation are solved, achieving higher accuracy and robustness in crack image segmentation.
Patent Information
- Application Number
- CN202511749733.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-26
- Publication Date
- 2026-02-27
AI Technical Summary
Existing crack segmentation methods suffer from structural fracture, blurred edges, and loss of details, making it difficult to meet the requirements of high accuracy and robustness, especially when dealing with long, thin cracks across regions and complex backgrounds.
We employ multi-scale feature extraction combined with a global self-attention mechanism, enhance the topological features of cracks through multi-branch directional convolution, perform topology-aware structure reconstruction, and use a hybrid loss function to optimize the segmentation results.
It effectively solves the problems of structural breakage, edge blurring and loss of details in traditional methods, and improves the robustness and accuracy of crack segmentation, especially in complex scenes where it can extract crack contours more completely and precisely.
Smart Images

Figure CN121582579A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computer vision and image processing, and particularly relates to a crack image segmentation method and system. BACKGROUND
[0002] Crack is one of the most common and typical structural diseases in concrete structures, and therefore, its timely and accurate detection is of great significance for evaluating the health status of the structure, preventing safety accidents, and reducing maintenance costs.
[0003] In recent years, crack detection methods based on digital images have been widely used due to their non-contact, high efficiency, and low cost. Among them, image segmentation technology can accurately extract the pixel-level contour of the crack from the complex background, providing a basis for subsequent quantitative analysis (such as width calculation, length measurement, and disease level assessment), and has become a research hotspot in this field.
[0004] Early crack segmentation methods mainly rely on manually designed low-level features (such as edges, textures, and gray-scale statistical features) and traditional image processing algorithms such as threshold segmentation and region growing. However, these methods are heavily dependent on expert experience and parameter tuning, and have poor generalization ability in uneven lighting, complex background texture, and noise interference, making it difficult to meet the requirements of high precision and robustness.
[0005] With the breakthrough of deep learning technology, semantic segmentation models based on CNN (Convolutional Neural Network), such as FCN (Fully Convolutional Network), U-NET, and DeepLab series, have become the mainstream solution for crack segmentation. These methods can automatically extract more discriminative features from data through an end-to-end learning approach, significantly improving segmentation accuracy. However, there are inherent limitations in CNN-based crack segmentation models: first, CNN relies on local convolution operations, and its receptive field is limited, making it difficult to model the long-distance topological dependence formed by the winding of cracks for hundreds of pixels, resulting in structural breaks and context loss when processing long and thin cracks across regions; second, crack morphology is complex, with variable width, multi-scale characteristics, and anisotropy in direction, while the fixed shape of the square convolution kernel used by traditional CNN is insufficient to capture these characteristics, and its single-scale receptive field also makes it difficult to effectively extract crack features of different sizes; third, when the decoder performs up-sampling to restore the resolution, conventional methods (such as transposed convolution or interpolation) lack targeted modeling of the elongated structure of the crack, resulting in blurred edges and loss of details in the reconstructed crack, especially for the branch part of the micro-crack, which severely restricts the fineness and practicality of the segmentation result. SUMMARY
[0006] To this end, the technical problem to be solved by the present application is to overcome the problems of structure breaking, edge blurring and detail loss in the existing crack segmentation.
[0007] To solve the above technical problems, the present application provides a crack image segmentation method, comprising the following steps: S10: performing multi-scale feature extraction on the collected crack image to obtain a feature representation containing local details and global context information; S20: performing topological perception enhancement on the feature representation to obtain a direction-enhanced feature map; S30: performing topological perception structure reconstruction and up-sampling on the direction-enhanced feature map to obtain a high-resolution segmentation result; S40: optimizing the high-resolution segmentation result to obtain an optimized segmentation result.
[0008] In an embodiment of the present application, in step S20, the method of topological perception enhancement on the feature representation to obtain a direction-enhanced feature map comprises the following steps: S21: performing multi-branch convolution processing on the feature representation to extract topological features of the crack through multiple convolution paths with different direction selectivity and multi-scale receptive fields; S22: concatenating multiple feature maps obtained by multi-branch convolution processing along the channel dimension to obtain a multi-directional feature combination; S23: performing convolution fusion on the multi-directional feature combination to adaptively integrate topological information of different directions to obtain the direction-enhanced feature map.
[0009] In an embodiment of the present application, in step S21, the multi-branch convolution processing includes four-branch convolution processing, and the specific method is: extracting horizontal direction features by horizontal stripe convolution, extracting vertical direction features by vertical stripe convolution, extracting first scale context features by first dilated convolution, and extracting second scale context features by second dilated convolution; after concatenating the feature maps output by the four branches along the channel, performing feature fusion by convolution.
[0010] In an embodiment of the present application, in step S30, the method of topological perception structure reconstruction and up-sampling on the direction-enhanced feature map to obtain a high-resolution segmentation result comprises the following steps: S31: performing multi-directional convolution processing on the direction-enhanced feature map to extract multi-directional structure features of the crack through multiple convolution paths with different direction selectivity; S32: concatenating feature maps obtained by multiple path convolution processing along the channel dimension to form multi-directional structure features; S33: Convolutional fusion is performed on the spliced multi-direction structural features to realize adaptive weighted integration of the direction features; S34: The fused feature map is up-sampled to restore the spatial resolution through pixel rearrangement to obtain the high-resolution segmentation result.
[0011] In an embodiment of the present application, in step S31, the method for performing multi-direction convolution processing on the direction enhanced feature map is as follows: horizontal direction structural features are extracted through horizontal strip convolution, vertical direction structural features are extracted through vertical strip convolution, and isotropic structural features are extracted through omnidirectional two-dimensional convolution; after the feature maps output by the three direction convolution paths are spliced, feature fusion is performed through convolution.
[0012] In an embodiment of the present application, in step S10, the method for performing multi-scale feature extraction on the collected crack image to obtain a feature representation containing local details and global context information includes the following steps: S11: Initial feature mapping is performed on the collected crack image to obtain a primary feature map containing basic structure and texture information; S12: Stack residual dilation convolution processing is performed on the primary feature map to obtain deep semantic features with a multi-scale receptive field through a plurality of dilation convolution layers with different dilation rates; S13: Global self-attention calculation is performed on the deep semantic features to obtain a feature representation containing local details and global context information.
[0013] In an embodiment of the present application, in step S13, the method for performing global self-attention calculation on the deep semantic features to obtain a feature representation containing local details and global context information is as follows: the correlation weights between each spatial position in the deep semantic features are calculated through a self-attention mechanism to establish a long-range topological dependency relationship between crack pixels; The deep semantic features are weighted and fused according to the correlation weights to generate enhanced features containing global context information; The enhanced features are fused with the original deep semantic features to obtain a feature representation containing both local details and global context information.
[0014] In an embodiment of the present application, in step S40, the method for optimizing the high-resolution segmentation result is as follows: a hybrid loss function is used to optimize the segmentation result, the hybrid loss function is a weighted combination of Dice loss and Focal loss, and its expression is as follows: , wherein, is a hybrid loss function value, is a Dice loss value, is a focal loss value, and respectively are preset weight coefficients of the Dice loss and the focal loss, and satisfy .
[0015] The application further provides a crack image segmentation system, comprising the following modules: a feature extraction module, configured to perform multi-scale feature extraction on the collected crack image to obtain a feature representation containing local details and global context information; a topological enhancement module, configured to perform topological perception enhancement on the feature representation to obtain a direction-enhanced feature map; a structure reconstruction module, configured to perform topological perception structure reconstruction and up-sampling on the direction-enhanced feature map to obtain a high-resolution segmentation result; an optimization module, configured to optimize the high-resolution segmentation result by using a hybrid loss function to obtain an optimized segmentation result.
[0016] The application further provides an electronic device, comprising a processor, a memory and a bus system, the processor and the memory being connected through the bus system, the memory being configured to store instructions, and the processor being configured to execute the instructions stored in the memory to implement the crack image segmentation method.
[0017] The above technical solution of the application has the following advantages compared with the prior art: The application effectively establishes a long-range topological dependency relationship between crack pixels by combining multi-scale feature extraction with a global self-attention mechanism, thereby overcoming the context loss problem caused by the limited receptive field of traditional CNNs; the multi-branch direction convolution enhances the ability to capture the anisotropic features of cracks; the topologically perceived structure reconstruction realizes direction-sensitive up-sampling, which significantly improves the recovery effect of crack edge details; finally, the hybrid loss function optimization improves the recognition ability of the model for sparse crack pixels while maintaining the structural integrity. The scheme has stronger robustness and higher segmentation accuracy in complex scenes, and effectively solves the problems of structure rupture, edge blur and detail loss existing in traditional methods. BRIEF DESCRIPTION OF DRAWINGS
[0018] In order to make the content of the application more easily understood, the application will be further described in detail below according to specific embodiments of the application and in conjunction with the drawings, in which: Figure 1 is a flowchart of the crack image segmentation method provided in the embodiments of the application; Figure 2 is a stacked residual dilated convolution feature visualization comparison chart in the embodiments of the application; Figure 3 This is a visualization comparison of topology-aware orientation-enhanced convolutional feature maps in an embodiment of the present invention; Figure 4 This is a comparison of the visualization features of topology-aware structure reconstruction in an embodiment of the present invention; Figure 5 This is a visual comparison of the segmentation results of different models on the CRACK500 dataset in the experiment; Figure 6 This is a performance comparison chart of different loss functions on the CRACK500 dataset in the experiment; Figure 7 This is a comparison chart of the performance of the Dice-Focal loss function with different proportions on the CRACK500 dataset in the experiment; Figure 8 This is a schematic diagram of the crack image segmentation system provided in the embodiment. Detailed Implementation
[0019] The present invention will be further described below with reference to the accompanying drawings and specific embodiments, so that those skilled in the art can better understand and implement the present invention. However, the embodiments described are not intended to limit the present invention.
[0020] Example 1: like Figure 1 As shown, the present invention provides a crack image segmentation method, characterized by comprising the following steps: S10: Perform multi-scale feature extraction on the acquired crack images to obtain feature representations that include local details and global context information; S20: Perform topology-aware enhancement on the feature representation to obtain a directionally enhanced feature map; S30: Perform topology-aware structure reconstruction and upsampling on the enhanced orientation feature map to obtain a high-resolution segmentation result; S40: Optimize the high-resolution segmentation result to obtain the optimized segmentation result.
[0021] This invention effectively fuses local details and global contextual information of crack images through multi-scale feature extraction, overcoming the context loss problem caused by the limited receptive field of traditional methods. Topological sensing enhancement strengthens the ability to capture anisotropic features of cracks, improving directional sensitivity. Further topological sensing structure reconstruction and upsampling significantly improve the restoration of crack edge details, reducing structural breakage and blurring. Optimization steps further improve the accuracy and robustness of the segmentation results. This method can extract crack contours more completely and precisely in complex scenes, providing a reliable foundation for subsequent quantitative analysis.
[0022] Specifically, in step S10, the method of performing multi-scale feature extraction on the collected crack image to obtain a feature representation containing local details and global context information includes the following steps: S11: performing initial feature mapping on the collected crack image to obtain a primary feature map containing basic structure and texture information; S12: performing stack residual dilation convolution processing on the primary feature map to obtain deep semantic features with multi-scale receptive fields through multiple dilation convolution layers with different dilation rates; S13: performing global self-attention calculation on the deep semantic features to obtain a feature representation containing local details and global context information.
[0023] In step S13, the method of performing global self-attention calculation on the deep semantic features to obtain a feature representation containing local details and global context information is as follows: the correlation weights between each spatial position in the deep semantic features are calculated through a self-attention mechanism to establish a long-range topological dependency relationship between crack pixels; the deep semantic features are weighted and fused according to the correlation weights to generate enhanced features containing global context information; and the enhanced features are fused with the original deep semantic features to obtain a feature representation containing both local details and global context information.
[0024] The multi-scale feature extraction of step S10 is the basis and key of the entire crack image segmentation method, and its purpose is to construct a feature representation that can capture both the fine texture of the crack and understand its global distribution law.
[0025] Specifically, initial feature mapping is performed on the input crack image, which is usually completed by one or more basic convolution modules (such as the combination of Conv-BN-ReLU), which serves to perform shallow feature extraction. These initial convolution layers use a small receptive field (such as a 3x3 convolution kernel) and focus on capturing edge, corner and basic texture patterns at the pixel level.
[0026] The mathematical expression can be regarded as a nonlinear mapping function : Let the input image be , then the primary feature map can be represented as . contains the basic structure and texture information of the crack, providing a high spatial resolution detail base for subsequent depth processing, maximizing the preservation of the original geometric details of the crack and preventing the loss of fine crack information due to early downsampling in subsequent processing.
[0027] Optionally, in this embodiment, the primary feature map Deep processing is performed. The core of the extractor is a stacked residual dilation convolution process. Instead of simply stacking standard convolutions, a series of dilation convolution layers with increasing dilation rates d are adopted and constructed in a residual connection manner. For example, in one instance, a module can include three sub-stages using 3x3 dilation convolutions with dilation rates d=1, d=2, d=4. For a dilation convolution with a kernel size of and a dilation rate of , the equivalent receptive field calculation formula is . Therefore, the equivalent receptive field of a 3x3 convolution is expanded to 3x3, 5x5, and 9x9 when d=1, 2, and 4, respectively. Through this stacking method, the network can exponentially increase the receptive field while keeping the spatial size of the feature map unchanged (usually maintained at 1 / 4 of the input by setting the stride to 1).
[0028] The combination of convolution layers with different dilation rates and residual connections brings multiple significant benefits. Convolution layers with different dilation rates are like a series of observation lenses with different focal lengths, where the layer with a dilation rate d=1 focuses on capturing fine features of the local neighborhood, the layer with d=2 is responsible for capturing medium-range contextual information, and the layer with d=4 can integrate semantic information from a wider area of the image. This multi-scale perception mechanism enables the model to effectively represent cracks with different widths, whether they are fine cracks like hair or relatively wide cracks.
[0029] Since the dilation convolution significantly expands the receptive field without adding additional model parameters or reducing the spatial resolution of the feature map, it can aggregate context information from a wider image area to accurately determine the class attributes of the current pixel. This is particularly important for cracks, which are sparse and elongated foreground pixels. A larger receptive field helps the model use the continuity and consistency of the surrounding pavement texture to suppress isolated background noise interference and effectively connect the discrete pixel responses along the crack direction, thereby forming a more semantically coherent feature representation, as shown in Figure 2 Compared with traditional convolution methods, the generated feature map in this embodiment contains significantly reduced background noise and more complete and coherent responses in wide crack areas.
[0030] The residual connection mechanism introduced in the network, which adds the output of the previous layer to the output of the current dilation convolution layer, effectively alleviates the inherent gradient vanishing problem in deep neural networks. This not only makes it possible to build and train deeper feature extraction networks, but also ensures that error gradients can be stably and effectively backpropagated through multiple layers.
[0031] Further, the above-mentioned processing results in deep semantic features rich in multi-scale information Global self-attention computation is performed. Although the stacked dilated convolution has captured the information within the expanded receptive field, it is still essentially a superposition of local operations, and the modeling of the topological dependency relationship of the extremely long-range crack spanning hundreds of pixels may still be insufficient. The self-attention mechanism (Self-Attention) is introduced here to make up for this gap. The calculation process is as follows: the feature map is respectively generated by linear transformation to generate query (Query, ), key (Key, ) and value (Value, ) matrices. By calculating the dot product of and , and applying the Softmax function, the correlation weight matrix between spatial positions is obtained: , where is the dimension of , used for scaling. Subsequently, the weighted sum of is performed using the weight matrix to generate the global context-enhanced feature .
[0032] The introduction of this self-attention mechanism produces significant beneficial effects. Its core advantage lies in its ability to directly establish long-range topological dependency relationships between any two crack pixels, regardless of how far apart they are in image space. The mechanism can capture this long-range interaction by calculating its correlation strength, which is crucial for reconnecting the interrupted crack fragments due to environmental noise or partial occlusion, and for deeply understanding the overall meandering direction of the crack and its macro-topological structure. At the same time, the mechanism achieves dynamic feature enhancement, allowing the model to adaptively strengthen the feature expression of other crack pixels with high semantic relevance to the current position and simultaneously weaken the interference from irrelevant background areas, thereby completing a more intelligent and precise context information fusion process.
[0033] The enhanced feature output by the self-attention is fused with the original deep semantic feature (e.g., by element-wise addition or channel concatenation followed by a 1x1 convolution), resulting in a feature representation that contains both local details and global context information. The fusion operation ensures that the valuable local details and structural information extracted by the convolutional layers are not lost while introducing strong global context capabilities.
[0034] Further, in step S20, the feature representation is topologically enhanced to obtain a direction-enhanced feature map, including the following steps: S21: performing multi-branch convolution processing on the feature representation to extract topological features of the crack through multiple convolution paths with different direction selectivity and multi-scale receptive field; S22: concatenating multiple feature maps obtained by multi-branch convolution processing along the channel dimension to obtain a multi-directional feature combination; S23: performing convolution fusion on the multi-directional feature combination to adaptively integrate topological information in different directions to obtain the direction-enhanced feature map.
[0035] Optionally, the topological enhancement process performed in step S20 is implemented by a topological shallow feature compensator (TSFC), which is specifically used to solve the key problems of crack anisotropic feature extraction and shallow noise filtering. As a slender and directionally variable topological structure, the traditional 3x3 square convolution kernel is insufficient in enhancing the continuity of a specific direction due to its isotropic property, and the single-scale dilated convolution lacks clear direction selectivity. Therefore, the TSFC module innovatively introduces a four-branch hybrid convolution operator to accurately model the omnidirectional topological connectivity of the crack through the cooperative work of multiple paths.
[0036] This four-branch structure includes two direction-specific convolution paths and two multi-scale context paths: the first path uses a 1x3 horizontal stripe convolution, whose learnable weights are constrained in the horizontal dimension, forming a zero-order filter along the horizontal direction and a one-dimensional band-pass filter along the vertical direction, which is specifically used to enhance the continuity of the horizontal trace of the crack and effectively suppress the off-axis fluctuations in the vertical direction; the second path uses a 3x1 vertical stripe convolution, whose weights are constrained in the vertical dimension, which can significantly enhance the vertical continuity features of the crack and reduce background activation response; the third path uses a 3x3 isotropic dilated convolution with a dilation rate of d, which introduces short-range isotropic context information by appropriate dilation rate setting (such as d=2), effectively filling small gaps in the crack and refining local edge contours; the fourth path uses a 3x3 isotropic dilated convolution with a dilation rate of 2d, which provides a larger pixel sampling span through the doubled dilation rate, and is specifically used to capture and compensate for the long-range, diagonal crack discontinuity that may be lost in the input features. These four branches construct a complete crack topological feature extraction system from four dimensions of horizontal, vertical, short-range isotropic, and long-range isotropic.
[0037] In the feature fusion stage, the output feature maps of the four branches are spliced along the channel dimension to form a multi-directional feature combination containing multi-directional and multi-scale information. Subsequently, an adaptive fusion is performed on the feature combination through a 1x1 convolutional layer. The fusion layer dynamically evaluates the contribution of each branch feature through learnable weight parameters, intelligently weights and integrates different directional topological information, and finally generates a directional enhancement feature map with significantly improved quality.
[0038] Through the synergistic work of direction-specific convolution and multi-scale context convolution, the modeling capability for the anisotropic features of cracks is greatly enhanced, so that the continuity of horizontal, vertical and diagonal cracks is effectively maintained. The inherent direction selectivity of stripe convolution enables it to reconnect long diagonal cracks that are interrupted due to noise degradation or occlusion without introducing additional parameters, significantly improving the structural repair capability of the model. Furthermore, the introduction of multi-scale dilation convolution ensures full-range feature coverage from local details to long-range dependencies, preserving the fine edge information of cracks and making up for the lack of long-distance connectivity.
[0039] As shown in Figure 3 After the above processing, the crack structure in the feature map presents a clearer and more continuous form, the response area along the crack body is wider and more coherent, and the response of background noise and non-crack areas is significantly suppressed. This fully verifies the excellent performance of the module in enhancing the directional features of cracks, maintaining global topological connectivity and suppressing complex background noise, providing vital enhanced feature representation for high-quality structure reconstruction of the subsequent decoder.
[0040] Further, in step S30, the method for topologically aware structure reconstruction and upsampling of the directional enhancement feature map to obtain a high-resolution segmentation result comprises the following steps: S31: performing multi-directional convolution processing on the directional enhancement feature map to extract multi-directional structural features of the cracks through multiple convolution paths with different direction selectivity; S32: splicing the feature maps obtained through the multiple path convolution processing along the channel dimension to form multi-directional structural features; S33: performing convolution fusion on the spliced multi-directional structural features to realize adaptive weighting and integration of directional features; S34: upsampling the fused feature map to restore the spatial resolution through pixel rearrangement to obtain the high-resolution segmentation result.
[0041] Specifically, in step S30, the feature map rich in directional information obtained after topology-aware enhancement is subjected to topology-aware structure reconstruction and upsampling to generate high-resolution segmentation results. This process is driven by the core of the Topology-Aware Structure Reconstruction Module (TSRM), which innovatively adopts a "strip shuffle" process to specifically address the edge blurring and structural breakage problems that easily occur in conventional upsampling processes when cracks are long, thin, and highly directional strip structures. The innovation of TSRM lies in deconstructing a single 2x upsampling operation into three convolutional branches that process in parallel at the base resolution, achieving refined reconstruction of the crack topology.
[0042] This process fully describes the technical solution of the TSRM module, which first performs directional strip convolution to enhance the structure and then performs pixel rearrangement upsampling, specifically including two key stages.
[0043] The first innovation of TSRM is that it deconstructs a single 2x upsampling operation into three convolutional branches that are processed in parallel at the base resolution, thereby achieving a refined reconstruction of the crack topology.
[0044] These three parallel paths employ convolutional kernels of different shapes to capture structural features in specific directions: The first path is a horizontal strip convolution using a (1, k) kernel, where learnable weights are constrained to the horizontal dimension. This operation is equivalent to performing a one-dimensional bandpass filter along the vertical direction, which can significantly enhance the continuity of horizontal crack traces, effectively connect horizontally oriented crack segments interrupted by noise or occlusion, and simultaneously suppress off-axis fluctuations and stripe noise in the vertical direction; The second path is a vertical strip convolution using a (k, 1) kernel, constraining the weights to the vertical dimension. This path is specifically designed to enhance the vertical continuity of cracks, effectively bridging longitudinally fractured crack segments and significantly reducing the activation response of background regions unrelated to this direction; The third path is an omnidirectional two-dimensional convolution using a traditional (k, k) square kernel. This path does not preset directional preferences and is responsible for providing isotropic local contextual semantic compensation, filling small gaps that may be ignored by directional convolution, smoothing local edge contours, and making the texture details of cracks fuller, ensuring the integrity of the reconstructed features.
[0045] The three feature maps output by the three-path convolution processing are then concatenated along the channel dimension to form a multi-directional structural feature combination that integrates horizontal, vertical and isotropic information. This combination is then adaptively fused through a learnable 1×1 convolutional layer.
[0046] The fusion layer dynamically learns the contribution weight of each direction feature during the training process, realizes the intelligent weighting and integration of the topology information of different directions, and the mathematical essence can be regarded as a weighted summation process on a feature channel: if the three-way output features are denoted as , , , the spliced features are , and the fused features are , wherein is the weight parameter of the 1x1 convolution.
[0047] Second, pixel rearrangement up-sampling (Pixel Shuffle), the fused feature map , the TSRM module uses the pixel rearrangement operation for up-sampling to restore the spatial resolution. The operation rearranges the pre-organized sub-pixels in the channel dimension to a larger spatial grid, and the mathematical expression is to transform the feature tensor with a size of into a high-resolution feature map with a size of . Compared with the traditional transposed convolution or interpolation method, pixel rearrangement is a parameter-free reconstruction method that can effectively avoid the introduction of checkerboard artifacts, thereby ensuring the quality of the reconstructed image.
[0048] As shown in Figure 4 , the visualization process of multi-directional feature reconstruction and pixel up-sampling in the TSRM module. After processing by the three direction-sensitive convolution branches, the feature map presents different directional response characteristics: the horizontal strip convolution strengthens the continuity of the crack in the horizontal direction; the vertical strip convolution enhances the structural features in the vertical direction; and the omnidirectional two-dimensional convolution provides isotropic context compensation. After fusion and pixel rearrangement up-sampling, the reconstructed feature map shows more coherent crack structure and clear edge details, effectively improving the blurring and breaking problems caused by traditional up-sampling methods.
[0049] Further, in step S40, the high-resolution segmentation result obtained through the topology-aware structure reconstruction and up-sampling is optimized to obtain the final optimized segmentation result. The core of the optimization process is to supervise the model prediction by using a hybrid loss function composed of Dice loss and Focal loss with preset weight coefficients, and the mathematical expression is: , wherein, represents the hybrid loss function value, is the Dice loss value, is the Focal loss value, and are the weight coefficients of the preset Dice loss and Focal loss, respectively, and satisfy the constraint condition .
[0050] Specifically, the Dice loss is constructed based on the Dice coefficient, which measures the overlap between the predicted segmentation region and the real labeled region, and its loss calculation formula is where represents the pixel set of the real crack region, represents the pixel set of the crack region predicted by the model, represents the number of correctly identified crack pixels in the intersection of the two, and respectively represent the total number of pixels of the real crack region and the predicted crack region.
[0051] The Dice loss has natural robustness to the problem of serious imbalance between foreground (crack) and background pixels commonly seen in image segmentation tasks, because it pays more attention to the proportion of overlapping regions rather than the absolute pixel count, thus helping the model to learn to generate more complete crack predictions in structure, effectively reducing the phenomenon of broken.
[0052] The Focal loss is an improvement based on the standard cross-entropy loss, which is specifically used to solve the class imbalance problem and to strengthen the attention to difficult-to-classify samples (usually sparse crack pixels). Its definition for a single pixel is represents the Sigmoid probability of the model predicting that the pixel belongs to the crack class, is its true label (1 represents crack and 0 represents background), and the expression of the Focal loss is: , where is a factor for balancing the weights of positive and negative samples, is a focusing parameter.
[0053] By introducing the modulation factor or , the Focal loss can dynamically reduce the contribution of easy-to-classify samples to the total loss, thereby focusing more on those difficult-to-classify sparse crack pixels or pixels with ambiguous boundaries, significantly improving the model's recall ability for subtle cracks and low-contrast regions.
[0054] The Dice loss and the Focal loss are combined by weighting to form a hybrid loss function, and the fundamental purpose is to comprehensively utilize the complementary advantages of the two loss functions: the Dice loss focuses on ensuring the overall consistency of the predicted crack area and the real area in shape and structure from a macroscopic perspective, which plays an important role in maintaining the connectivity and structural integrity of the cracks; and the Focal loss starts from the microscopic pixel level, effectively improves the sensitivity and recognition ability of the model to the sparsely distributed crack pixels by focusing on difficult samples, which is especially helpful to reduce the missed detection. This combination strategy enables the model to obtain good structure fitting characteristics through the Dice loss constraint during the optimization process, and also enhances the mining ability of the foreground pixels with the help of the Focal loss, so as to achieve a better balance between precision and recall.
[0055] In the application of crack segmentation in complex road conditions and various backgrounds, the method significantly alleviates the defects such as structural discontinuity, unclear boundary and loss of detailed features that often occur in previous technologies, and can realize more accurate and stable pixel-level crack recognition effect, laying a more accurate and reliable input foundation for subsequent crack quantitative statistics and structural safety evaluation.
[0056] Experiment: To verify the effectiveness of the crack image segmentation method proposed in the present application, the present application conducts systematic experimental evaluation, including parameter setting, data set introduction and performance comparison analysis on public data sets.
[0057] The experiment adopts a training process based on the PyTorch framework, uses the AdamW optimizer to optimize the model, and sets the initial learning rate to , the momentum parameter is (0.9, 0.999), and the default weight decay coefficient is used to suppress overfitting. The training process lasts for 200 cycles, and the batch size is set to 4. To stabilize the gradient dynamics in the early training stage, a cosine annealing learning rate scheduler is used and a 2-cycle warm-up phase is set. The loss function adopts the weighted combination of Dice loss and Focal loss, and the weight coefficient is adjusted according to the characteristics of the data set, aiming to solve the problems of sparse crack pixels and blurred boundaries. After each training cycle, the mIoU, precision, recall and F1 score are used to evaluate on the validation set, and the model weight with the best performance is saved. All experiments are completed on a single block of GeForce RTX 4060Ti GPU.
[0058] The experiment adopts the CRACK500 dataset for model training and verification. The dataset is collected by Temple University and contains 500 high-resolution pavement images (resolution: 2000 × 1500 pixels), covering four types of cracks: alligator cracks, longitudinal cracks, transverse cracks, and multi-branch cracks, and retaining complex factors such as light changes, shadows, and occlusions in actual scenes. After cropping, only the area containing the cracks (640 × 360 pixels) is retained, resulting in a total of 3368 images. The dataset is divided into a training set (2020 images), a validation set (673 images), and a test set (675 images) in a ratio of about 6:2:2. The CRACK500 dataset contains a variety of morphologies such as wide cracks, narrow cracks, and low-contrast cracks, and some images have significant background noise and texture interference, which poses a high demand on the segmentation ability of the model.
[0059] To comprehensively evaluate the performance of the method, it is compared with mainstream segmentation models such as U-Net, DeepLabV3+, ResUNet++, SwinUNet, and SegFormer on the CRACK500 test set. The quantitative results are shown in Table 1, and the method achieves the best results in mIoU, recall rate, and F1 score, with values of 0.787, 0.824, and 0.738, respectively.
[0060] Table 1:
[0061] Although the precision is slightly lower than that of U-Net, the significant improvement in recall rate makes the overall performance better than all baseline models, achieving a good balance between integrity and accuracy.
[0062] The visual segmentation results are shown in Figure 5 It can be seen that U-Net performs well in detecting wide cracks, but misses narrow cracks and low-contrast areas; DeepLabV3+ is sensitive to background noise and prone to false predictions; ResUNet++ can maintain crack continuity, but slightly over-extends at the boundary; SwinUNet performs moderately in structural integrity, but fails to effectively connect some broken areas; SegFormer performs well in connectivity and detail representation, but lacks smoothness in crack boundaries. In contrast, the method can output clear and complete segmentation results for different crack morphologies and effectively suppress background interference.
[0063] In addition, for the selection of the weight ratio in the hybrid loss function, different ratios are compared.
[0064] BCE (Binary Cross-Entropy) is used as one of the baseline comparison items. It is a traditional segmentation loss function, but when dealing with tasks such as cracks, which are extremely sparse in foreground pixels, it is easy to cause the model to be dominated by the background and learn insufficiently about crack pixels, thereby limiting performance. In contrast, the hybrid loss function of the present application combines the complementary advantages of Dice loss focusing on the overall structural integrity and Focal loss focusing on difficult example samples.
[0065] As shown in Figure 6 and Figure 7 , with the increase of the weight of Focal loss, the precision gradually decreases and the recall increases. The experimental results show that when the weight ratio of Dice loss and Focal loss is 0.4:0.6, the model reaches the optimal mIoU and F1 score (0.787 and 0.738, respectively), taking into account the structural integrity and the ability to identify sparse crack pixels, verifying the superiority of the weight configuration in the wide crack segmentation task.
[0066] Embodiment Two Based on the same inventive concept as Embodiment One, the present application also provides a crack image segmentation system for implementing the steps of the crack image segmentation method described in Embodiment One. As shown in Figure 8 , the crack image segmentation system includes the following modules: a feature extraction module for performing multi-scale feature extraction on the collected crack image to obtain a feature representation containing local details and global context information; a topology enhancement module for performing topology-aware enhancement on the feature representation to obtain a direction-enhanced feature map; a structure reconstruction module for performing topology-aware structure reconstruction and up-sampling on the direction-enhanced feature map to obtain a high-resolution segmentation result; an optimization module for optimizing the high-resolution segmentation result using a hybrid loss function to obtain an optimized segmentation result.
[0067] Embodiment Three The present application also provides an electronic device, which includes a processor, a memory, and a bus system, the processor and the memory being connected through the bus system, the memory being used to store instructions, and the processor being used to execute the instructions stored in the memory to implement the crack image segmentation method described in Embodiment One.
[0068] Those skilled in the art will appreciate that embodiments of the application can be devised for a method, a system, or a computer program product. Accordingly, the present application can be embodied in the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present application can take the form of a computer program product on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROMs, optical storage devices, etc.) embodying computer readable program code.
[0069] The present application is described in reference to the flowchart and / or block diagrams of the method, apparatus (system) and computer program product according to embodiments of the application. It will be understood that each block of the flowchart and / or block diagrams, and combinations of blocks in the flowchart and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can 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 and / or block diagram block or blocks. Figure 1 one or more functions specified in the flowchart and / or block diagram block or blocks. Figure 1 one or more functions specified in the flowchart and / or block diagram block or blocks.
[0070] These computer program instructions can 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 instructions which implement the function specified in the flowchart and / or block diagram block or blocks. Figure 1 one or more functions specified in the flowchart and / or block diagram block or blocks. Figure 1 one or more functions specified in the flowchart and / or block diagram block or blocks.
[0071] These computer program instructions can 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 and / or block diagram block or blocks. Figure 1 one or more functions specified in the flowchart and / or block diagram block or blocks. Figure 1 one or more functions specified in the flowchart and / or block diagram block or blocks.
[0072] Obviously, the above-described embodiments are only examples and are not intended to limit the present application. Based on the above description, those skilled in the art can make other variations and modifications of the present application without deviating from the scope of the present application. Therefore, the present application should not be limited by the above embodiments.
Claims
1. A crack image segmentation method, characterized in that, Includes the following steps: S10: Perform multi-scale feature extraction on the acquired crack images to obtain feature representations that include local details and global context information; S20: Perform topology-aware enhancement on the feature representation to obtain a directionally enhanced feature map; S30: Perform topology-aware structure reconstruction and upsampling on the enhanced orientation feature map to obtain a high-resolution segmentation result; S40: Optimize the high-resolution segmentation result to obtain the optimized segmentation result.
2. The crack image segmentation method according to claim 1, characterized in that: Step S20, the method for performing topology-aware enhancement on the feature representation to obtain a direction-enhanced feature map, includes the following steps: S21: Perform multi-branch convolution processing on the feature representation, and extract the topological features of the crack through multiple convolution paths with different directional selectivity and multi-scale receptive fields; S22: Concatenate multiple feature maps obtained from multi-branch convolution along the channel dimension to obtain a multi-directional feature combination; S23: Perform convolutional fusion on the multi-directional feature combination to adaptively integrate the topological information of different directions and obtain the feature map with enhanced direction.
3. The crack image segmentation method according to claim 2, characterized in that: In step S21, the multi-branch convolution processing includes four-branch convolution processing. The specific method is as follows: extract horizontal features through horizontal stripe convolution, extract vertical features through vertical stripe convolution, extract first-scale context features through first dilated convolution, and extract second-scale context features through second dilated convolution; after concatenating the feature maps output by the four branches, feature fusion is performed through convolution.
4. The crack image segmentation method according to claim 1, characterized in that: In step S30, the method for performing topology-aware structure reconstruction and upsampling on the orientation enhancement feature map to obtain a high-resolution segmentation result includes the following steps: S31: Perform multi-directional convolution processing on the directional enhancement feature map, and extract multi-directional structural features of the crack through multiple convolution paths with different directional selectivity; S32: The feature maps obtained by convolutional processing of multiple paths are spliced along the channel dimension to form multi-directional structural features; S33: Perform convolutional fusion on the spliced multi-directional structural features to achieve adaptive weighted integration of directional features; S34: Upsample the fused feature map and restore the spatial resolution by pixel rearrangement to obtain the high-resolution segmentation result.
5. The crack image segmentation method according to claim 4, characterized in that: In step S31, the method for performing multi-directional convolution processing on the directional enhancement feature map is as follows: extracting horizontal structural features through horizontal strip convolution, extracting vertical structural features through vertical strip convolution, and extracting isotropic structural features through omnidirectional two-dimensional convolution; after concatenating the feature maps output by the three directional convolution paths, feature fusion is performed through convolution.
6. The crack image segmentation method according to claim 1, characterized in that: In step S10, the method for extracting multi-scale features from the acquired crack image to obtain a feature representation containing local details and global context information includes the following steps: S11: Perform initial feature mapping on the acquired crack images to obtain a primary feature map containing basic structural and texture information; S12: Perform stacked residual dilated convolution processing on the primary feature map, and obtain deep semantic features with multi-scale receptive fields through multiple dilated convolutional layers with different dilation rates. S13: Perform global self-attention calculation on the deep semantic features to obtain a feature representation that includes local details and global context information.
7. The crack image segmentation method according to claim 6, characterized in that: In step S13, the method for performing global self-attention calculation on the deep semantic features to obtain feature representations containing local details and global context information is as follows: calculate the association weights between each spatial location in the deep semantic features through a self-attention mechanism, and establish long-range topological dependencies between crack pixels. The deep semantic features are weighted and fused according to the association weights to generate enhanced features containing global context information; The enhanced features are fused with the original deep semantic features to obtain a feature representation that simultaneously contains local details and global contextual information.
8. The crack image segmentation method according to claim 1, characterized in that: In step S40, the method for optimizing the high-resolution segmentation result is as follows: A hybrid loss function is used to optimize the segmentation result. The hybrid loss function is a weighted combination of Dice loss and Focal loss, and its expression is: , in, For the mixed loss function value, This represents the Dice loss value. Focal loss value and These are the preset weight coefficients for Dice loss and Focal loss, respectively, and satisfy the following conditions: .
9. A crack image segmentation system, characterized in that, Includes the following modules: The feature extraction module is used to extract features at multiple scales from the acquired crack images to obtain feature representations that include local details and global context information. The topology enhancement module is used to perform topology-aware enhancement on the feature representation to obtain a directionally enhanced feature map; The structure reconstruction module is used to perform topology-aware structure reconstruction and upsampling on the orientation enhancement feature map to obtain high-resolution segmentation results; The optimization module is used to optimize the high-resolution segmentation result using a hybrid loss function to obtain the optimized segmentation result.
10. An electronic device, characterized in that, The electronic device includes a processor, a memory, and a bus system, wherein the processor and the memory are connected via the bus system, the memory is used to store instructions, and the processor is used to execute the instructions stored in the memory to implement the crack image segmentation method according to any one of claims 1 to 8.