Crack detection method and device based on bounding box guidance constraint and electronic equipment

CN121504915BActive Publication Date: 2026-05-29CHINA RAILWAY DESIGN GRP CO LTD +3
View PDF 4 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
CHINA RAILWAY DESIGN GRP CO LTD
Filing Date
2026-01-12
Publication Date
2026-05-29

Smart Images

  • Figure CN121504915B_ABST
    Figure CN121504915B_ABST
Patent Text Reader

Abstract

The application provides a crack detection method and device based on a bounding box guide constraint and electronic equipment, and relates to the technical field of image analysis and processing. The method comprises the following steps: obtaining crack labeling information, the crack labeling information comprising a target bounding box defined on a to-be-detected image and surrounding a target crack, and an artificial anchor point labeled for the target crack; performing dynamic expansion based on the target bounding box to obtain a corresponding background region, and performing adaptive image segmentation based on local contrast analysis of an image region in the target bounding box and the background region to generate a crack segmentation image; extracting at least one high-confidence connected domain from the crack segmentation image as a crack sample according to the artificial anchor point, learning a crack feature model to filter noise of the crack segmentation image, and performing structure optimization and vectorization reconstruction on crack pixels after noise filtering to output a final crack path. The application improves the crack detection accuracy in a complex environment.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image analysis and processing technology, particularly to the field of tunnel appearance recognition technology, and especially to a crack detection method, device, and electronic device based on bounding box guided constraints. Background Technology

[0002] Crack detection is a crucial step in ensuring the safe operation of infrastructure such as bridges, tunnels, and buildings. Digital image-based crack detection is a mainstream technology replacing manual visual inspection. By acquiring images of infrastructure surfaces and analyzing them using computer vision algorithms, automated identification and quantification of crack defects can be achieved. However, due to the complexity of actual engineering environments, the acquired images often differ from samples taken under ideal conditions. Figure 1 As shown, real crack images are usually accompanied by a variety of interference factors such as uneven lighting, shadows, and surface stains. These factors make tiny, blurry cracks easily confused with the background, posing a huge challenge to the accurate identification of automated algorithms.

[0003] Currently, automated crack segmentation and detection technologies are mainly divided into the following two categories:

[0004] Firstly, traditional image processing methods for crack segmentation mainly rely on segmentation operators such as thresholding and edge detection. While these methods allow for flexible parameter adjustments, their adaptability is limited. To obtain better segmentation results for each image, manual parameter adjustments are required for each image repeatedly. This is not only inefficient but also results in poor algorithm robustness, making it difficult to adapt to complex and ever-changing real-world scenarios.

[0005] Secondly, deep learning is used for intelligent recognition, achieving end-to-end pixel-level segmentation through neural network training, adapting to most crack segmentation scenarios. However, neural network models require training on large datasets to improve their generalization ability. Building such datasets is cumbersome and time-consuming. Furthermore, using insufficiently trained models for crack segmentation is prone to false positives or false negatives when encountering novel interferences or tiny cracks, affecting the crack detection results.

[0006] Both of the above-mentioned mainstream technical approaches have inherent flaws that are difficult to overcome. When faced with the requirement of accurate and efficient crack segmentation, and when the dataset is insufficient and the environmental background is complex, both technical approaches have their own shortcomings and are difficult to meet engineering needs. Summary of the Invention

[0007] This invention provides a crack detection method, apparatus, and electronic device based on bounding box guided constraints to address the problem of improving crack detection accuracy when the dataset is insufficient and the environmental background is complex.

[0008] In a first aspect, embodiments of the present invention provide a crack detection method based on bounding box guided constraints, comprising:

[0009] Obtain crack annotation information, which includes: a target bounding box defined on the image to be detected that surrounds the target crack, and at least one artificial anchor point within the target bounding box that annotates the target crack;

[0010] Based on the target bounding box, the corresponding background region is dynamically expanded, and adaptive image segmentation is performed based on the local comparison analysis between the image region within the target bounding box and the background region to generate a crack segmentation image.

[0011] Based on the artificial anchors, at least one high-confidence connected component containing the artificial anchors is extracted from the crack segmentation image as a crack sample, and a crack feature model is learned based on the crack samples.

[0012] The learned crack feature model is used to filter out noise from the crack segmentation image, and the crack pixels after noise filtering are structurally optimized and vectorized for reconstruction to output the final crack path.

[0013] In one possible implementation, the step of dynamically expanding the target bounding box to obtain the corresponding background region includes:

[0014] The dynamic expansion ratio is determined based on the size of the target bounding box; wherein the dynamic expansion ratio is negatively correlated with the size of the target bounding box.

[0015] Based on the dynamic expansion ratio, the region expands outward from the outer edge of the target bounding box to generate a background region corresponding to the target bounding box.

[0016] In one possible implementation, the adaptive image segmentation based on local contrast analysis between the image region within the target bounding box and the background region to generate a crack segmentation image includes:

[0017] Multiple image segmentation algorithms are applied in parallel to the image region and the background region to obtain corresponding binary image segmentation results; wherein, the multiple image segmentation algorithms include two or more of Z-score thresholding, Gaussian adaptive thresholding, Laplacian texture feature segmentation, and Retinex enhanced segmentation; wherein, the Z-score thresholding is based on the image grayscale statistics;

[0018] Calculate the image grayscale statistics for the image region and background region in the binary image segmentation result, respectively; wherein, the image grayscale statistics include the median and robust standard deviation of pixel grayscale values;

[0019] Based on the image grayscale statistics and the artificial anchor points, unsupervised and supervised indicators are determined respectively. Adaptive weights for each binary image segmentation result are determined according to the unsupervised and supervised indicators. Then, image fusion is performed on each binary image segmentation result according to the determined adaptive weights to generate a crack segmentation image.

[0020] In one possible implementation, determining unsupervised and supervised metrics based on the image grayscale statistics and the artificial anchor points, and determining adaptive weights for each binary image segmentation result based on the unsupervised and supervised metrics, includes:

[0021] The local contrast score is determined based on the image grayscale statistics.

[0022] Based on the hit results of the artificial anchor points according to the binary image segmentation results, the constraint factor of the artificial anchor points is determined.

[0023] The adaptive weights of each binary image segmentation result are determined based on the artificial anchor point constraint factor and local contrast score corresponding to each binary image segmentation result.

[0024] In one possible implementation, the local contrast score is calculated as follows:

[0025]

[0026] in, , , , , The original grayscale image corresponding to the binary image segmentation result in coordinates Pixel value at; , These represent the total number of pixels in the image area and the background area, respectively. , These are the average gray levels of the image region and the background region, respectively. , These represent the grayscale variances of the image region and the background region, respectively. It is a very small constant to prevent the denominator from being zero; This is a penalty factor.

[0027] In one possible implementation, the artificial anchor constraint factor is calculated as follows:

[0028]

[0029] in, For artificial anchor recall rate; , A mask generated based on the coordinates of artificial anchor points; To calculate the pixels that hit the artificial anchor point using a bitwise AND operation. ; To count the number of non-zero pixels; The range is [0,1]; Range [0.2, 1.2].

[0030] In one possible implementation, the adaptive weights are calculated as follows:

[0031]

[0032] in, For the first The original comprehensive score of the binary image segmentation result corresponding to each image segmentation algorithm; For the first An image segmentation algorithm is based on the local contrast score determined by the image grayscale statistics; For the first Artificial anchor point constraint factors for the binary image segmentation results of each image segmentation algorithm.

[0033] In one possible implementation, the method further includes: standardizing the adaptive weights of each binary image segmentation result, using the following standardization formula:

[0034]

[0035] in, For the first The original comprehensive score of each algorithm; This represents the total number of image segmentation algorithms. This is the total weight scaling constant, used to maintain order-of-magnitude compatibility with traditional hard threshold logic.

[0036] In one possible implementation, extracting at least one high-confidence connected component containing the artificial anchor as a crack sample from the crack segmentation image based on the artificial anchor includes:

[0037] Locate the pixel position of the artificial anchor point in the crack segmentation image;

[0038] The high-confidence connected components containing the pixel locations are extracted as the crack samples.

[0039] In one possible implementation, the crack feature model includes a width feature model and a direction feature model.

[0040] In one possible implementation, the width feature model learning process includes:

[0041] Calculate the ratio of the area to the perimeter of the connected region corresponding to the crack sample;

[0042] The area and perimeter of the connected region are input into the average width estimation formula to determine the average width estimate, thereby constructing the width feature model.

[0043] The formula for estimating the average width is as follows:

[0044]

[0045] In the formula, Let be the area of ​​the connected region; Let be the perimeter of the connected region.

[0046] In one possible implementation, the directional feature model learning process includes:

[0047] Obtain the set of coordinates of all pixels within the connected component corresponding to the crack sample;

[0048] Principal component analysis is performed on the coordinate set, and the direction of the first principal component is determined as the main direction of the crack sample to construct the direction feature model.

[0049] In one possible implementation, performing principal component analysis on the coordinate set includes:

[0050] Calculate the geometric center of the coordinate set;

[0051] Subtract the coordinates of the geometric center from each coordinate in the coordinate matrix corresponding to the coordinate set to obtain the centered coordinate matrix;

[0052] Construct the covariance matrix of the centered coordinate matrix, and solve for the eigenvectors of the covariance matrix.

[0053] In one possible implementation, the step of filtering noise from the crack segmentation image using the learned crack feature model includes:

[0054] For each candidate connected component in the crack segmentation image, calculate the width feature value and the orientation feature value;

[0055] Obtain the width tolerance range corresponding to the width feature model and the direction tolerance range corresponding to the direction feature model; wherein, the width tolerance range is dynamically determined based on the average width estimate.

[0056] When the width feature value corresponding to the target candidate connected component exceeds the width tolerance range, and / or the direction feature value corresponding to the target candidate connected component exceeds the direction tolerance range, the target candidate connected component is treated as noise and filtered out.

[0057] In one possible implementation, the structural optimization and vectorization reconstruction of the crack pixels after noise filtering includes:

[0058] The skeleton of the crack is obtained by extracting the crack pixel set after noise filtering.

[0059] Under the constraint of directional consistency, the breakpoints in the crack skeleton are connected;

[0060] Curve fitting is performed on the connected crack profile to generate a vectorized crack path.

[0061] Secondly, embodiments of the present invention provide a crack detection device based on bounding box guided constraints, comprising:

[0062] The annotation information acquisition module is used to acquire crack annotation information, which includes: a target bounding box defined on the image to be detected that surrounds the target crack, and at least one artificial anchor point for the target crack within the target bounding box.

[0063] The crack segmentation image acquisition module is used to dynamically expand the target bounding box to obtain the corresponding background region, and perform adaptive image segmentation based on the local comparison analysis between the image region within the target bounding box and the background region to generate a crack segmentation image.

[0064] The crack feature model learning module is used to extract at least one high-confidence connected component containing the artificial anchor from the crack segmentation image as a crack sample, and learn a crack feature model based on the crack sample.

[0065] The crack path output module is used to filter noise from the crack segmentation image using the learned crack feature model, and to perform structural optimization and vectorization reconstruction on the crack pixels after noise filtering, and output the final crack path.

[0066] Thirdly, embodiments of the present invention provide an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the method described in the first aspect or any possible implementation thereof.

[0067] In this embodiment of the invention, crack annotation information including target bounding boxes and artificial anchor points is acquired. First, the background region is dynamically expanded based on the target bounding box. Then, adaptive segmentation is achieved based on local comparison analysis between the region within the target bounding box and the background region. This process avoids the problem of traditional global background analysis being easily affected by distant interference, focusing on the difference between the crack and the direct background to improve segmentation accuracy. Next, high-confidence connected components are extracted as crack samples based on artificial anchor points, ensuring that the samples are real cracks rather than noise, providing a reliable foundation for subsequent feature model learning. Finally, noise is filtered out through the feature model, and the crack pixels are structurally optimized and vectorized for reconstruction. This removes non-crack interference while ensuring the integrity of the crack structure and the standardization of the output results. Overall, it effectively addresses the crack detection needs in scenarios with complex backgrounds and insufficient datasets, achieving accurate and efficient crack extraction. Attached Figure Description

[0068] Figure 1 It is a schematic diagram based on a real crack image shown in a specific embodiment;

[0069] Figure 2 This is an application scenario diagram of a crack detection method based on bounding box guided constraints provided by an embodiment of the present invention;

[0070] Figure 3 This is a flowchart illustrating the implementation of a crack detection method based on bounding box guided constraints according to an embodiment of the present invention.

[0071] Figure 4 This is a human-computer interaction interface for defining target bounding boxes and artificial anchor points, provided in an embodiment of the present invention;

[0072] Figure 5 This is a schematic diagram of an adaptive image segmentation framework provided in an embodiment of the present invention;

[0073] Figure 6 This is a schematic diagram of a self-learning feature filtering mechanism based on artificial anchor points provided in an embodiment of the present invention;

[0074] Figure 7 This is a flowchart illustrating the implementation of a crack detection method based on bounding box guided constraints according to another embodiment of the present invention.

[0075] Figure 8 This is a schematic diagram of the structure of a crack detection device based on bounding box guided constraints provided in an embodiment of the present invention. Detailed Implementation

[0076] The embodiments of the present invention will now be described in detail with reference to the accompanying drawings.

[0077] Figure 2This diagram illustrates an application scenario of the crack detection method based on bounding box guided constraints provided in an embodiment of the present invention. Figure 2 As shown, this scenario focuses on the maintenance and detection of cracks in the concrete lining of bridges, tunnels, and buildings, using industrial cameras and industrial servers as the core hardware. Based on this, the crack rapid detection method based on target bounding box guided constraints provided in this application embodiment is realized, replacing traditional manual inspection and overcoming complex interference problems such as uneven lighting, surface water stains, and joints in tunnels.

[0078] In practice, industrial cameras are fixed to inspection vehicles or designated locations, equipped with adaptive lighting and positioning functions. They acquire real-time images of the lining surface during inspection and transmit them synchronously to an industrial server. The server comes pre-installed with customized inspection software, supporting human-machine interaction and automated algorithm operation. Inspectors use the server interface to mark target bounding boxes and multiple manual anchor points in suspected crack areas, completing a small amount of guided input.

[0079] After receiving the annotation information, the server automatically expands the bounding box to generate associated background regions, constructs a local model based on background grayscale statistics, and achieves accurate segmentation by integrating illumination normalization and adaptive thresholding algorithms. Then, high-confidence crack samples are extracted using manual anchor points, and width and direction feature models are learned to filter out non-crack noise. Finally, through skeleton extraction, breakpoint connection, and curve fitting, vectorized crack paths and related parameters are output.

[0080] Furthermore, during the implementation of this embodiment, the detection results can simultaneously generate a report with location information, which is uploaded to the operation and maintenance platform and backed up locally. This scenario requires only minimal manual guidance to achieve automated and accurate detection of minute cracks, significantly improving detection efficiency and safety, and providing reliable technical support for the safe operation and maintenance of tunnel infrastructure.

[0081] Figure 3 This is a flowchart illustrating the implementation of a crack detection method based on bounding box guided constraints according to an embodiment of the present invention. Figure 3 As shown, it includes the following steps:

[0082] S301, Obtain crack annotation information, which includes: a target bounding box defined on the image to be detected that surrounds the target crack, and at least one artificial anchor point within the target bounding box that annotates the target crack.

[0083] The execution subject of each embodiment of this application can be a server, processor, microprocessor, or other device with data processing capabilities. In actual implementation, the specific implementation method of the execution subject can be selected according to actual needs. This embodiment does not impose any special restrictions on this, as long as it is a device with data processing capabilities.

[0084] like Figure 4The human-computer interaction interface shown allows users to manually define the crack region I1 (i.e., ...) on the image to be inspected. Figure 4 (The area highlighted in red) and artificial anchor points (such as...) Figure 4 (Blue punctuation marks within the red box).

[0085] Traditional crack extraction methods analyze the entire image, making them highly susceptible to interference from background texture and lighting variations. This invention manually selects the crack area and expands the crack region to obtain a background region I2 with extremely high grayscale similarity and correlation to the background. Using background region I2 as a reference, a targeted crack segmentation model is established, focusing on distinguishing subtle differences between the current crack and its most direct background region I2, achieving accurate and robust adaptive segmentation and obtaining preliminary crack segmentation results.

[0086] In the initial crack segmentation results, non-crack noise such as scratches and stains, which are difficult to remove, inevitably remains. Therefore, the human-computer interface meets the requirement of defining artificial anchor points. In actual implementation, artificial anchor points are used to determine high-confidence connected components, and these are used as crack samples to construct a model for noise removal, achieving accurate noise elimination and improving the accuracy of crack extraction.

[0087] S302: Dynamically expand the target bounding box to obtain the corresponding background region, and perform adaptive image segmentation based on the local comparison analysis between the image region within the target bounding box and the background region to generate a crack segmentation image.

[0088] Figure 5 This is a schematic diagram of an adaptive image segmentation framework. Unless otherwise specified, the image region within the target bounding box in this embodiment refers to... Figure 5 Medium crack region I1. Figure 5 The dynamically expanded background region I2 is obtained, and its background information, rather than the global background information of the image, is used as the reference information. This is the key to local adaptive segmentation. By performing a limited and intelligent expansion outward from the tightly surrounding crack region I1, the resulting background region I2 seamlessly connects with the background of the crack region in physical space. According to the principle of spatial correlation of images, the background of this adjacent region has the highest similarity and correlation with the real background of the crack region in terms of texture, grayscale, brightness, and other features.

[0089] Using this highly similar background information as reference, a targeted crack segmentation model is established, creating targeted local standards that effectively ignore background interference from other distant areas, focusing only on distinguishing the subtle differences between the current crack and its most direct background, thus achieving extremely accurate and robust adaptive segmentation. Figure 5As shown, after adaptive image segmentation through local contrast analysis, a preliminary crack segmentation result is obtained, namely the crack segmentation image.

[0090] S303, extract at least one high-confidence connected component containing the artificial anchor from the crack segmentation image as a crack sample, and learn a crack feature model based on the crack sample.

[0091] This step mainly involves using artificial anchor points to determine high-confidence connected components, and using these connected components as crack samples. By performing reverse analysis on these samples, a unique feature model is established for the crack to be detected. Based on this model, feature filtering is performed on all candidate regions of the crack segmentation image, thereby achieving accurate noise removal.

[0092] In this embodiment, an adaptive crack segmentation framework based on local comparative analysis is seamlessly integrated with a self-learning feature filtering mechanism guided by manual anchor points, forming a highly efficient human-machine collaborative mechanism. This mechanism guides the segmentation algorithm to focus on key areas and filters out noise, effectively addressing engineering needs for precise and efficient crack segmentation, even with insufficient datasets and complex environmental contexts. This mechanism guides the algorithm to perform intelligent segmentation with minimal and intuitive human input, achieving an effective balance between accuracy, efficiency, and controllability in crack extraction.

[0093] S304 uses the learned crack feature model to filter out noise from the crack segmentation image, and performs structural optimization and vectorization reconstruction on the crack pixels after noise filtering to output the final crack path.

[0094] After precise filtering, in order to ensure the structural integrity of the crack, it is necessary to further perform a neighborhood search on the endpoints of the remaining crack skeleton and apply directional consistency as a geometric constraint. Connect the breakpoint pairs that meet the structural continuity assumption (i.e. crack pixels after noise filtering) to obtain the crack contour, and reconstruct the processed pixel-level contour into a vectorized path with good smoothness as the final crack path output.

[0095] In this embodiment, the method acquires crack annotation information including target bounding boxes and artificial anchor points. First, it dynamically expands the background region based on the target bounding box. Then, it achieves adaptive segmentation based on local comparison analysis between the region within the target bounding box and the background region. This process avoids the problem of traditional global background analysis being easily affected by distant interference and can focus on the difference between cracks and the direct background to improve segmentation accuracy. Next, it extracts high-confidence connected components as crack samples based on artificial anchor points, which can ensure that the samples are real cracks rather than noise, providing a reliable foundation for subsequent feature model learning. Finally, it filters out noise through the feature model and performs structural optimization and vectorization reconstruction on crack pixels. This removes non-crack interference and ensures the integrity of the crack structure and the standardization of the output results. Overall, it can effectively cope with the crack detection needs in scenarios with complex backgrounds and insufficient datasets, and achieve accurate and efficient crack extraction.

[0096] The above embodiments provide an overview of the overall scheme of the crack detection method based on bounding box guided constraints. The following describes the relevant details.

[0097] In one possible implementation, the corresponding background region is obtained by dynamically expanding the target bounding box, including:

[0098] The dynamic expansion ratio is determined based on the size of the target bounding box; the dynamic expansion ratio is negatively correlated with the size of the target bounding box.

[0099] Based on the dynamic expansion ratio, the background region of the target bounding box is generated by expanding outward from the outer edge of the target bounding box.

[0100] The dynamic expansion ratio is negatively correlated with the size of the target bounding box; that is, the larger the size, the smaller the ratio, and the smaller the size, the larger the ratio, in order to adapt to crack region scenes of different sizes.

[0101] When the target bounding box size is large, a smaller expansion ratio is sufficient to cover a adequate reference background area, avoiding the introduction of excessive irrelevant background interference. When the target bounding box size is small, the expansion ratio needs to be appropriately increased to ensure that the acquired background area contains sufficient local background feature information to meet the needs of subsequent grayscale statistical analysis. Optionally, the system dynamically expands based on the overall size of the crack region I1, and the calculation formula for the expansion ratio is as follows:

[0102]

[0103] In the formula, The length of the short side of the image to be detected is given by the above formula. The above formula ensures that the basic expansion ratio is at least 10% and is dynamically adjusted according to the image size. When the image size is less than 2000 pixels, the expansion ratio will be increased accordingly, up to a maximum of 15%.

[0104] In this embodiment, the method determines a dynamic expansion ratio that is negatively correlated with the size of the target bounding box, and expands outward from the outer edge of the bounding box to generate a background region. When the bounding box size is small, a larger expansion ratio is used, and when the size is large, a relatively smaller expansion ratio is used. This design ensures that the background region is always highly correlated with the crack region within the target bounding box in terms of background features. It avoids both insufficient expansion leading to a lack of background information and excessive expansion introducing irrelevant background interference. This provides a reference region that fits the actual background of the crack for subsequent adaptive segmentation based on local contrast analysis, ensuring the effectiveness and reliability of the background information before segmentation.

[0105] In one possible implementation, adaptive image segmentation is performed based on local contrast analysis between the image region within the target bounding box and the background region to generate a crack segmentation image, including:

[0106] Multiple image segmentation algorithms are applied in parallel to the image region and the background region to obtain the corresponding binary image segmentation results. Among them, the multiple image segmentation algorithms include two or more of Z-score thresholding, Gaussian adaptive thresholding, Laplacian texture feature segmentation, and Retinex enhanced segmentation. Among them, Z-score thresholding is based on image grayscale statistics.

[0107] Calculate the image grayscale statistics for the image region and background region in the binary image segmentation result, respectively; where the image grayscale statistics include the median and robust standard deviation of pixel grayscale values;

[0108] Based on image grayscale statistics and artificial anchor points, unsupervised and supervised indices are determined respectively. Adaptive weights for each binary image segmentation result are determined according to the unsupervised and supervised indices. Then, image fusion is performed on each binary image segmentation result according to the determined adaptive weights to generate a crack segmentation image.

[0109] In a preferred embodiment, the image region and the background region are subjected to Z-score thresholding, Gaussian adaptive thresholding, Laplacian texture feature segmentation, and Retinex enhanced post-segmentation in parallel, that is, four image segmentation algorithms are executed in parallel.

[0110] In practical implementation, due to the complex and variable nature of crack environments, if the result of one of the four image segmentation algorithms differs significantly from the actual result (e.g., an extreme result where the binary image is entirely black or entirely white), the result of the other methods is retained and that method is ignored. In other possible implementations, when crack detection efficiency requirements are stringent, two or three of the four image segmentation algorithms can be selected to adapt to the design efficiency requirements.

[0111] In the specific implementation process, before executing the Z-score thresholding algorithm, the image grayscale statistics of the background region are calculated; among them, the image grayscale statistics include the median and robust standard deviation of pixel grayscale values.

[0112] Since the background region I2 and the crack region's background are seamlessly connected in physical space, according to the principle of spatial correlation of images, this adjacent background region has the highest similarity and correlation with the real background of the crack region in terms of texture, grayscale, and brightness. Therefore, to establish a stable background model that can effectively reflect the local environmental characteristics of the crack region, robust statistical analysis of the grayscale information within the background region I2 is required. The algorithm will calculate the median of the grayscale values ​​of all pixels within this region. and the robust standard deviation of this local background. The latter is defined mathematically as follows:

[0113]

[0114] in, This represents the number of pixels within the background region I2. For the background region I2, the first The pixel value of each pixel.

[0115] as well as Together, they form a dynamic statistical benchmark for the current analysis area, which is used to quantify the significance of crack signals in subsequent steps.

[0116] Among these, the median reflects the core grayscale level of the background area, is less affected by abnormal pixels, and avoids interference from extreme grayscale values ​​on background features. The robust standard deviation quantifies the dispersion of grayscale values ​​in the background area, accurately reflecting the grayscale distribution characteristics of the local background. By combining these two statistics, a local background model that stably reflects the local environmental characteristics of the current crack area can be established, effectively avoiding the influence of interfering factors in the global background such as uneven lighting and distant stains.

[0117] In this process, a local background model is constructed by calculating the median and robust standard deviation of pixel gray values ​​in the background region. Then, based on this model, adaptive segmentation is performed on the region within the target bounding box and the background region. This allows the segmentation process to focus on the gray value difference between the crack and the surrounding direct background, effectively ignoring the interference of distant backgrounds, improving the robustness of adaptive segmentation to complex backgrounds, and reducing segmentation errors caused by mixed background features.

[0118] The process of performing Z-score thresholding on the image region includes: calculating the Z-score of each pixel in the image region based on the image grayscale statistics, and recording pixels with Z-scores less than a set threshold as crack pixels.

[0119] In this embodiment, the Z-score calculation formula for each pixel is:

[0120]

[0121] in, The first image region within the target bounding box The pixel value of each pixel. This is the median of the grayscale values ​​of all pixels within the background area; This represents the robust standard deviation of pixels within the background region.

[0122] Then, binarization is performed in the following manner:

[0123]

[0124] in, To set a threshold, pixels with a Z-score less than or equal to the threshold are marked as 1 and are denoted as crack pixels, while pixels with a Z-score greater than the threshold are marked as 0 and are denoted as non-crack pixels.

[0125] Gaussian adaptive thresholding segmentation of image regions aims to dynamically analyze the gray-level distribution within the local neighborhood of each pixel within the target bounding box, calculate the segmentation threshold adapted to the local region in real time, accurately capture the gray-level boundary between cracks and the background, and ensure that cracks and the background can be accurately distinguished in local scenes with different gray-level distributions. It is suitable for handling scenes with irregular gray-level distribution of cracks.

[0126] In the specific implementation process, the cv2.adaptiveThreshold function is used to complete the Gaussian adaptive thresholding process for image regions.

[0127] The image region is segmented using Laplacian texture enhancement to strengthen the texture features of the crack edges and amplify the difference between the crack and the background in the edge dimension. Then, a threshold screening mechanism is used to retain suspected crack pixels with strong edge features, further focusing on the crack target.

[0128] In practice, the Laplacian operator cv2.Laplacian completes the Laplacian texture enhancement segmentation process for the image region.

[0129] Furthermore, after performing Laplacian texture enhancement segmentation using the `cv2.adaptiveThreshold` function, a bitwise AND operation is performed with the Z-score thresholding result to preserve dark pixels with strong edge features. Specifically, a logical AND operation is performed on the pixel values ​​at the same coordinate positions in the binary image corresponding to the Z-score thresholding result and the binary image after Laplacian texture enhancement segmentation. Then, each pixel is compared and judged, and results that are considered to be cracks in both binary images are retained.

[0130] The core function of Retinex enhancement followed by segmentation is to correct uneven illumination in the image. Addressing common lighting interference in real-world engineering scenarios, the Retinex algorithm can separate the illumination and reflection components of an image region. After illumination enhancement, adaptive threshold segmentation is performed again on the enhanced image to improve crack detection under complex lighting conditions, eliminate interference from uneven illumination, and restore the true grayscale characteristics of the crack.

[0131] In the specific implementation process, through (in The illumination effect is eliminated by applying a Gaussian kernel, and then adaptive thresholding is performed again on the enhanced image. Given the grayscale image matrix of the image to be detected, the estimated illumination component is subtracted from the image to be detected within a logarithmic threshold. This eliminates low-frequency brightness interference caused by shadows and uneven lighting, thereby restoring the true reflection characteristics of the cracks and enabling subsequent segmentation algorithms to work on a uniform brightness benchmark.

[0132] After parallel segmentation using four algorithms, intelligent weighted fusion is performed on the binarized results output by each algorithm. Based on the scene adaptation advantages of each algorithm (e.g., Z-score segmentation adapts to scenes with significant background differences, and Retinex enhanced segmentation adapts to scenes with complex lighting), corresponding weights are assigned to each result. The four binarized results are then weighted and summed to generate a probability map that comprehensively reflects the advantages of each algorithm. Higher pixel values ​​in the probability map indicate a higher confidence level that the pixel represents a crack. Finally, thresholding is applied to transform the probability map into a preliminary binary image of the crack, i.e., the final crack segmentation image. This fusion process effectively compensates for the limitations of a single algorithm, ensuring complete coverage of the crack region while minimizing the intrusion of non-crack noise, providing a high-quality preliminary segmentation foundation for subsequent steps.

[0133] The algorithm executes multiple image segmentation algorithms in parallel, including Z-score thresholding, Gaussian adaptive thresholding, Laplacian texture feature segmentation, and Retinex enhanced segmentation. The results are then weighted and fused to improve the processing efficiency of the algorithm. By combining the advantages of multiple algorithms, the algorithm solves the segmentation deviation caused by uneven illumination, ensuring the integrity of the details of the segmentation results. The final crack segmentation image can still maintain high accuracy even when the illumination is complex or the grayscale difference is small.

[0134] Furthermore, based on image grayscale statistics and manually selected anchor points, unsupervised and supervised metrics were determined to assign adaptive weights to each binary image segmentation result. The supervised metrics, based on the image's inherent features, judge whether the extracted "cracks" and "background" have a significant statistical difference (i.e., whether the cracks are sufficiently dark, the background sufficiently bright, and whether the two are cleanly separated). The supervised metrics, based on user interaction, judge whether the extraction results cover the user-specified anchor points.

[0135] In this embodiment, by executing multiple complementary image segmentation algorithms in parallel and combining unsupervised quality assessment based on local background statistics with supervised intent feedback based on artificial anchors, the system can adaptively assign higher weights to high-quality, high-fit results, dynamically calculate and fuse the results of each algorithm, thereby effectively suppressing noise, preserving the details and continuity of real cracks, and generating crack segmentation images of higher quality.

[0136] In one possible implementation, unsupervised and supervised metrics are determined based on image grayscale statistics and artificial anchor points, respectively. Adaptive weights for each binary image segmentation result are then determined based on these metrics, including:

[0137] Local contrast score is determined based on image grayscale statistics;

[0138] Based on the hit results of the artificial anchor points in the binary image segmentation results, the constraint factors of the artificial anchor points are determined.

[0139] The adaptive weights of each binary image segmentation result are determined based on the artificial anchor point constraint factor and local contrast score corresponding to each binary image segmentation result.

[0140] To assess the salience of the crack, it is necessary to compare the image region with the background region; therefore, a local contrast score is calculated. The formula for calculating the local contrast score is:

[0141]

[0142] in, , , , , The original grayscale image corresponding to the binary image segmentation result in coordinates Pixel value at; , These represent the total number of pixels in the image area and the background area, respectively. , These are the average gray levels of the image region and the background region, respectively. , These are the grayscale variances of the image region and the background region, respectively (reflecting the degree of internal clutter). It is a very small constant to prevent the denominator from being zero; This is a penalty factor.

[0143] In the above calculation formula, the Fisher linear discrimination criterion is used to evaluate the separability of cracks from the background. The better the crack extraction quality, the greater the inter-class distance (mean difference) and the smaller the intra-class divergence (variance sum). This represents the inter-class distance. This algorithm assumes the crack is a dark target, therefore it is generally equal to the background brightness. It must be greater than the crack brightness If the extracted crack area is brighter than the background ( This indicates that specular noise was extracted, and the result is based on the penalty factor. A low score is assigned to the local contrast score. The value represents the intra-class divergence; the smaller the value, the purer the extracted cracks and background.

[0144] The artificial anchor point constraint factor reflects the recall capability of each binary image segmentation result evaluated based on the set of artificial anchor point pixel coordinates D1. The formula for calculating the artificial anchor point constraint factor is:

[0145]

[0146] in, For artificial anchor recall rate, , A mask generated based on the coordinates of the manually generated anchor points (a circular area with the click point as the center and a radius equal to the set spatial tolerance threshold). To calculate the pixels that hit the artificial anchor point using a bitwise AND operation. ; To count the number of non-zero pixels; The range is [0,1]; Range [0.2, 1.2]. Even if it's a complete miss, it assigns a base score of 0.2; if it's a complete miss, it assigns 1.2 times the base score.

[0147] The formula for calculating adaptive weights is:

[0148]

[0149] in, For the first The original comprehensive score of the binary image segmentation result corresponding to each image segmentation algorithm; For the first Artificial anchor point constraint factors for the binary image segmentation results of each image segmentation algorithm.

[0150] In one possible implementation, the method further includes: standardizing the adaptive weights of each binary image segmentation result, using the following standardization formula:

[0151]

[0152] in, For the first The original comprehensive score of each algorithm; For the first An image segmentation algorithm is based on the local contrast score determined by the image grayscale statistics; This represents the total number of image segmentation algorithms. This is the total weight scaling constant, used to maintain order-of-magnitude compatibility with traditional hard threshold logic; in this embodiment, it is set to 5.0.

[0153] In this embodiment, adaptive weights are determined for each binary image segmentation result based on the artificial anchor point constraint factor and local contrast score corresponding to each segmentation result, so that each adaptive weight is automatically adjusted according to the image content. For example, in a uniformly illuminated image, the Z-score algorithm may have a higher local contrast score, and its weight will automatically increase; in an image with complex texture, the Retinex-enhanced algorithm may have a higher score. By introducing... As the denominator, if an image segmentation algorithm extracts a lot of messy noise, resulting in a large variance, the score will be affected. It will be suppressed. An artificial anchor constraint factor is introduced. This constructs a feedback loop between user prior information and algorithm output. By quantifying the coverage of the algorithm results to the user-specified area, the algorithm weight that "hit" the user's intent (i.e., the crack extraction results cover the manual anchor points) is forcibly increased, reducing the missed detection problem that is prone to occur in automated algorithms.

[0154] In one possible implementation, extracting at least one high-confidence connected component containing the artificial anchor as a crack sample from the crack segmentation image based on the artificial anchor includes:

[0155] In the crack segmentation image, locate the pixel position of the artificial anchor point;

[0156] High-confidence connected components containing pixel locations are extracted as crack samples.

[0157] In the actual implementation process, the pixel position of the artificial anchor point is first located in the crack segmentation image, and then the high-confidence connected component containing the pixel position is extracted as the crack sample. Since the artificial anchor point is labeled for the target crack, its pixel position must be closely related to the real crack, and the corresponding connected component is also likely to be the real crack area rather than noise.

[0158] In this embodiment, high-quality crack samples are directly selected, avoiding the introduction of noise as samples into the subsequent feature model learning process. This provides a high-quality data foundation for building an accurate crack feature model and reduces feature model bias caused by sample quality issues.

[0159] In one possible implementation, the crack feature model includes a width feature model and a direction feature model.

[0160] In this embodiment, the crack feature model is defined as including a width feature model and a direction feature model. Width and direction are key morphological features that distinguish cracks from other interfering factors, such as scratches and stains. Specifically, the width feature can differentiate cracks from excessively wide stains or excessively fine scratches, while the direction feature can distinguish the continuous extension of cracks from the irregular distribution of messy stains. By focusing on these two core features to construct the model, clear and targeted judgment criteria can be provided for subsequent noise filtering, avoiding ineffective noise filtering due to ambiguous feature selection, and improving the ability of the subsequent noise filtering process to identify non-crack interference.

[0161] In one possible implementation, the width feature model learning process includes:

[0162] Calculate the ratio of the area to the perimeter of the connected region corresponding to the crack sample;

[0163] The area and perimeter of the connected components are input into the average width estimation formula to determine the average width estimate, thereby constructing a width feature model.

[0164] The formula for estimating the average width is as follows:

[0165]

[0166] In the formula, Let be the area of ​​the connected region; Let be the perimeter of the connected region.

[0167] For a long, narrow connected component (such as a crack), there is an approximate mathematical relationship between its width and the ratio of its area to its perimeter. Approximating the long, narrow crack as a rectangle, the formulas for calculating the area and perimeter of a rectangle are as follows:

[0168]

[0169] in, Let be the area of ​​the connected region; Let be the perimeter of the connected region; The length of the connected component; The width of the connected component.

[0170] Since cracks are generally very long and thin linear defects, their length is much greater than their width, i.e., L >> W. Therefore, the perimeter of the crack can be approximated as P ≈ 2L. Thus, the ratio of the crack's area to its perimeter can be obtained as follows:

[0171]

[0172] Therefore, the crack width characteristics can be quickly derived using an average width estimation method that is computationally efficient and robust to complex shapes:

[0173] .

[0174] In actual implementation, the constructed width feature model can clearly describe the width range of the target crack. During subsequent noise filtering, the model can be used to identify and filter out interferences that exceed the width range, such as excessively wide glue marks or excessively fine fiber impurities, effectively improving the accuracy of filtering width-related noise.

[0175] In this embodiment, since the crack has a thin, linear structure, the ratio of its area to its perimeter can accurately reflect the actual width characteristics, and the average width estimate calculated by the formula can precisely match the width attribute of the target crack.

[0176] In one possible implementation, the directional feature model learning process includes:

[0177] Obtain the set of coordinates of all pixels within the connected component corresponding to the crack sample;

[0178] Principal component analysis is performed on the coordinate set, and the direction of the first principal component is determined as the main direction of the crack sample to construct a directional feature model.

[0179] Among them, cracks, as linear structures, exhibit a clear concentration of pixel coordinates along their extension direction. Principal component analysis (PCA) is primarily used to extract the extension direction of crack samples. The core idea is to construct a new coordinate system to reduce the dimensionality of multidimensional data and extract features. Through coordinate transformation, the dispersed pixel coordinates are mapped to the new coordinate system, where the first coordinate axis (i.e., the first principal component) points in the direction of maximum data variance. For a linearly distributed set of pixels like cracks, the direction of the first principal component is the extension direction of the crack.

[0180] In actual implementation, directional feature models can be used to filter out messy surface stains, glue marks, or watermarks.

[0181] In this embodiment, the constructed directional feature model can accurately capture the continuous extension characteristics of the target crack. During subsequent noise filtering, the model can be used to identify and filter out interference without a fixed extension direction, thereby enhancing the filtering effect of direction-related noise.

[0182] In one possible implementation, principal component analysis is performed on the coordinate set, including:

[0183] Calculate the geometric center of the coordinate set;

[0184] Subtract the coordinates of the geometric center from each coordinate in the coordinate matrix corresponding to the coordinate set to obtain the centered coordinate matrix.

[0185] Construct the covariance matrix of the centered coordinate matrix, and solve for the eigenvectors of the covariance matrix.

[0186] In the principal component analysis (PCA) of the coordinate set, the geometric center is first calculated and the coordinate matrix is ​​centered to eliminate the influence of coordinate position offset on the data distribution analysis, allowing subsequent analysis to focus more on the relative distribution characteristics of pixels. Then, by constructing the covariance matrix of the centered coordinate matrix, the correlation between coordinate data is accurately reflected, and solving the eigenvectors of the covariance matrix can accurately extract the main distribution directions of the data. These progressive steps ensure the accuracy of the PCA process, avoid errors in directional feature extraction due to insufficient data preprocessing or calculation bias, and further guarantee the reliability of the directional feature model.

[0187] In one possible implementation, noise removal of the crack segmentation image is performed using the learned crack feature model, including:

[0188] For each candidate connected component in the crack segmentation image, calculate the width feature value and the orientation feature value;

[0189] Obtain the width tolerance range corresponding to the width feature model and the direction tolerance range corresponding to the direction feature model; wherein, the width tolerance range is dynamically determined based on the average width estimate.

[0190] When the width feature value corresponding to the target candidate connected component exceeds the width tolerance range, and / or the direction feature value corresponding to the target candidate connected component exceeds the direction tolerance range, the target candidate connected component is treated as noise and filtered out.

[0191] In the specific implementation process, firstly, the coordinates of all pixels in the crack sample are extracted (assuming there are n pixels), and a coordinate matrix N is constructed:

[0192]

[0193] Find the geometric center of the point set The entire point set is translated so that its center is located at the origin. The formula for calculating the geometric center is as follows:

[0194]

[0195] Subtract the coordinates of the geometric center from the coordinates of each point to obtain the centered matrix B:

[0196]

[0197] Construct a covariance matrix C to describe the variance of the data across different dimensions and the correlation between dimensions:

[0198]

[0199] The eigenvectors of the covariance matrix point to the directions of the principal components of the data, i.e., the principal directions of the sample cracks. This direction vector is then transformed into a specific angle. The orientation angle of each crack sample. The calculated value is mapped onto the complex plane to obtain the complex average value, and the resulting phase angle is obtained. :

[0200]

[0201]

[0202] in, It is the average of complex numbers.

[0203] With the learned width features and directional features Using this as a template, the present invention performs a consistency check on each independent connected component in candidate graph C. Assume the width feature of each connected component... and directional features Satisfy the following formula:

[0204]

[0205] In the formula, and These are the preset width and direction tolerances, respectively.

[0206] Optionally, the width tolerance range is set to max(0.3, 0.2). This approach dynamically adjusts the tolerance based on changes in crack width (wider cracks correspond to greater tolerance, and narrower cracks to smaller tolerance), while ensuring the algorithm's stability when processing extremely fine cracks. Optionally, the directional tolerance range is set to 23-28 degrees. Preferably, the directional tolerance is set to an experimentally verified empirical value of 25 degrees. This step utilizes dynamically learned features to achieve precise removal of non-crack noise.

[0207] Figure 6 This is a schematic diagram of a self-learning feature filtering mechanism based on artificial anchor points provided in an embodiment of the present invention, combined with... Figure 5 and Figure 6 As shown, based on the local background model, adaptive image segmentation is performed on the image region and background region within the target bounding box, and then... Figure 5 Noise signals are filtered out to obtain the final filtered result.

[0208] In this embodiment, width and orientation feature values ​​are calculated for each candidate connected component in the crack segmentation image. Simultaneously, a dynamic width tolerance range is determined based on the average width estimate, and an orientation tolerance range is determined by combining the orientation feature model. This dynamic width tolerance can be flexibly adjusted according to the actual width of the target crack, avoiding false or missed filtering issues caused by fixed tolerances. When the width or orientation feature value of a candidate connected component exceeds the corresponding tolerance range, it is filtered out as noise. This accurately identifies and removes interference that does not conform to the crack morphology characteristics, significantly reducing false detections and missed detections, and improving the purity of the crack segmentation results.

[0209] In one possible implementation, structural optimization and vectorized reconstruction are performed on the crack pixels after noise filtering, including:

[0210] The skeleton of the crack is obtained by extracting the crack pixel set after noise filtering.

[0211] Under the constraint of directional consistency, the breakpoints in the crack skeleton are connected;

[0212] Curve fitting is performed on the connected crack profile to generate a vectorized crack path.

[0213] In the specific implementation process, the binary crack pixel set after noise filtering is used as input. Following the principle of "not destroying the core extension trend of the crack and not losing key topological nodes", the endpoints, turning points and legal branches of the crack are preserved to avoid structural breakage or accidental deletion of branches due to excessive refinement. At the same time, redundant pixels on the edges in the crack width direction are removed, and finally a thin line skeleton that fits the original crack shape is obtained. The pixels on the skeleton must remain continuous, which not only preserves the geometric features of the crack, but also greatly reduces the data complexity of subsequent processing.

[0214] The skeleton after noise filtering may contain tiny breaks due to discontinuous segmentation, residual noise, or extremely fine cracks. Identify skeleton endpoints, pair breakpoints with similar distances, verify that the local and global directions are consistent and the angle is reasonable by referring to the main crack direction, check the spatial distance for reasonableness, and finally connect the breakpoint pairs that meet the conditions to maintain skeleton continuity.

[0215] After the connection is completed, feature sampling points, including endpoints, inflection points, and uniformity points, are selected using the complete skeleton as input, and the density is adjusted according to the crack morphology. A mathematical curve is generated using a fitting algorithm to match the trend of the sampling points and smooth pixel fluctuations. The final result is a vectorized path, which can be used for engineering applications such as length calculation and width analysis. Optionally, the fitting algorithm can be a polynomial or B-spline.

[0216] In this embodiment, the method extracts the skeleton of the crack pixel set after noise filtering, which can remove redundant pixels while preserving the core extension structure of the crack, simplifying the subsequent processing. Then, under the constraint of directional consistency, the breakpoints in the crack skeleton are connected, which can repair crack fractures caused by segmentation errors or local noise and ensure the integrity of the crack structure. Finally, the connected crack contour is curve fitted to generate a vectorized crack path, which not only eliminates the clutter of pixel-level results, but also facilitates the subsequent quantitative analysis of parameters such as crack length and curvature, improving the practicality and standardization of the detection results.

[0217] Figure 7 This is a schematic diagram of the architecture of a crack detection method based on bounding box guided constraints provided in another embodiment of the present invention, as shown below. Figure 7 The steps shown are as follows:

[0218] First, perform manual bounding box selection and manual anchor point operations on the original image to obtain the image region I1 (i.e., ...) within the target bounding box. Figure 5 The crack region I1) and the set of coordinates of artificial anchor pixel points D1.

[0219] Secondly, the crack region I1 is dynamically expanded to obtain the corresponding background region I2. Then, multiple image segmentation schemes, including Z-score thresholding, Gaussian adaptive thresholding, Laplacian texture feature segmentation, and Retinex enhanced post-segmentation, are applied to the crack region I1 to construct a candidate crack set.

[0220] Then, based on the set of pixel coordinates of artificial anchor points D1, at least one high-confidence connected component containing artificial anchor points is extracted from the candidate crack set as a crack sample, and a crack feature model is learned based on the crack sample to complete the weak labeling of the crack target.

[0221] Finally, based on the weak labeling results of the crack target, structural optimization and vectorization reconstruction are performed to output the final crack path.

[0222] It should be understood that the sequence number of each step in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.

[0223] The following are device embodiments of the present invention. For details not described in detail, please refer to the corresponding method embodiments described above.

[0224] Figure 8 A schematic diagram of the crack detection device based on bounding box guided constraints provided in an embodiment of the present invention is shown. For ease of explanation, only the parts related to the embodiment of the present invention are shown, and are described in detail below:

[0225] like Figure 8 As shown, the crack detection device 8 based on bounding box guided constraints includes:

[0226] The annotation information acquisition module 801 is used to acquire crack annotation information, which includes: a target bounding box defined on the image to be detected that surrounds the target crack, and at least one artificial anchor point within the target bounding box that annotates the target crack.

[0227] The crack segmentation image acquisition module 802 is used to dynamically expand the target bounding box to obtain the corresponding background region, and perform adaptive image segmentation based on the local comparison analysis between the image region within the target bounding box and the background region to generate a crack segmentation image.

[0228] The crack feature model learning module 803 is used to extract at least one high-confidence connected component containing the artificial anchor from the crack segmentation image as a crack sample, and learn the crack feature model based on the crack sample.

[0229] The crack path output module 804 is used to filter noise from the crack segmentation image using the learned crack feature model, and to perform structural optimization and vectorization reconstruction on the crack pixels after noise filtering, and output the final crack path.

[0230] In one possible implementation, the crack segmentation image acquisition module 802 is specifically used for:

[0231] The dynamic expansion ratio is determined based on the size of the target bounding box; the dynamic expansion ratio is negatively correlated with the size of the target bounding box.

[0232] Based on the dynamic expansion ratio, the background region of the target bounding box is generated by expanding outward from the outer edge of the target bounding box.

[0233] In one possible implementation, the crack segmentation image acquisition module 802 is specifically used for:

[0234] Calculate the image grayscale statistics for the background region; where the image grayscale statistics include the median and robust standard deviation of pixel grayscale values;

[0235] Adaptive image segmentation is performed on the image region within the target bounding box based on image grayscale statistics.

[0236] In one possible implementation, the crack segmentation image acquisition module 802 is specifically used for:

[0237] Multiple image segmentation algorithms are applied in parallel to the image region; among them, two or more of the following image segmentation algorithms are used: Z-score thresholding, Gaussian adaptive thresholding, Laplacian texture feature segmentation, and Retinex enhanced segmentation; Z-score thresholding is based on image grayscale statistics.

[0238] The segmentation results from each image segmentation algorithm are weighted and fused to generate a crack segmentation image.

[0239] In one possible implementation, the crack feature model learning module 803 is specifically used for:

[0240] In the crack segmentation image, locate the pixel position of the artificial anchor point;

[0241] High-confidence connected components containing pixel locations are extracted as crack samples.

[0242] In one possible implementation, the crack feature model includes a width feature model and a direction feature model.

[0243] In one possible implementation, the crack feature model learning module 803 is specifically used for:

[0244] Calculate the ratio of the area to the perimeter of the connected region corresponding to the crack sample;

[0245] The area and perimeter of the connected components are input into the average width estimation formula to determine the average width estimate, thereby constructing a width feature model.

[0246] The formula for estimating the average width is as follows:

[0247]

[0248] In the formula, Let be the area of ​​the connected region; Let be the perimeter of the connected region.

[0249] In one possible implementation, the crack feature model learning module 803 is specifically used for:

[0250] Obtain the set of coordinates of all pixels within the connected component corresponding to the crack sample;

[0251] Principal component analysis is performed on the coordinate set, and the direction of the first principal component is determined as the main direction of the crack sample to construct a directional feature model.

[0252] In one possible implementation, the crack feature model learning module 803 is specifically used for:

[0253] Calculate the geometric center of the coordinate set;

[0254] Subtract the coordinates of the geometric center from each coordinate in the coordinate matrix corresponding to the coordinate set to obtain the centered coordinate matrix.

[0255] Construct the covariance matrix of the centered coordinate matrix, and solve for the eigenvectors of the covariance matrix.

[0256] In one possible implementation, the crack path output module 804 is specifically used for:

[0257] For each candidate connected component in the crack segmentation image, calculate the width feature value and the orientation feature value;

[0258] Obtain the width tolerance range corresponding to the width feature model and the direction tolerance range corresponding to the direction feature model; wherein, the width tolerance range is dynamically determined based on the average width estimate.

[0259] When the width feature value corresponding to the target candidate connected component exceeds the width tolerance range, and / or the direction feature value corresponding to the target candidate connected component exceeds the direction tolerance range, the target candidate connected component is treated as noise and filtered out.

[0260] In one possible implementation, the crack path output module 804 is specifically used for:

[0261] The skeleton of the crack is obtained by extracting the crack pixel set after noise filtering.

[0262] Under the constraint of directional consistency, the breakpoints in the crack skeleton are connected;

[0263] Curve fitting is performed on the connected crack profile to generate a vectorized crack path.

[0264] In this embodiment, crack annotation information including the target bounding box and artificial anchor points is acquired. First, the background region is dynamically expanded based on the target bounding box. Then, adaptive segmentation is achieved based on local comparison analysis between the region within the target bounding box and the background region. This process avoids the problem of traditional global background analysis being easily affected by distant interference, focusing on the difference between the crack and the direct background to improve segmentation accuracy. Next, high-confidence connected components are extracted as crack samples based on artificial anchor points, ensuring that the samples are real cracks rather than noise, providing a reliable foundation for subsequent feature model learning. Finally, noise is filtered out through the feature model, and the crack pixels are structurally optimized and vectorized for reconstruction. This removes non-crack interference while ensuring the integrity of the crack structure and the standardization of the output results. Overall, it effectively addresses the crack detection needs in scenarios with complex backgrounds and insufficient datasets, achieving accurate and efficient crack extraction.

[0265] This invention also provides an electronic device, including a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the method described in the above method embodiments. Exemplarily, the electronic device may be a smartphone, tablet computer, laptop computer, desktop computer, smart speaker, smartwatch, etc., and is not limited thereto.

[0266] In the above embodiments, the descriptions of each embodiment have their own emphasis. Parts not detailed or described in a particular embodiment can be referred to in the relevant descriptions of other embodiments. Unless otherwise specified or in conflict with logic, the terminology and / or descriptions between different embodiments are consistent and can be referenced interchangeably. Technical features in different embodiments can be combined to form new embodiments based on their inherent logical relationships.

[0267] The above-described embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included within the protection scope of the present invention.

Claims

1. A crack detection method based on bounding box guided constraints, characterized in that, include: Obtain crack annotation information, which includes: a target bounding box defined on the image to be detected that surrounds the target crack, and at least one artificial anchor point within the target bounding box that annotates the target crack; Based on the target bounding box, the corresponding background region is dynamically expanded, and adaptive image segmentation is performed based on the local comparison analysis between the image region within the target bounding box and the background region to generate a crack segmentation image. At least one high-confidence connected component containing the artificial anchor is extracted from the crack segmentation image as a crack sample based on the artificial anchor, and a crack feature model is learned based on the crack sample; wherein, the crack feature model includes a width feature model and a direction feature model; The learned crack feature model is used to filter out noise from the crack segmentation image, and the crack pixels after noise filtering are structurally optimized and vectorized for reconstruction to output the final crack path. The step of performing adaptive image segmentation based on local contrast analysis between the image region within the target bounding box and the background region to generate a crack segmentation image includes: Multiple image segmentation algorithms are applied in parallel to the image region and the background region to obtain the corresponding binary image segmentation results; Calculate the grayscale statistics of the crack region and the background region in the original grayscale image corresponding to the binary image segmentation result, respectively; wherein, the image grayscale statistics include the grayscale mean and grayscale variance of the pixel grayscale values; Based on the image grayscale statistics and the artificial anchor points, unsupervised and supervised indicators are determined respectively. Adaptive weights for each binary image segmentation result are determined according to the unsupervised and supervised indicators. Then, image fusion is performed on each binary image segmentation result according to the determined adaptive weights to generate a crack segmentation image.

2. The method according to claim 1, characterized in that, The step of dynamically expanding the target bounding box to obtain the corresponding background region includes: The dynamic expansion ratio is determined based on the size of the target bounding box; wherein the dynamic expansion ratio is negatively correlated with the size of the target bounding box. Based on the dynamic expansion ratio, the region expands outward from the outer edge of the target bounding box to generate a background region corresponding to the target bounding box.

3. The method according to claim 1, characterized in that, The various image segmentation algorithms include two or more of the following: Z-score thresholding, Gaussian adaptive thresholding, Laplacian texture feature segmentation, and Retinex enhanced post-segmentation.

4. The method according to claim 3, characterized in that, The process of determining unsupervised and supervised metrics based on the image grayscale statistics and the artificial anchor points, and determining adaptive weights for each binary image segmentation result based on the unsupervised and supervised metrics, includes: The local contrast score is determined based on the image grayscale statistics. Based on the hit results of the artificial anchor points according to the binary image segmentation results, the constraint factor of the artificial anchor points is determined. The adaptive weights of each binary image segmentation result are determined based on the artificial anchor point constraint factor and local contrast score corresponding to each binary image segmentation result.

5. The method according to claim 1, characterized in that, The width feature model learning process includes: Calculate the area and perimeter of the connected region corresponding to the crack sample; The area and perimeter of the connected region are input into the average width estimation formula to determine the average width estimate, thereby constructing the width feature model. The formula for estimating the average width is as follows: In the formula, Let be the area of ​​the connected region; Let be the perimeter of the connected region.

6. The method according to claim 1, characterized in that, The directional feature model learning process includes: Obtain the set of coordinates of all pixels within the connected component corresponding to the crack sample; Principal component analysis is performed on the coordinate set, and the direction of the first principal component is determined as the main direction of the crack sample to construct the direction feature model.

7. The method according to claim 6, characterized in that, The principal component analysis of the coordinate set includes: Calculate the geometric center of the coordinate set; Subtract the coordinates of the geometric center from each coordinate in the coordinate matrix corresponding to the coordinate set to obtain the centered coordinate matrix; Construct the covariance matrix of the centered coordinate matrix, and solve for the eigenvectors of the covariance matrix.

8. A crack detection device based on bounding box guided constraints for performing the method according to any one of claims 1 to 7, characterized in that, include: The annotation information acquisition module is used to acquire crack annotation information, which includes: a target bounding box defined on the image to be detected that surrounds the target crack, and at least one artificial anchor point for the target crack within the target bounding box. The crack segmentation image acquisition module is used to dynamically expand the target bounding box to obtain the corresponding background region, and perform adaptive image segmentation based on the local comparison analysis between the image region within the target bounding box and the background region to generate a crack segmentation image. The crack feature model learning module is used to extract at least one high-confidence connected component containing the artificial anchor from the crack segmentation image as a crack sample, and to learn a crack feature model based on the crack sample. The crack path output module is used to filter noise from the crack segmentation image using the learned crack feature model, and to perform structural optimization and vectorization reconstruction on the crack pixels after noise filtering, and output the final crack path.

9. An electronic device, characterized in that, It includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the method as described in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Landslide boundary and crack labeling method and system based on man-machine cooperation

    CN115578725A

  • Method and system for calculating width of slope crack and rock mass joint crack and medium

    CN118967945A

  • Bridge crack identification and automatic evaluation method based on image identification and AI modeling

    CN120689308A

  • Multi-stage filtering road thrown object detection method based on dynamic difference analysis

    CN120932185A