A Deep Learning-Based Automatic Tunnel Crack Identification Method

By employing multi-scale deep neural networks and graph structure analysis methods, the robustness and accuracy issues in tunnel crack identification were resolved, achieving high-precision automatic identification and structured analysis of tunnel cracks, thus improving the completeness and accuracy of the identification.

CN121259586BActive Publication Date: 2026-04-03CHINA RAILWAY CONSULTING GRP BEIJING ENG INSPECTION CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-10-20
Publication Date
2026-04-03

AI Technical Summary

Technical Problem

Existing technologies for tunnel crack identification suffer from insufficient robustness to complex textured backgrounds, non-uniform lighting, and blurred edges. They are also difficult to extract fine crack features, have low identification accuracy, lack quantitative assessment capabilities for crack geometric properties, and have insufficient connectivity modeling, which affects the judgment of structural integrity.

Method used

A multi-scale deep neural network and graph structure analysis method are adopted, combined with Retinex enhancement and discrete wavelet transform. A frequency-aware channel enhancement module and an adaptive scale alignment mechanism are introduced. Redundant information is compressed through a low-rank attention transformation module. An iterative refinement algorithm based on the eight-neighborhood rule is used to extract the main structure of the crack and repair discontinuous segments to construct a crack connectivity graph.

Benefits of technology

It achieves high-precision automatic identification and structured analysis of tunnel cracks, improves the completeness and accuracy of identification in complex backgrounds, and can effectively extract the geometric attributes of cracks to meet the needs of structural defect diagnosis.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121259586B_ABST
    Figure CN121259586B_ABST
Patent Text Reader

Abstract

This invention discloses an automatic tunnel crack identification method based on deep learning, comprising the following steps: Step 1: Acquiring image data; Step 2: Preprocessing the image data; Step 3: Inputting the spatial-frequency fusion feature image data into a feature extraction network with HRNet-W48 as the backbone, outputting a feature representation tensor; Step 4: Inputting the feature representation tensor into a SegFormer network, including an encoder and a multi-scale fusion decoder, and introducing a low-rank attention transformation module, outputting a crack mask image; Step 5: Constructing a crack connectivity graph structure, and repairing discontinuous cracks through graph connectivity analysis, outputting the repaired crack connectivity graph structure; Step 6: Visualizing the crack mask image and geometric attributes. This invention integrates multi-scale deep learning, the SegFormer network, and graph structure analysis to achieve automatic tunnel crack identification.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image recognition technology, and in particular to an automatic identification method for tunnel cracks based on deep learning. Background Technology

[0002] With the rapid development of urban infrastructure and the large-scale construction of tunnel projects in mountainous areas, the demand for tunnel structural health monitoring continues to rise, and image recognition and automatic detection technologies for tunnel lining cracks have received widespread attention. Currently, most common tunnel crack identification methods are based on manual inspection or traditional image processing algorithms, but these methods generally suffer from the following problems in practical applications:

[0003] Traditional image enhancement and segmentation algorithms lack robustness to interference from complex textured backgrounds, non-uniform lighting, and blurred edges, making it difficult to effectively extract crack region features and prone to missed or false detections. Existing deep learning networks mostly employ single-scale feature extraction structures, lacking the ability to preserve the structure of tiny cracks in high-resolution images, resulting in weak response and low recognition accuracy for small cracks. Furthermore, the identified crack images often remain at the pixel-level semantic segmentation stage, failing to further reconstruct and analyze the crack structure, which is insufficient to meet the quantitative assessment requirements of crack geometric attributes for structural disease diagnosis. In addition, cracks have complex morphologies and variable orientations, and existing methods have significant shortcomings in crack connectivity modeling and repairing discontinuous cracks, affecting the assessment of structural integrity and maintenance decisions.

[0004] Therefore, how to provide a method for automatic identification of tunnel cracks based on deep learning is a problem that urgently needs to be solved by those skilled in the art. Summary of the Invention

[0005] One objective of this invention is to propose an automatic tunnel crack identification method based on deep learning. This invention integrates multi-scale deep neural networks and graph structure analysis methods to address the problems of blurred crack edges, discontinuous morphology, and complex connectivity in tunnel crack image recognition. It effectively improves the representation of details and frequency features through Retinex enhancement and discrete wavelet transform; introduces a frequency-aware channel enhancement module and an adaptive scale alignment mechanism to achieve collaborative modeling of multi-scale contextual information; constructs a low-rank attention transform module to compress redundant channel information and improve attention computation efficiency; and utilizes an iterative refinement algorithm based on the eight-neighborhood rule and graph connectivity analysis to extract the main crack structure and repair discontinuous segments, significantly enhancing crack connectivity representation and achieving high-precision automatic identification and structured analysis of tunnel cracks.

[0006] An automatic tunnel crack identification method based on deep learning according to an embodiment of the present invention includes the following steps:

[0007] Step 1: Acquire image data of the tunnel surface;

[0008] Step 2: Preprocess the image data, including image grayscale normalization, Retinex enhancement, edge-preserving filtering, and discrete wavelet transform, to obtain spatial-frequency fusion feature image data;

[0009] Step 3: Input the spatial-frequency fusion feature image data into the feature extraction network with HRNet-W48 as the backbone, add a frequency-aware channel enhancement module to each branch, and introduce an adaptive scale alignment module when connecting across branches to output a feature representation tensor;

[0010] Step 4: Input the feature representation tensor into the SegFormer network. The SegFormer network includes an encoder based on the Transformer structure and a multi-scale fusion decoder. A low-rank attention transformation module is introduced at the front end of the multi-scale fusion decoder to output a crack mask map.

[0011] Step 5: Perform crack structure reconstruction processing on the crack mask map, use an iterative thinning algorithm based on the eight-neighbor rule to extract the main crack lines, construct the crack connectivity graph structure, and repair discontinuous cracks through graph connectivity analysis, and output the repaired crack connectivity graph structure.

[0012] Step 6: Extract the geometric attributes of the repaired crack connectivity graph structure, and visualize the crack mask map and geometric attributes.

[0013] Optionally, the image data specifically includes visible light images, multispectral images, and infrared images, with an image resolution of not less than 2048×1024 pixels.

[0014] Optionally, step two specifically includes:

[0015] By reading the red, green, and blue channel values ​​of each pixel in the image data, and adding the three channel values ​​according to a set weighting ratio, a single-channel grayscale image is generated.

[0016] The grayscale image is subjected to grayscale normalization processing, and the grayscale values ​​of all pixels in the grayscale image are scaled to a continuous range between 0 and 1 through linear mapping;

[0017] The normalized grayscale image is enhanced with Retinex. The normalized grayscale image is then copied into three copies and blurred to different degrees. The blurring operation uses a sliding window of a set size to perform convolution smoothing on the entire image.

[0018] For each blurred image, a logarithmic difference is performed pixel-by-pixel with the normalized grayscale image, and the images are then superimposed and merged along the channel dimension to generate an enhanced image.

[0019] The enhanced image is subjected to edge-preserving filtering. Each pixel in the enhanced image is traversed, and the gray-level difference and spatial distance difference between the pixel and its neighboring pixels are calculated. The gray-level difference is mapped to an intensity similarity coefficient, and the spatial distance difference is mapped to a spatial weight coefficient. The intensity similarity coefficient and the spatial weight coefficient are multiplied and normalized to serve as the filtering weight. The gray-level value of the current pixel is replaced by a weighted average of the pixel values ​​in the neighboring area.

[0020] The filtered enhanced image is subjected to discrete wavelet transform. A two-dimensional orthogonal wavelet basis at a set scale is used to perform high-pass filtering in the horizontal, vertical and diagonal directions to generate high-frequency sub-band images in three directions. All high-frequency sub-band images are consistent with the size of the filtered enhanced image.

[0021] The filtered enhanced image is treated as a single-channel tensor and sequentially concatenated with high-frequency sub-band images in the horizontal, vertical, and diagonal directions along the channel dimension to generate spatial-frequency fusion feature image data with four channels.

[0022] Optionally, step three specifically includes:

[0023] The spatial-frequency fusion feature image data is input into a feature extraction network with HRNet-W48 as the backbone. HRNet-W48 includes four parallel branches, which receive image features with downsampling ratios of 1, 2, 4 and 8 respectively. The four branches perform image feature transfer at each stage through a lateral connection structure. After each stage, each branch maintains the original resolution and continues to transfer image features.

[0024] A frequency-aware channel enhancement module is added within each branch. The frequency-aware channel enhancement module includes a frequency feature fusion submodule and a channel attention calculation submodule.

[0025] The frequency feature fusion submodule concatenates the feature map of the current branch with the high-frequency subband image at the corresponding scale in the channel dimension. The concatenation result is input into three 3×3 convolutional layers for sequential processing and outputs the fused image feature map.

[0026] The channel attention calculation submodule performs global average pooling on the fused image feature map in the channel direction, and after inputting it into a two-layer fully connected network, generates a channel weight map. The channel weight map is then multiplied by the fused image feature map channel by channel in order to output an enhanced image feature map.

[0027] When performing enhanced image feature map transfer between any two parallel branches, an adaptive scale alignment module is inserted, which includes scale mapping operation and size compensation operation.

[0028] The scale mapping operation performs pointwise convolution in the channel direction on the enhanced image feature map of the high-resolution branch, adjusting it to be consistent with the number of channels of the low-resolution branch. The size compensation operation performs bilinear interpolation upsampling on the enhanced image feature map, adjusting the size of the enhanced image feature map to be completely consistent with the size of the target branch space. The aligned enhanced image feature map and the enhanced image feature map of the target branch are concatenated in the channel dimension to output a cross-scale fusion map.

[0029] The cross-scale fused graphs output from all stages are upsampled to the highest resolution using bilinear interpolation and aligned in the spatial dimension before being stitched together in the channel dimension to form a feature representation tensor.

[0030] Optionally, the encoder based on the Transformer structure includes multiple encoding modules, each encoding module including a feature partitioning unit, an embedding transformation unit, a multi-head attention mechanism unit, and a feedforward network;

[0031] The feature partitioning unit divides the input feature representation tensor into two-dimensional image blocks of a set size, and each image block is flattened into a one-dimensional image block vector in the spatial dimension.

[0032] The embedding transformation unit performs a linear transformation on each one-dimensional image patch vector, mapping it to an embedding space of a unified dimension to form an image patch embedding sequence;

[0033] The multi-head attention mechanism unit performs multi-head self-attention calculation on the image patch embedding sequence, generates multiple attention weight matrices, and performs weighted combination of the image patch embedding sequence according to the respective attention weight matrices to output multi-channel context features.

[0034] The feedforward network includes two fully connected layers and one GELU activation layer. The first fully connected layer performs dimensionality up-processing on the multi-channel context features. The GELU activation layer performs non-linear mapping on the up-dimensional multi-channel context features. The second fully connected layer performs dimensionality down-processing on the mapped up-dimensional multi-channel context features and outputs encoded features with the same embedding dimension as the input.

[0035] Multiple encoding modules are connected in series to form the encoder backbone structure. The output of the previous encoding module serves as the input of the next encoding module, and finally, the Transformer encoded features are output.

[0036] Optionally, the low-rank attention transformation module performs linear dimensionality reduction on the input Transformer encoded features in the channel dimension using matrix projection, compressing the number of channels of the Transformer encoded features from the original dimension to a preset low-dimensional value.

[0037] The dimensionality-reduced Transformer encoded features are expanded into a two-dimensional matrix in the spatial dimension. By constructing the inner product relationship between the query matrix and the key matrix, the correlation matrix of the dimensionality-reduced Transformer encoded features at the corresponding spatial positions is formed.

[0038] Based on the correlation matrix, matrix multiplication is performed on the value matrix of the dimension-reduced Transformer encoded features to generate an attention-weighted Transformer encoded response tensor.

[0039] The attention-weighted Transformer encoded response tensor is linearly up-dimensional by introducing a channel mapping matrix to restore it to the same number of channels as the input Transformer encoded features, while maintaining the same spatial size as the input Transformer encoded features;

[0040] The upgraded Transformer encoded features are output to the multi-scale fusion decoder as input features.

[0041] Optionally, the multi-scale fusion decoder includes multiple upsampling branches and a feature fusion module;

[0042] The multiple upsampling branches receive input features with resolutions of 1 / 4, 1 / 8, 1 / 16 and 1 / 32 respectively, and perform bilinear interpolation upsampling processing on the input features at each scale to adjust the spatial resolution of all input features to be consistent with the 1 / 4 scale.

[0043] The feature fusion module concatenates the upsampled input features along the channel dimension, then sequentially inputs them into the convolutional layer for feature fusion processing, and outputs a crack mask image.

[0044] Optionally, step five specifically includes:

[0045] The crack mask image is converted into a binary image, with the pixel value of the crack area set to 1 and the pixel value of the non-crack area set to 0.

[0046] The crack trunk line is extracted from the binary image using an iterative thinning algorithm based on the eight-neighborhood rule, specifically including:

[0047] Traverse all pixels in the binary image. For each pixel, extract a neighborhood window consisting of eight neighboring pixels and count the number of pixels with a value of 1 in the neighborhood.

[0048] To determine whether the current pixel is at an edge, the edge detection condition is whether the number of 0-1 transitions in the neighborhood is equal to 1. If the number of 0-1 transitions is equal to 1, the current pixel is at an edge; otherwise, the current pixel is not at an edge.

[0049] Calculate the structural integrity of the pixel and determine whether deletion will cause a break between adjacent pixels. If the neighboring region remains connected after deleting a pixel, then the culling premise is satisfied.

[0050] The pixel removal criteria are set as follows: the current pixel value is 1, the number of pixels with a value of 1 in the neighborhood is between 2 and 6, the number of 0-1 transitions is equal to 1, and the deletion does not destroy the connectivity of the neighborhood.

[0051] Pixels that meet the set pixel removal conditions are marked as deleted and set to 0 in the current iteration until there are no more pixels that meet the set pixel removal conditions in the entire binary image. The output result is a thinned image that retains only the main structure.

[0052] All pixels with a value of 1 in the refined image are taken as the main crack lines and nodes. Based on the eight-adjacency relationship, the edge connection relationship between each node and its adjacent nodes is defined to construct a crack connected graph structure containing a set of nodes and a set of edges.

[0053] Traverse all node subgraphs in the fracture connected graph structure, identify isolated subgraphs without connection paths as fracture segments, and record the positions of the endpoints of each fracture segment;

[0054] Calculate the Euclidean distance between the endpoints of any two crack segments. If the Euclidean distance is less than the preset connection threshold, add an edge between the endpoints to establish a connection relationship and merge the two crack segments into the same connected subgraph.

[0055] After completing the connections between all crack segments that meet the connection conditions, output the repaired crack connectivity graph structure.

[0056] Optionally, the geometric attributes specifically include crack length, width, direction, start and end point coordinates, and curvature information.

[0057] The beneficial effects of this invention are:

[0058] This invention addresses the issues of uneven illumination, texture interference, and weak crack structure response in tunnel crack images by integrating spatial-frequency fusion preprocessing with a high-resolution feature modeling network. It employs a combination of Retinex enhancement and edge-preserving filtering, and introduces discrete wavelet transform to construct high-frequency sub-band images, achieving multi-scale fusion of spatial and frequency information. In the feature extraction stage, a multi-branch network with HRNet-W48 as the backbone is constructed, combined with a frequency-aware channel enhancement module to improve the high-frequency crack feature response. An adaptive scale alignment mechanism ensures accurate fusion of multi-scale information. In the semantic encoding stage, a Transformer-based structure is used. The SegFormer model integrates a low-rank attention transformation module to model the global context, improving the accuracy of identifying minute cracks. In the post-processing stage, an iterative refinement algorithm based on the eight-neighborhood rule is constructed to extract the main crack lines, and a graph structure is built to reconstruct the connectivity of fracture cracks, thereby outputting a topologically continuous crack connectivity graph. Finally, discontinuous crack structures are repaired through graph traversal and endpoint association analysis, and geometric attributes such as crack length, width, direction, start and end point coordinates, and curvature information are extracted. This realizes an automated tunnel crack identification process from image preprocessing and structure recognition to geometric analysis, effectively improving the completeness, accuracy, and interpretability of crack identification in complex backgrounds. Attached Figure Description

[0059] The accompanying drawings are provided to further illustrate the invention and form part of the specification. They are used in conjunction with embodiments of the invention to explain the invention and do not constitute a limitation thereof. In the drawings:

[0060] Figure 1 This is an overall flowchart of a deep learning-based automatic tunnel crack identification method proposed in this invention.

[0061] Figure 2 This is a schematic diagram of the feature extraction network structure of the deep learning-based automatic tunnel crack identification method proposed in this invention, with HRNet-W48 as the backbone.

[0062] Figure 3 This is a flowchart illustrating the construction process of a crack connectivity graph for an automatic tunnel crack identification method based on deep learning proposed in this invention. Detailed Implementation

[0063] The present invention will now be described in further detail with reference to the accompanying drawings. These drawings are simplified schematic diagrams, illustrating only the basic structure of the invention, and therefore only show the components relevant to the invention.

[0064] refer to Figures 1-3 A method for automatic identification of tunnel cracks based on deep learning includes the following steps:

[0065] Step 1: Acquire image data of the tunnel surface;

[0066] Step 2: Preprocess the image data, including image grayscale normalization, Retinex enhancement, edge-preserving filtering, and discrete wavelet transform, to obtain spatial-frequency fusion feature image data;

[0067] Step 3: Input the spatial-frequency fusion feature image data into the feature extraction network with HRNet-W48 as the backbone, add a frequency-aware channel enhancement module to each branch, and introduce an adaptive scale alignment module when connecting across branches to output a feature representation tensor;

[0068] Step 4: Input the feature representation tensor into the SegFormer network. The SegFormer network includes an encoder based on the Transformer structure and a multi-scale fusion decoder. A low-rank attention transformation module is introduced at the front end of the multi-scale fusion decoder to output a crack mask map.

[0069] Step 5: Perform crack structure reconstruction processing on the crack mask map, use an iterative thinning algorithm based on the eight-neighbor rule to extract the main crack lines, construct the crack connectivity graph structure, and repair discontinuous cracks through graph connectivity analysis, and output the repaired crack connectivity graph structure.

[0070] Step 6: Extract the geometric attributes of the repaired crack connectivity graph structure, and visualize the crack mask map and geometric attributes.

[0071] In this embodiment, the image data specifically includes visible light images, multispectral images, and infrared images, with an image resolution of not less than 2048×1024 pixels.

[0072] In this embodiment, step two specifically includes:

[0073] By reading the red, green, and blue channel values ​​of each pixel in the image data, and adding the three channel values ​​according to a set weighting ratio, a single-channel grayscale image is generated.

[0074] The grayscale image is subjected to grayscale normalization processing, and the grayscale values ​​of all pixels in the grayscale image are scaled to a continuous range between 0 and 1 through linear mapping;

[0075] The normalized grayscale image is enhanced with Retinex. The normalized grayscale image is then copied into three copies and blurred to different degrees. The blurring operation uses a sliding window of a set size to perform convolution smoothing on the entire image.

[0076] For each blurred image, a logarithmic difference is performed pixel-by-pixel with the normalized grayscale image, and the images are then superimposed and merged along the channel dimension to generate an enhanced image.

[0077] The enhanced image is subjected to edge-preserving filtering. Each pixel in the enhanced image is traversed, and the gray-level difference and spatial distance difference between the pixel and its neighboring pixels are calculated. The gray-level difference is mapped to an intensity similarity coefficient, and the spatial distance difference is mapped to a spatial weight coefficient. The intensity similarity coefficient and the spatial weight coefficient are multiplied and normalized to serve as the filtering weight. The gray-level value of the current pixel is replaced by a weighted average of the pixel values ​​in the neighboring area.

[0078] The filtered enhanced image is subjected to discrete wavelet transform. A two-dimensional orthogonal wavelet basis at a set scale is used to perform high-pass filtering in the horizontal, vertical and diagonal directions to generate high-frequency sub-band images in three directions. All high-frequency sub-band images are consistent with the size of the filtered enhanced image.

[0079] The filtered enhanced image is treated as a single-channel tensor and sequentially concatenated with high-frequency sub-band images in the horizontal, vertical, and diagonal directions along the channel dimension to generate spatial-frequency fusion feature image data with four channels.

[0080] In this embodiment, step three specifically includes:

[0081] The spatial-frequency fusion feature image data is input into a feature extraction network with HRNet-W48 as the backbone. HRNet-W48 includes four parallel branches, which receive image features with downsampling ratios of 1, 2, 4 and 8 respectively. The four branches perform image feature transfer at each stage through a lateral connection structure. After each stage, each branch maintains the original resolution and continues to transfer image features.

[0082] In this invention, each stage refers to the four main stages of the HRNet-W48 network structure from input to output, namely stage one to stage four. Stage one contains only the original resolution branch. Stages two to four each add a downsampling branch in each stage, and finally, in stage four, four parallel feature map branches with resolutions of 1x, 1 / 2x, 1 / 4x, and 1 / 8x are formed. The stages are laterally connected through a multi-scale feature fusion module to realize the transfer and sharing of image features between the branches.

[0083] A frequency-aware channel enhancement module is added within each branch. The frequency-aware channel enhancement module includes a frequency feature fusion submodule and a channel attention calculation submodule.

[0084] The frequency feature fusion submodule concatenates the feature map of the current branch with the high-frequency subband image at the corresponding scale in the channel dimension. The concatenation result is input into three 3×3 convolutional layers for sequential processing and outputs the fused image feature map.

[0085] The channel attention calculation submodule performs global average pooling on the fused image feature map in the channel direction, and after inputting it into a two-layer fully connected network, generates a channel weight map. The channel weight map is then multiplied by the fused image feature map channel by channel in order to output an enhanced image feature map.

[0086] When performing enhanced image feature map transfer between any two parallel branches, an adaptive scale alignment module is inserted, which includes scale mapping operation and size compensation operation.

[0087] The scale mapping operation performs pointwise convolution in the channel direction on the enhanced image feature map of the high-resolution branch, adjusting it to be consistent with the number of channels of the low-resolution branch. The size compensation operation performs bilinear interpolation upsampling on the enhanced image feature map, adjusting the size of the enhanced image feature map to be completely consistent with the size of the target branch space. The aligned enhanced image feature map and the enhanced image feature map of the target branch are concatenated in the channel dimension to output a cross-scale fusion map.

[0088] After performing bilinear interpolation upsampling to the highest resolution and aligning the cross-scale fused graphs output from all stages, they are stitched together in the channel dimension to form a feature representation tensor.

[0089] In this invention, HRNet-W48 is used as the backbone structure of the feature extraction network. By constructing four parallel branches to process image features at different resolutions and maintaining their respective resolutions at each stage, this avoids the loss of high-resolution information caused by repeated downsampling and upsampling in traditional networks, thereby enhancing the ability to preserve the fine-grained structure of tunnel cracks. Simultaneously, the parallel branches achieve efficient fusion of features at different scales through lateral connections, improving the model's ability to express multi-scale crack morphology.

[0090] A frequency-aware channel enhancement module is introduced into each branch, fusing wavelet high-frequency sub-band images with the feature map of the current branch. This significantly improves the network's sensitivity to crack texture details, especially in extracting weakly textured regions such as narrow cracks and hairline cracks. The channel weight map generated by the channel attention calculation sub-module is used to weight and adjust the fused features, enabling the network to automatically focus on important high-frequency texture channels during training, effectively suppressing background interference and pseudo-crack regions.

[0091] An adaptive scale alignment module is introduced during cross-branch feature transfer. By adjusting the channel structure through pointwise convolution and compensating for spatial size through bilinear interpolation, the feature maps at different resolutions are fully aligned in dimension, avoiding feature distortion and semantic drift. This enhances the consistency and accuracy of cross-scale fusion. Finally, the feature representation tensor formed by uniformly upsampling and channel stitching the image feature maps output at each scale has a richer ability to express spatial structure and frequency information, providing high-quality input for crack region recognition and semantic segmentation.

[0092] In this embodiment, the encoder based on the Transformer structure includes multiple encoding modules, each encoding module including a feature partitioning unit, an embedding transformation unit, a multi-head attention mechanism unit, and a feedforward network;

[0093] The feature partitioning unit divides the input feature representation tensor into two-dimensional image blocks of a set size, and each image block is flattened into a one-dimensional image block vector in the spatial dimension.

[0094] The embedding transformation unit performs a linear transformation on each one-dimensional image patch vector, mapping it to an embedding space of a unified dimension to form an image patch embedding sequence;

[0095] The multi-head attention mechanism unit performs multi-head self-attention calculation on the image patch embedding sequence, generates multiple attention weight matrices, and performs weighted combination of the image patch embedding sequence according to the respective attention weight matrices to output multi-channel context features.

[0096] When the multi-head attention mechanism unit performs multi-head self-attention computation on the image patch embedding sequence, it first inputs each image patch embedding vector into a linear mapping layer to generate corresponding query vectors, key vectors, and value vectors. Then, it calculates the dot product similarity between the query vector and all key vectors, divides it by a scaling factor, and inputs it into a Softmax function to generate a set of normalized attention weights for each query vector. Finally, it performs a position-weighted summation of these weights with the corresponding value vector to obtain the attention output for that query vector. This computation process is executed independently and in parallel in each head, with each attention head using different mapping parameters to output multiple independent attention features. Finally, the outputs from all attention heads are concatenated along the channel dimension and input into a linear mapping layer for channel integration processing, outputting multi-channel contextual features. This enables parallel modeling of long-distance dependencies between image patches in multiple subspaces, enhancing the encoder's ability to perceive spatial structural information in cracked images and improving the accuracy and robustness of the overall semantic representation.

[0097] The feedforward network includes two fully connected layers and one GELU activation layer. The first fully connected layer performs dimensionality up-processing on the multi-channel context features. The GELU activation layer performs non-linear mapping on the up-dimensional multi-channel context features. The second fully connected layer performs dimensionality down-processing on the mapped up-dimensional multi-channel context features and outputs encoded features with the same embedding dimension as the input.

[0098] Multiple encoding modules are connected in series to form the encoder backbone structure. The output of the previous encoding module serves as the input of the next encoding module, and finally, the Transformer encoded features are output.

[0099] In this embodiment, the low-rank attention transformation module performs linear dimensionality reduction on the input Transformer encoded features in the channel dimension using matrix projection, compressing the number of channels of the Transformer encoded features from the original dimension to a preset low-dimensional value.

[0100] The matrix projection method refers to using a learnable linear transformation in the channel dimension to compress the dimensionality of the input high-dimensional Transformer encoded feature tensor. Specifically, assuming the feature vector at each spatial location is a one-dimensional high-dimensional vector in the channel dimension, a linear projection matrix of size (original number of channels × low-dimensional number of channels) is constructed. Matrix multiplication is then performed on this high-dimensional vector to map it into the low-dimensional channel space. The linear projection matrix is ​​automatically updated as a learnable parameter during model training, ensuring that the projected low-dimensional representation retains key semantic features. This matrix projection operation effectively reduces redundant information in the channel dimension while maintaining the spatial structure, improving the efficiency and accuracy of subsequent attention calculations.

[0101] The dimensionality-reduced Transformer encoded features are expanded into a two-dimensional matrix in the spatial dimension. By constructing the inner product relationship between the query matrix and the key matrix, the correlation matrix of the dimensionality-reduced Transformer encoded features at the corresponding spatial positions is formed.

[0102] Based on the correlation matrix, matrix multiplication is performed on the value matrix of the dimension-reduced Transformer encoded features to generate an attention-weighted Transformer encoded response tensor.

[0103] The attention-weighted Transformer encoded response tensor is linearly up-dimensional by introducing a channel mapping matrix to restore it to the same number of channels as the input Transformer encoded features, while maintaining the same spatial size as the input Transformer encoded features;

[0104] The upgraded Transformer encoded features are output to the multi-scale fusion decoder as input features.

[0105] In this embodiment, the multi-scale fusion decoder includes multiple upsampling branches and a feature fusion module;

[0106] The multiple upsampling branches receive input features with resolutions of 1 / 4, 1 / 8, 1 / 16 and 1 / 32 respectively, and perform bilinear interpolation upsampling processing on the input features at each scale to adjust the spatial resolution of all input features to be consistent with the 1 / 4 scale.

[0107] The feature fusion module concatenates the upsampled input features along the channel dimension, then sequentially inputs them into the convolutional layer for feature fusion processing, and outputs a crack mask image.

[0108] In this embodiment, step five specifically includes:

[0109] The crack mask image is converted into a binary image, with the pixel value of the crack area set to 1 and the pixel value of the non-crack area set to 0.

[0110] The crack trunk line is extracted from the binary image using an iterative thinning algorithm based on the eight-neighborhood rule, specifically including:

[0111] Traverse all pixels in the binary image. For each pixel, extract a neighborhood window consisting of eight neighboring pixels and count the number of pixels with a value of 1 in the neighborhood.

[0112] To determine whether the current pixel is at an edge, the edge detection condition is whether the number of 0-1 transitions in the neighborhood is equal to 1. If the number of 0-1 transitions is equal to 1, the current pixel is at an edge; otherwise, the current pixel is not at an edge.

[0113] Calculate the structural integrity of the pixel and determine whether deletion will cause a break between adjacent pixels. If the neighboring region remains connected after deleting a pixel, then the culling premise is satisfied.

[0114] The pixel removal criteria are set as follows: the current pixel value is 1, the number of pixels with a value of 1 in the neighborhood is between 2 and 6, the number of 0-1 transitions is equal to 1, and the deletion does not destroy the connectivity of the neighborhood.

[0115] Pixels that meet the set pixel removal conditions are marked as deleted and set to 0 in the current iteration until there are no more pixels that meet the set pixel removal conditions in the entire binary image. The output result is a thinned image that retains only the main structure.

[0116] All pixels with a value of 1 in the refined image are taken as the main crack lines and nodes. Based on the eight-adjacency relationship, the edge connection relationship between each node and its adjacent nodes is defined to construct a crack connected graph structure containing a set of nodes and a set of edges.

[0117] In this invention, a foreground pixel has a value of 1, indicating the presence of a crack; a background pixel has a value of 0, indicating the absence of a crack. When constructing the crack-connected graph structure based on eight adjacency relationships, each foreground pixel is considered a node in the graph. For each pixel, its eight adjacent pixels (top, bottom, left, right, and four diagonals) are examined to determine if any of these adjacent pixels are also foreground pixels. If a neighboring pixel is a foreground pixel, an edge is established between that pixel and its neighboring pixels in the graph structure, representing their spatial connection in the image.

[0118] The connection relationships are established using undirected edges, ensuring that only one edge is established between any two foreground pixels with spatial adjacency to avoid redundancy. By traversing all foreground pixels in the image and performing adjacency checks on each pixel's eight directions, a complete adjacency graph reflecting the image's structural features can be constructed.

[0119] Traverse all node subgraphs in the fracture connected graph structure, identify isolated subgraphs without connection paths as fracture segments, and record the positions of the endpoints of each fracture segment;

[0120] Calculate the Euclidean distance between the endpoints of any two crack segments. If the Euclidean distance is less than the preset connection threshold, add an edge between the endpoints to establish a connection relationship and merge the two crack segments into the same connected subgraph.

[0121] After completing the connections between all crack segments that meet the connection conditions, output the repaired crack connectivity graph structure.

[0122] In this embodiment, the geometric attributes specifically include crack length, width, direction, start and end point coordinates, and curvature information.

[0123] Example 1:

[0124] To verify the feasibility of this invention in practice, it was applied to a typical tunnel inspection scenario. A large number of tunnel wall images were acquired through an unmanned inspection system, and crack identification and geometric parameter extraction were completed under actual construction and maintenance conditions. The stability, accuracy, and adaptability of the deep learning-based automatic tunnel crack identification method proposed in this invention were comprehensively tested.

[0125] In this embodiment, the inspection system uses an automated mobile platform equipped with a high-definition industrial camera to continuously acquire image data along the tunnel trajectory. The image coverage area includes typical structural areas such as sidewalls, arches, and inverted arches. The image resolution is uniformly set to 2048×1024 pixels, the frame rate is controlled at 5 frames per second, and approximately 5500 images are acquired in a single operation, covering a total distance of approximately 2.5 kilometers. Following the processing flow of this invention, the acquired image data is first preprocessed, including grayscale normalization, Retinex enhancement, edge-preserving filtering, and discrete wavelet transform operations, to improve the contrast of crack edge features and suppress background noise.

[0126] Based on the spatial-frequency fusion feature image after image enhancement, the HRNet-W48 feature extraction network is input and combined with a frequency-aware channel enhancement module to perform multi-scale crack feature extraction. Subsequently, a SegFormer network with low-rank attention transform is introduced to complete pixel-level crack segmentation, outputting a high-resolution crack mask image. In the crack structure reconstruction stage, after the mask image is converted into a binary image, an iterative thinning algorithm based on the eight-neighbor rule is used to accurately extract the main crack lines. All main crack line pixels are treated as nodes in the graph structure, and edge connections between nodes are established using the eight-neighbor rule to form a complete crack connected graph structure.

[0127] During the graph structure analysis phase, adjacent but unclosed crack segments are connected using a Euclidean distance threshold, effectively repairing discontinuities in the graph. The repaired connected graph is then used for geometric attribute extraction, including key parameters such as the length, width, direction, start and end point coordinates, and curvature of each crack. The final output is a crack data table that can be used for engineering evaluation.

[0128] During testing, 1436 valid crack images were identified from 5500 images, yielding 2971 crack structures. The total identification time was 48 minutes. Compared with manual identification results, this invention maintains an average pixel-level accuracy of 93.6% while improving processing efficiency by approximately 5.2 times. More importantly, through automatic extraction of geometric attributes, the system can generate crack attribute parameters for a single image within 30 seconds, significantly improving the efficiency of subsequent crack rating and disease analysis.

[0129] Table 1. Statistical Table of Crack Recognition Performance in Sample Images

[0130]

[0131] Based on the data in Table 1 above, it can be seen that the automatic tunnel crack identification method proposed in this invention has a relatively stable overall recognition effect on different image samples, and has strong adaptability and high accuracy.

[0132] From the distribution of crack number and total length, images with more cracks, such as IMG022 and IMG047, detected 6 and 5 cracks respectively, with total lengths reaching 872.1 mm and 790.6 mm, demonstrating that the method can effectively identify complex crack structures. In contrast, IMG035 and IMG011 detected only 1-2 cracks, indicating that the method also possesses high sensitivity in simple crack scenarios. The average crack width is generally between 1.5 mm and 2.6 mm, with the maximum width reaching 4.2 mm, indicating that the system has strong resolution in detecting small cracks.

[0133] Regarding the curvature variation trend, the images exhibit various changes such as increase, decrease, and significant fluctuations, indicating that the system has the ability to characterize the trend of crack morphological changes. The main direction is distributed between -6.5° and 15.7°, indicating that the recognition system can accurately model cracks in different directions. The start and end point coordinates are also accurately provided, which is helpful for subsequent crack location and repair.

[0134] The recognition time ranges from 211ms to 309ms, with an average of about 270ms, which can meet the needs of engineering practice for rapid recognition; while the recognition accuracy is between 91.9% and 96.3%, with an average accuracy of 94.1%, proving that the invention has high robustness and reliability.

[0135] This embodiment constructs a complete automatic tunnel crack identification process, achieving efficient identification and structured representation of complex crack morphologies. By employing frequency-aware channel enhancement and multi-scale fusion decoding strategies, the feature representation capability of crack edge regions is effectively improved. After crack mask image generation, skeleton extraction based on eight-neighborhood rules and graph connectivity analysis are introduced to accurately reconstruct the main crack line and repair discontinuous crack structures, greatly enhancing the integrity and spatial connectivity of crack information. Simultaneously, it also possesses comprehensive geometric attribute extraction and visualization capabilities, providing important reference for crack assessment and repair.

[0136] The above description is only a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any equivalent substitutions or modifications made by those skilled in the art within the scope of the technology disclosed in the present invention, based on the technical solution and inventive concept of the present invention, should be covered within the scope of protection of the present invention.

Claims

1. A method for automatic identification of tunnel cracks based on deep learning, characterized in that, Includes the following steps: Step 1: Acquire image data of the tunnel surface; Step 2: Preprocess the image data, including image grayscale normalization, Retinex enhancement, edge-preserving filtering, and discrete wavelet transform, to obtain spatial-frequency fusion feature image data; Step 3: Input the spatial-frequency fusion feature image data into the feature extraction network with HRNet-W48 as the backbone, add a frequency-aware channel enhancement module to each branch, and introduce an adaptive scale alignment module when connecting across branches to output a feature representation tensor; Step 4: Input the feature representation tensor into the SegFormer network. The SegFormer network includes an encoder based on the Transformer structure and a multi-scale fusion decoder. A low-rank attention transformation module is introduced at the front end of the multi-scale fusion decoder to output a crack mask map. Step 5: Perform crack structure reconstruction processing on the crack mask map, use an iterative thinning algorithm based on the eight-neighbor rule to extract the main crack lines, construct the crack connectivity graph structure, and repair discontinuous cracks through graph connectivity analysis, and output the repaired crack connectivity graph structure. Step 6: Extract the geometric attributes of the repaired crack connectivity graph structure, and visualize the crack mask map and geometric attributes.

2. The method for automatic identification of tunnel cracks based on deep learning according to claim 1, characterized in that, The image data specifically includes visible light images, multispectral images, and infrared images, with an image resolution of no less than 2048×1024 pixels.

3. The method for automatic identification of tunnel cracks based on deep learning according to claim 1, characterized in that, Step two specifically involves: By reading the red, green, and blue channel values ​​of each pixel in the image data, and adding the three channel values ​​according to a set weighting ratio, a single-channel grayscale image is generated. The grayscale image is subjected to grayscale normalization processing, and the grayscale values ​​of all pixels in the grayscale image are scaled to a continuous range between 0 and 1 through linear mapping; The normalized grayscale image is enhanced with Retinex. The normalized grayscale image is then copied into three copies and blurred to different degrees. The blurring operation uses a sliding window of a set size to perform convolution smoothing on the entire image. For each blurred image, a logarithmic difference is performed pixel-by-pixel with the normalized grayscale image, and the images are then superimposed and merged along the channel dimension to generate an enhanced image. The enhanced image is subjected to edge-preserving filtering. Each pixel in the enhanced image is traversed, and the gray-level difference and spatial distance difference between the pixel and its neighboring pixels are calculated. The gray-level difference is mapped to an intensity similarity coefficient, and the spatial distance difference is mapped to a spatial weight coefficient. The intensity similarity coefficient and the spatial weight coefficient are multiplied and normalized to serve as the filtering weight. The gray-level value of the current pixel is replaced by a weighted average of the pixel values ​​in the neighboring area. The filtered enhanced image is subjected to discrete wavelet transform. A two-dimensional orthogonal wavelet basis at a set scale is used to perform high-pass filtering in the horizontal, vertical and diagonal directions to generate high-frequency sub-band images in three directions. All high-frequency sub-band images are consistent with the size of the filtered enhanced image. The filtered enhanced image is treated as a single-channel tensor and sequentially concatenated with high-frequency sub-band images in the horizontal, vertical, and diagonal directions along the channel dimension to generate spatial-frequency fusion feature image data with four channels.

4. The method for automatic identification of tunnel cracks based on deep learning according to claim 1, characterized in that, Step three specifically involves: The spatial-frequency fusion feature image data is input into a feature extraction network with HRNet-W48 as the backbone. HRNet-W48 includes four parallel branches, which receive image features with downsampling ratios of 1, 2, 4 and 8 respectively. The four branches perform image feature transfer at each stage through a lateral connection structure. After each stage, each branch maintains the original resolution and continues to transfer image features. A frequency-aware channel enhancement module is added within each branch. The frequency-aware channel enhancement module includes a frequency feature fusion submodule and a channel attention calculation submodule. The frequency feature fusion submodule concatenates the feature map of the current branch with the high-frequency subband image at the corresponding scale in the channel dimension. The concatenation result is input into three 3×3 convolutional layers for sequential processing and outputs the fused image feature map. The channel attention calculation submodule performs global average pooling on the fused image feature map in the channel direction, and after inputting it into a two-layer fully connected network, generates a channel weight map. The channel weight map is then multiplied by the fused image feature map channel by channel in order to output an enhanced image feature map. When performing enhanced image feature map transfer between any two parallel branches, an adaptive scale alignment module is inserted, which includes scale mapping operation and size compensation operation. The scale mapping operation performs pointwise convolution in the channel direction on the enhanced image feature map of the high-resolution branch, adjusting it to be consistent with the number of channels of the low-resolution branch. The size compensation operation performs bilinear interpolation upsampling on the enhanced image feature map, adjusting the size of the enhanced image feature map to be completely consistent with the size of the target branch space. The aligned enhanced image feature map and the enhanced image feature map of the target branch are concatenated in the channel dimension to output a cross-scale fusion map. The cross-scale fused graphs output from all stages are upsampled to the highest resolution using bilinear interpolation and aligned in the spatial dimension before being stitched together in the channel dimension to form a feature representation tensor.

5. The method for automatic identification of tunnel cracks based on deep learning according to claim 1, characterized in that, The encoder based on the Transformer structure includes multiple encoding modules, each encoding module including a feature partitioning unit, an embedding transformation unit, a multi-head attention mechanism unit, and a feedforward network; The feature partitioning unit divides the input feature representation tensor into two-dimensional image blocks of a set size, and each image block is flattened into a one-dimensional image block vector in the spatial dimension. The embedding transformation unit performs a linear transformation on each one-dimensional image patch vector, mapping it to an embedding space of a unified dimension to form an image patch embedding sequence; The multi-head attention mechanism unit performs multi-head self-attention calculation on the image patch embedding sequence, generates multiple attention weight matrices, and performs weighted combination of the image patch embedding sequence according to the respective attention weight matrices to output multi-channel context features. The feedforward network includes two fully connected layers and one GELU activation layer. The first fully connected layer performs dimensionality up-processing on the multi-channel context features. The GELU activation layer performs non-linear mapping on the up-dimensional multi-channel context features. The second fully connected layer performs dimensionality down-processing on the mapped up-dimensional multi-channel context features and outputs encoded features with the same embedding dimension as the input. Multiple encoding modules are connected in series to form the encoder backbone structure. The output of the previous encoding module serves as the input of the next encoding module, and finally, the Transformer encoded features are output.

6. The method for automatic identification of tunnel cracks based on deep learning according to claim 1, characterized in that, The low-rank attention transformation module performs linear dimensionality reduction on the input Transformer encoded features in the channel dimension using matrix projection, compressing the number of channels of the Transformer encoded features from the original dimension to a preset low-dimensional value. The dimensionality-reduced Transformer encoded features are expanded into a two-dimensional matrix in the spatial dimension. By constructing the inner product relationship between the query matrix and the key matrix, the correlation matrix of the dimensionality-reduced Transformer encoded features at the corresponding spatial positions is formed. Based on the correlation matrix, matrix multiplication is performed on the value matrix of the dimension-reduced Transformer encoded features to generate an attention-weighted Transformer encoded response tensor. The attention-weighted Transformer encoded response tensor is linearly up-dimensional by introducing a channel mapping matrix to restore it to the same number of channels as the input Transformer encoded features, while maintaining the same spatial size as the input Transformer encoded features; The upgraded Transformer encoded features are output to the multi-scale fusion decoder as input features.

7. The method for automatic identification of tunnel cracks based on deep learning according to claim 1, characterized in that, The multi-scale fusion decoder includes multiple upsampling branches and a feature fusion module; The multiple upsampling branches receive input features with resolutions of 1 / 4, 1 / 8, 1 / 16 and 1 / 32 respectively, and perform bilinear interpolation upsampling processing on the input features at each scale to adjust the spatial resolution of all input features to be consistent with the 1 / 4 scale. The feature fusion module concatenates the upsampled input features along the channel dimension, then sequentially inputs them into the convolutional layer for feature fusion processing, and outputs a crack mask image.

8. The method for automatic identification of tunnel cracks based on deep learning according to claim 1, characterized in that, Step five specifically involves: The crack mask image is converted into a binary image, with the pixel value of the crack area set to 1 and the pixel value of the non-crack area set to 0. The crack trunk line is extracted from the binary image using an iterative thinning algorithm based on the eight-neighborhood rule, specifically including: Traverse all pixels in the binary image. For each pixel, extract a neighborhood window consisting of eight neighboring pixels and count the number of pixels with a value of 1 in the neighborhood. To determine whether the current pixel is at an edge, the edge detection condition is whether the number of 0-1 transitions in the neighborhood is equal to 1. If the number of 0-1 transitions is equal to 1, the current pixel is at an edge; otherwise, the current pixel is not at an edge. Calculate the structural integrity of the pixel and determine whether deletion will cause a break between adjacent pixels. If the neighboring region remains connected after deleting a pixel, then the culling premise is satisfied. The pixel removal criteria are set as follows: the current pixel value is 1, the number of pixels with a value of 1 in the neighborhood is between 2 and 6, the number of 0-1 transitions is equal to 1, and the deletion does not destroy the connectivity of the neighborhood. Pixels that meet the set pixel removal conditions are marked as deleted and set to 0 in the current iteration until there are no more pixels that meet the set pixel removal conditions in the entire binary image. The output result is a thinned image that retains only the main structure. All pixels with a value of 1 in the refined image are taken as the main crack lines and nodes. Based on the eight-adjacency relationship, the edge connection relationship between each node and its adjacent nodes is defined to construct a crack connected graph structure containing a set of nodes and a set of edges. Traverse all node subgraphs in the fracture connected graph structure, identify isolated subgraphs without connection paths as fracture segments, and record the positions of the endpoints of each fracture segment; Calculate the Euclidean distance between the endpoints of any two crack segments. If the Euclidean distance is less than the preset connection threshold, add an edge between the endpoints to establish a connection relationship and merge the two crack segments into the same connected subgraph. After completing the connections between all crack segments that meet the connection conditions, output the repaired crack connectivity graph structure.

9. The method for automatic identification of tunnel cracks based on deep learning according to claim 1, characterized in that, The geometric attributes specifically include crack length, width, direction, start and end point coordinates, and curvature information.

Citation Information

Patent Citations

  • High-voltage switch cabinet relay crack detection method and related device

    CN119741295A

  • Subway tunnel crack identification method and system based on deep learning

    CN120783215A