An ancient building crack identification method and device based on image processing

By calculating the local Otsu threshold and local gray-scale mean within a sliding window to select seed points, and combining region growing and skeletonization processing, the problem of seed point selection being susceptible to noise interference was solved, thus achieving high-precision segmentation and quantitative identification of cracks in ancient buildings.

CN122265224APending Publication Date: 2026-06-23XIAN UNIV OF TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610380601.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-03-26
Publication Date
2026-06-23

AI Technical Summary

Technical Problem

In existing technologies, region growing algorithms based on the local Otsu method are susceptible to noise and background texture interference during crack segmentation, resulting in too many seed points and misselection, which affects segmentation accuracy and computational efficiency.

Method used

By calculating the local Otsu threshold and local grayscale mean within a sliding window, seed points are selected based on dual conditions, and neighboring pixels are accurately merged using a region growing algorithm and skeletonization processing to obtain an accurate crack region.

Benefits of technology

It improves the accuracy and efficiency of crack segmentation, enables quantitative identification of cracks, and allows for the timely detection of potential safety issues in ancient buildings.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122265224A_ABST
    Figure CN122265224A_ABST
Patent Text Reader

Abstract

This invention provides a method and apparatus for identifying cracks in ancient buildings based on image processing, belonging to the field of image processing. The method includes: acquiring a close-up image of cracks in an ancient building; segmenting the cracks using a region growing algorithm combining local Otsu's method and local mean; performing skeletonization processing on the segmented crack regions to obtain a crack skeleton with a single pixel width; and calculating the length and average width of the crack based on the area of ​​the crack region and the size of the crack skeleton, thereby achieving quantitative identification of the crack. This effectively reduces noise and background texture interference, improves the accuracy of seed point selection, and provides a more reliable and accurate technical means for detecting cracks in ancient buildings, helping to promptly identify potential safety issues in ancient buildings.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of image recognition, specifically relating to a method and apparatus for identifying cracks in ancient buildings based on image processing. Background Technology

[0002] Cracks are a key indicator affecting the structural safety and durability of ancient buildings. Accurately detecting parameters such as crack length and width is of great significance for the protection and restoration of ancient buildings. Computer vision-based digital image processing methods, due to their advantages of being non-contact, highly efficient, and highly accurate, have been widely applied in the field of crack detection.

[0003] In crack image segmentation, commonly used methods include Otsu's method and region growing algorithms. Otsu's method divides the image into target and background by calculating a global threshold, offering the advantage of adaptive thresholding. However, it relies on global grayscale statistics and is susceptible to uneven illumination and noise interference, resulting in poor segmentation performance in cracked images of ancient buildings against complex backgrounds. Region growing algorithms, on the other hand, require pre-setting seed points and gradually merge neighboring pixels using grayscale similarity criteria. This approach better preserves the continuity of the crack, but the quality of the seed point selection directly affects the accuracy of the segmentation results.

[0004] Existing technologies combine the local Otsu method with region growing algorithms, using a sliding window to calculate the local Otsu threshold and select seed points to enhance adaptability to local illumination changes. However, this method relies solely on the local Otsu threshold for seed point selection, which presents several problems in practical applications: when the sliding window contains noise or background texture, the local Otsu threshold may misclassify non-crack areas as seed points, resulting in an excessive number and scattered distribution of seed points. This not only increases the computational time of region growing but may also introduce mis-segmented regions, affecting the accuracy of crack extraction. Summary of the Invention

[0005] To address the shortcomings of existing region growing algorithms based on the local Otsu method in crack segmentation, where seed point selection relies solely on the local Otsu threshold and is susceptible to noise and background texture interference, leading to excessive or incorrect seed point selection and consequently affecting segmentation accuracy and computational efficiency, this invention provides an image processing-based method and apparatus for identifying cracks in ancient buildings.

[0006] To achieve the above objectives, the present invention provides the following technical solution: A method for identifying cracks in ancient buildings based on image processing, the method comprising: Obtain close-up images of cracks in ancient buildings; The near-field crack image is traversed using a preset sliding window, and the local Otsu threshold and local gray mean value of each window are calculated respectively. For the center pixel of each window, if its gray value is greater than the local Otsu threshold of the window and the local gray mean value of the window is less than the preset seed point screening threshold, then the center pixel is marked as a seed point. Starting from all marked seed points, pixels whose gray values ​​in their neighborhoods differ from the average gray value of the current seed point region by less than the growth threshold are merged as the current seed point region. The current seed point region is then grown to obtain the segmented crack region. The segmented crack region is skeletonized to obtain a crack skeleton with a width of one pixel. Based on the area of ​​the crack region and the size of the crack skeleton, the length and average width of the crack are calculated to achieve quantitative identification of the crack.

[0007] Optionally, the step of traversing the near-field crack image using a preset sliding window and calculating the local Otsu threshold and local gray-scale mean for each window; for the center pixel of each window, if its gray-scale value is greater than the local Otsu threshold of that window and the local gray-scale mean of that window is less than a preset seed point screening threshold, then marking the center pixel as a seed point includes: Set the sliding window size to 3×3 pixels and traverse the entire enhanced crack image in row-major order. For each window, the local threshold of that window is calculated using Otsu's method. And calculate the average grayscale value of all pixels within the window. ; For the center pixel of the window, if its grayscale value If a preset condition is met, the center pixel is marked as a seed point; the preset condition is: ; in, This is a preset seed point screening threshold used to ensure that seed points are located within the crack area.

[0008] Optionally, starting from all marked seed points, pixels whose grayscale values ​​differ from the average grayscale value of the current seed point region by less than a growth threshold within their neighborhoods are merged to form the current seed point region. The segmented crack region obtained after region growing from the current seed point region includes: Starting from each seed point, the difference between the gray values ​​of its 8 neighboring regions and the average gray value of the current seed point region is less than the growth threshold. The pixels are merged into the current region, and the gray-scale mean of that region is updated, until the absolute value of the difference between the gray-scale value of all remaining pixels in the 8-neighborhood of the current region and the gray-scale mean of the current seed point region is greater than or equal to the growth threshold. In the case of [a specific condition], growth is stopped, resulting in segmented crack regions; wherein, the growth threshold [is specified]. Based on the preset contrast between the crack and the background.

[0009] Optionally, the step of skeletonizing the segmented crack region to obtain a crack skeleton with a single pixel width includes: The Zhang parallel fast thinning algorithm is used to iteratively erode the binarized crack region, deleting boundary pixels that meet specific conditions each time, until a crack skeleton with a width of 1 pixel is obtained.

[0010] Optionally, after obtaining the crack skeleton with a single pixel width, burr removal is also performed on the crack skeleton, including: Traverse the crack skeleton image and identify all nodes and endpoints; a node is a pixel with 3 or more skeleton points in its 8-neighborhood; an endpoint is a pixel with only 1 skeleton point in its 8-neighborhood. Starting from each endpoint, search along the skeleton to the node and count the number of pixels in that branch; If the branch length is less than the preset burr threshold, all pixels of that branch are removed from the skeleton until no new branches are removed, resulting in a burr-free crack skeleton.

[0011] Optionally, calculating the length and average width of the crack based on the area of ​​the crack region and the dimensions of the crack skeleton includes: The total number of pixels in the crack region is used as the area of ​​the crack region. The total number of pixels in the crack skeleton is used as the crack skeleton length. This yields the average width of the crack in pixels. : ; Multiply the average width in pixels by the scale factor The average width of the crack, measured in millimeters, was obtained. : ; Crack length in millimeters Based on the length of the crack skeleton Multiply by the scaling factor get: .

[0012] Optionally, before traversing the close-up crack image with a preset sliding window, the close-up crack image is preprocessed, the preprocessing including grayscale processing, filtering and noise reduction, and contrast enhancement performed sequentially. The grayscale conversion process uses a weighted average method to convert the original RGB image to grayscale, and the grayscale value calculation formula is as follows: ; in, Represents the corresponding pixel after grayscale conversion of an RGB image. grayscale value, , , These represent the corresponding pixels in the three channels of an RGB image. Pixel values; The filtering and denoising uses a mean filter, which traverses the grayscale image with a sliding window of a set size, and replaces the grayscale value of the center pixel of the window with the mean grayscale value of all pixels in the window. The contrast enhancement employs a three-segment linear transformation, dividing the image's grayscale values ​​into three intervals, and using different linear mapping functions to stretch the grayscale difference between the crack and the background.

[0013] A device for identifying cracks in ancient buildings based on image processing, the device comprising: The acquisition module is used to acquire close-up images of cracks in ancient buildings; The filtering module is used to traverse the near-field crack image with a preset sliding window, and calculate the local Otsu threshold and local gray mean of each window respectively; for the center pixel of each window, if its gray value is greater than the local Otsu threshold of the window and the local gray mean of the window is less than the preset seed point filtering threshold, then the center pixel is marked as a seed point. The segmentation module is used to merge pixels whose gray values ​​in their neighborhoods are less than the average gray value of the current seed point region, starting from all marked seed points, as the current seed point region. The current seed point region is then grown to obtain the segmented crack region. The processing module is used to perform skeletonization processing on the segmented crack region to obtain a crack skeleton with a single pixel width. The identification module is used to calculate the length and average width of the crack based on the area of ​​the crack region and the size of the crack skeleton, so as to achieve quantitative identification of the crack.

[0014] The image processing-based method for identifying cracks in ancient buildings provided by this invention has the following beneficial effects: This invention traverses a near-field crack image of an ancient building using a preset sliding window, calculating both the local Otsu threshold and the local gray-scale mean. When selecting seed points, it considers not only the relationship between the central pixel's gray-scale value and the local Otsu threshold but also the comparison between the window's local gray-scale mean and the preset seed point selection threshold. This dual-condition selection effectively reduces noise and background texture interference, avoids excessive seed points and misselection, and improves the accuracy of seed point selection, thereby enhancing subsequent segmentation precision. Using accurately selected seed points as a starting point for region growing allows for more precise merging of neighboring pixels that meet the conditions, resulting in more accurate crack segmentation. The segmented crack region is then skeletonized to obtain a single-pixel-width crack skeleton. Based on this, the crack length and average width are calculated according to the crack area and skeleton size, enabling quantitative crack identification. Overall, this method improves crack segmentation accuracy and computational efficiency, providing a more reliable and accurate technical means for detecting cracks in ancient buildings and helping to promptly identify potential safety issues. Attached Figure Description

[0015] To more clearly illustrate the embodiments and design schemes of the present invention, the accompanying drawings required for this embodiment will be briefly described below. The drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0016] Figure 1 This is a schematic flowchart of an image processing-based method for identifying cracks in ancient buildings according to an exemplary embodiment of the present invention.

[0017] Figure 2 This is a schematic diagram of the main process for crack extraction according to an exemplary embodiment of the present invention.

[0018] Figure 3 This is a schematic diagram of a three-segment linear transformation algorithm provided by the present invention according to an exemplary embodiment.

[0019] Figure 4 This is a schematic diagram of a seed point traversal according to an exemplary embodiment of the present invention.

[0020] Figure 5 This is a schematic diagram of a region growth according to an exemplary embodiment of the present invention, wherein (a) is a pixel label, (b) is the gray value of an 8-neighborhood, and (c) is the growth direction: 10-11-12.

[0021] Figure 6 This is a schematic diagram of a crack skeleton provided by the present invention according to an exemplary embodiment, wherein (a) is a crack before skeletonization and (b) is a crack skeleton after skeletonization.

[0022] Figure 7 This is a flowchart of a burr removal algorithm provided by the present invention according to an exemplary embodiment.

[0023] Figure 8 This is a block diagram of an image processing-based ancient building crack identification device provided by the present invention according to an exemplary embodiment. Detailed Implementation

[0024] To enable those skilled in the art to better understand and implement the technical solutions of the present invention, the present invention will be described in detail below with reference to the accompanying drawings and specific embodiments. The following embodiments are only used to more clearly illustrate the technical solutions of the present invention and should not be construed as limiting the scope of protection of the present invention.

[0025] The technical solutions provided by the various embodiments of the present invention will be described in detail below with reference to the accompanying drawings.

[0026] First, this invention provides a method for identifying cracks in ancient buildings based on image processing, specifically as follows: Figure 1 As shown, it includes the following steps: S101. Obtain a close-up image of the cracks in the ancient building.

[0027] In one embodiment, ignoring the overlap rate, a large number of close-up images can be acquired using close-up photography or a telephoto lens to obtain a close-up image sequence. The close-up image sequence acquired through close-up photography includes unwanted non-crack images. Therefore, a ResNet-34-based transfer learning network is used to identify cracks and non-cracks in the close-up image portion, retaining the crack images to obtain a close-up crack image.

[0028] In this step, the close-up crack image still needs to be preprocessed.

[0029] For example, this preprocessing includes sequential grayscale conversion, filtering and noise reduction, and contrast enhancement. The grayscale conversion uses a weighted average method to perform grayscale conversion on the original RGB image, and the grayscale value calculation formula is as follows:

[0030] ; in, Represents the corresponding pixel after grayscale conversion of an RGB image. grayscale value, , , These represent the corresponding pixels in the three channels of an RGB image. The pixel value.

[0031] This filtering and denoising method uses a mean filter, which traverses the grayscale image with a sliding window of a set size, and replaces the grayscale value of the center pixel of the window with the mean grayscale value of all pixels within the window.

[0032] This contrast enhancement employs a three-segment linear transformation, dividing the image's grayscale values ​​into three intervals, and using different linear mapping functions to stretch the grayscale difference between the crack and the background.

[0033] S102. Traverse the near-field crack image using a preset sliding window, and calculate the local Otsu threshold and local gray-scale mean for each window respectively. For the center pixel of each window, if its gray-scale value is greater than the local Otsu threshold of the window and the local gray-scale mean of the window is less than the preset seed point screening threshold, then mark the center pixel as a seed point.

[0034] In this step, the sliding window size is set to 3×3 pixels, and the entire enhanced crack image is traversed in row-major order; for each window, the local threshold of that window is calculated using Otsu's method. And calculate the average grayscale value of all pixels within the window. For the center pixel of the window, if its grayscale value If a preset condition is met, the center pixel is marked as a seed point; the preset condition is: ; in, This is a preset seed point screening threshold used to ensure that seed points are located within the crack area.

[0035] S103. Starting from all marked seed points, merge pixels whose gray values ​​in their neighborhoods differ from the average gray value of the current seed point region by less than the growth threshold as the current seed point region. The current seed point region is then grown to obtain the segmented crack region.

[0036] In this step, each seed point is taken as the starting point, and the difference between the gray values ​​of its 8 neighboring areas and the average gray value of the current seed point region is less than the growth threshold. The pixels are merged into the current region, and the gray-scale mean of that region is updated, until the absolute value of the difference between the gray-scale value of all remaining pixels in the 8-neighborhood of the current region and the gray-scale mean of the current seed point region is greater than or equal to the growth threshold. In this case, growth stops, resulting in segmented crack regions; where the growth threshold is... Based on the preset contrast between the crack and the background.

[0037] S104. Perform skeletonization processing on the segmented crack region to obtain a crack skeleton with a single pixel width.

[0038] In this step, Zhang's parallel fast thinning algorithm is used to iteratively erode the binarized crack region, deleting boundary pixels that meet specific conditions each time, until a crack skeleton with a width of 1 pixel is obtained.

[0039] In addition, after obtaining the crack skeleton with a single pixel width, burrs are removed from the crack skeleton.

[0040] For example, traverse the crack skeleton image and identify all nodes and endpoints; a node is a pixel with 3 or more skeleton points in its 8-neighborhood; an endpoint is a pixel with only 1 skeleton point in its 8-neighborhood; starting from each endpoint, search along the skeleton to the node and count the number of pixels in the branch; if the branch length is less than a preset burr threshold, delete all pixels of the branch from the skeleton until no new branches are deleted, thus obtaining a burr-free crack skeleton.

[0041] S105. Based on the area of ​​the crack region and the size of the crack skeleton, calculate the length and average width of the crack to achieve quantitative identification of the crack.

[0042] In this step, the total number of pixels in the crack region is counted as the area of ​​the crack region. The total number of pixels in the crack skeleton is used as the crack skeleton length. This yields the average width of the crack in pixels. : ; Multiply the average width in pixels by the scale factor The average width of the crack, measured in millimeters, was obtained. : ; Crack length in millimeters Based on the length of the crack skeleton Multiply by the scaling factor get: .

[0043] Based on the above steps, the present invention also provides an embodiment, such as... Figure 2 As shown, the process includes preprocessing and crack extraction. Preprocessing aims to remove image noise and highlight cracks, thus reducing the difficulty of crack segmentation. Next, crack segmentation is performed, including obtaining a binary crack image using an improved crack segmentation algorithm, extracting crack pixel coordinates, and skeletonizing the crack. Finally, crack-related parameters, including average crack width and length, are extracted based on the crack skeleton.

[0044] The first step is preprocessing, which includes grayscale conversion, filtering and noise reduction, and contrast enhancement.

[0045] Before image processing, since the collected images of cracks in the walls of ancient buildings are mostly color images, they first need to be converted to grayscale images. When processing images with a computer, if RGB images are used, the R, G, and B channels need to be processed separately, which leads to low efficiency and directly affects the crack extraction speed. After grayscale processing, the image information is represented by a single channel without losing detailed information. This invention uses a weighted average method.

[0046] Based on the importance of different channels in the RGB image and other indicators, the R, G, and B channels are assigned weights of 0.299, 0.587, and 0.114 respectively. The weighted average value is then used as the grayscale value of the grayscale image. The specific formula is:

[0047] ; in, Represents the corresponding pixel after grayscale conversion of an RGB image. grayscale value, , , These represent the corresponding pixels in the three channels of an RGB image. The pixel value.

[0048] Ancient buildings are constantly exposed to the outdoors, resulting in noise in the acquired crack images. This noise is useless information, detrimental to crack segmentation and extraction, and may degrade image quality and disrupt the normal extraction of crack features. To remove as much useless noise as possible, preserve the integrity of the cracks, and ensure the accuracy of subsequent crack segmentation and parameter extraction, filtering and denoising are necessary. This invention employs mean filtering, which not only effectively suppresses random noise in the image but also weakens the gradient of pixels in the crack image. Using mean filtering to remove image noise lays the foundation for subsequent crack segmentation.

[0049] Mean filtering is a linear filter in the time domain. It assumes that neighboring pixels in an image are highly correlated spatially, and the gray value of a pixel depends on its own gray value and the gray values ​​of its surrounding pixels. For noise points, because they are relatively independent and prominent, their gray values ​​appear to suddenly increase or decrease. Under this assumption, mean filtering is used to remove pixels with abrupt changes. This involves randomly selecting a pixel and all pixels in its neighboring region using a template, calculating the average value of the pixels in that region, and then replacing the gray value of the selected target point with this average value to remove noise. Let the number of pixels in the template be... ,point The set of neighborhood pixels is grayscale value The grayscale value after mean filtering is Then the following condition is met:

[0050] ; Mean filters are computationally fast, have simple algorithms, are easy to implement, and effectively remove outliers, thereby reducing noise. The template size should be much smaller than the image size, and is generally an odd number, such as a 3×3 or 5×5 rectangle.

[0051] .

[0052] Image contrast enhancement is an image processing technique used to suppress irrelevant information and highlight information of interest for subsequent crack segmentation and extraction. Due to environmental factors such as lighting, images of ancient buildings may exhibit uneven brightness when captured, leading to the loss of crack information during direct processing. To avoid this problem and improve crack segmentation, it is necessary to enhance the contrast between the cracks and the background. This invention employs a three-segment linear transformation algorithm to enhance the contrast of the close-up crack image while suppressing irrelevant background areas to facilitate seed point selection.

[0053] Three-segment linear transformations are the most commonly used type of linear transformation, such as... Figure 3 As shown. The principle is to divide the image grayscale values ​​into three intervals, and then use different linear transformation functions to map the grayscale values ​​of different intervals to the new grayscale intervals, thereby achieving contrast enhancement.

[0054] The three-segment linear transformation function is: ; in , , , As a crucial parameter in the transformation process, it directly determines the effect of the transformed image. , When, the image remains unchanged; when , , At this point, the image becomes thresholded, resulting in the loss of image information. Therefore, it is necessary to set parameters appropriately to preserve the detailed information of the cracks while achieving contrast enhancement.

[0055] Crack parameters are a direct indicator of damage to ancient buildings. Therefore, many scholars have conducted extensive research in the field of crack detection and proposed various methods. In Chapter 3, close-up crack images of the wall and bridge structure have been obtained. To quantitatively identify cracks, this invention first uses an improved region growing algorithm to extract cracks, statistically analyzes the crack pixel coordinates, and performs skeletonization processing on them. Finally, the relevant parameters of the cracks, including average width and length, are calculated.

[0056] Otsu's method is a commonly used image segmentation algorithm that divides an image into background and target using clustering, automatically selecting the threshold that maximizes the inter-class variance as the segmentation threshold. For a close-up image of a crack in an ancient building, the target is the crack, and the rest is the background.

[0057] Otsu's method is used for crack segmentation and can efficiently determine the image binarization segmentation threshold. However, this algorithm is limited by the global threshold and is easily affected by noise. During outdoor shooting, due to the constant environmental influences on ancient buildings, it is difficult to ensure lighting conditions and low noise. Therefore, it is difficult to obtain good segmentation results by using Otsu's method alone.

[0058] Region growing is a region-based image segmentation algorithm that requires three conditions: seed points, growth rules, and stopping conditions. The combination of local Otsu's method and region growing is often used for image segmentation, but it is not well-suited for crack segmentation.

[0059] In region growing algorithms, the selection of seed points directly affects the segmentation results. Too few seed points can lead to incorrect crack segmentation, while too many can result in missegmentation. Using only the local Otsu method to determine an excessive number of seed points results in excessively long growth times. Therefore, a local mean is introduced to constrain the selection of seed points.

[0060] The steps and rules for selecting seed points are as follows: (1) Design a 3×3 window and traverse the entire image in row-major order. See the diagram of seed point traversal as follows. Figure 4 As shown.

[0061] (2) The local threshold of the window is calculated using the Otsu method. and the local grayscale mean of the window. .

[0062] (3) When the center point of each block grayscale value Greater than And the mean of that block Less than the threshold Let the point be the crack point, and let this point be the seed point. The formula is: .

[0063] (4) Traverse the image and repeat steps (2) and (3) to find all seed points.

[0064] pass By restricting the selection location of seed points to be within the crack area, the chances of seed points being selected as noise points are reduced, thereby reducing the growth time.

[0065] The growth rules and stopping conditions for regional growth are as follows: ; in, The average gray value of the merged region after growth. This represents the grayscale values ​​of the remaining pixels in the already traversed region. The grayscale threshold difference that stops growth. A schematic diagram of the growth process is shown below. Figure 5 As shown, (a) represents the pixel number, (b) represents the grayscale value of the 8-neighborhood, and (c) represents the growth direction: 10-11-12. The process includes the following steps:

[0066] (1) Based on the gray value of the selected seed point 1, statistically analyze the value of each point in the eight neighborhoods and compare it with the seed point. Select the point 8 with a gray value close to that of the seed point and add it to the segmentation region.

[0067] (2) Calculate the average gray value of the segmented regions (point 1 and point 8) as the new benchmark.

[0068] (3) Point 8 is used as a new seed point for searching, and the search area is all the areas that have been browsed.

[0069] (4) Repeat (2) and (3) until the difference between the new seed point and the mean of the already segmented regions exceeds the set threshold. Growth stops.

[0070] (5) Repeat steps (1) to (4) for all selected seed points to complete the crack segmentation.

[0071] The width and length of cracks play a crucial role in assessing their severity and potential harm to cultural relics, making them essential parameters in crack detection. Obtaining a crack skeleton requires first acquiring a binarized crack image. Then, specific points are deleted while preserving the crack's shape and continuity. Finally, burrs are removed to obtain a single-pixel width crack skeleton. Illustrations before and after skeletonization are shown below. Figure 6 As shown, (a) is the crack before skeletonization, and (b) is the crack skeleton after skeletonization.

[0072] After extracting the binarized crack image, this invention employs Zhang's parallel fast thinning algorithm to thin the crack image and extract the crack skeleton. The algorithm works by setting conditions to erode target points that meet those conditions. These conditions include retaining endpoints and removing edge points that would alter the connectivity of connected components. This step is repeated until the target crack becomes thinner and no new target points are eroded.

[0073] However, the obtained crack skeleton contains multiple burrs in addition to the desired main skeleton, and these burr branches affect the accuracy of crack parameter calculation. Therefore, the refined crack skeleton needs further processing, namely, burr removal, to obtain the final single-pixel width, burr-free crack skeleton. The burr removal algorithm flow of this invention is as follows: Figure 7 As shown.

[0074] First, a scan is performed from the nodes or endpoints to count the lengths of each branch from the endpoint to the node. Then, branches that meet the criteria are deleted. Setting appropriate thresholds can effectively ensure the integrity of crack information while removing burrs. The nodes, endpoints, and branch lengths are defined as follows: a node is a point with 3 or more pixels in its 8-neighborhood; an endpoint is a point with only 1 pixel in its 8-neighborhood; and the branch length is the number of pixels from the branch node to the endpoint.

[0075] The burr removal process of this invention includes the following steps: (1) Traverse the image, count and record the coordinates of the skeleton nodes and endpoint pixels, and denote them as sets. and set .

[0076] (2) Perform a scan search starting from each endpoint and count the number of pixels in each branch. .

[0077] (3) Set the burr removal threshold and count the number of pixels obtained. Compared with this threshold, if If the value is less than the threshold, the branch is removed and the deleted node is restored.

[0078] (4) Update the set of nodes and endpoints and determine whether the set has been updated. If it has been updated, skip to step (2).

[0079] (5) The set of nodes and endpoints no longer changes, output the skeleton, and the process ends.

[0080] Crack parameters include crack width and length. In the conservation of ancient buildings, width and length play a crucial role in assessing the severity of cracks and their potential harm to cultural relics. They are important parameters in crack detection and also serve as important reference indicators for subsequent cultural relic restoration.

[0081] There are various algorithms for calculating crack width parameters, including centerline-based crack width methods, average crack width methods, and grayscale-based crack width methods. Given the narrow and elongated nature of cracks, this invention uses the more stable average crack width method. This algorithm, due to its averaging calculation process, can identify cracks with high resolution. Crack length parameters are obtained by calculating the crack skeleton length.

[0082] The calculation method for the average crack width is as follows: The average width of the crack is calculated by dividing the crack closure area by the crack centerline length. The crack closure areas are then calculated separately. and crack skeleton length Then the average width of the crack can be obtained. :

[0083] ; Multiply this by a scaling factor. The physical size of a pixel is the ratio of the crack width in pixels to the crack width in millimeters, expressed in mm / pixel, and is obtained from a target of known size. The final average crack width is expressed in millimeters. The final formula is:

[0084] ; The crack length is directly calculated by counting the number of pixels in the crack skeleton and multiplying it by a scale factor. This is the final crack length. : .

[0085] Using the above method, by traversing the near-field crack image of an ancient building through a preset sliding window, the local Otsu threshold and local gray-level mean are calculated respectively. When selecting seed points, not only is the relationship between the gray value of the center pixel and the local Otsu threshold considered, but also the comparison between the local gray-level mean of the window and the preset seed point selection threshold is combined. This dual-condition selection can effectively reduce noise and background texture interference, avoid excessive seed points and misselection, improve the accuracy of seed point selection, and thus improve the subsequent segmentation accuracy. Using the accurately selected seed points as the starting point for region growing, neighboring pixels that meet the conditions can be merged more accurately, resulting in more accurate segmentation of the crack region. The pixel coordinates of the segmented crack region are extracted and skeletonized to obtain a single-pixel width crack skeleton. Based on this, the crack length and average width are calculated according to the crack region area and the skeleton size, enabling quantitative identification of cracks. Overall, this method improves the crack segmentation accuracy and computational efficiency, providing a more reliable and accurate technical means for crack detection in ancient buildings, and helping to promptly discover potential safety problems in ancient buildings.

[0086] In addition, the present invention has been experimentally verified.

[0087] The seed point selection rule and region growing method of this invention are used to segment the close-up image identified as a crack. The segmented crack image ensures the integrity of the crack to the maximum extent. The segmentation result shows that the crack is white. Based on this, the pixel coordinates of the white pixels are counted, and then the length and average width of the crack are extracted.

[0088] After crack segmentation, Zhang's parallel fast refinement algorithm is used to extract the crack skeleton, and the burr removal algorithm of this invention is used to remove redundant branches. The number of pixels in the coarse crack skeleton is counted as follows. The length from the endpoint to the node is Since the burr length is much smaller than the main branch length, the branch length threshold is set to 1 / 40 of the total number of pixels. If the branch is not specified, then that branch is removed. After the thinning algorithm, redundant branches have been removed, and only the main skeleton of the crack with a width of one pixel is retained. The crack parameters calculated based on this skeleton are closer to the actual size.

[0089] To verify the accuracy of the crack parameters obtained from digital image processing, a vernier caliper with an accuracy of 0.02 mm was used on-site to measure the crack width at different crack locations on the bridge structure, and the average width was calculated to be 3.60, which was taken as the true value.

[0090] When photographing the wall and bridge, the camera's scale factor was 0.3689 mm / pixel and 0.1585 mm / pixel respectively after on-site calibration. After crack identification, one close-up image with a crack was obtained for each. The crack parameters are shown in Table 1 using the aforementioned calculation method.

[0091] Table 1 Crack parameters Tables 2 and 3 show the average width error of cracks in the bridge structure. = 0.04 mm, this error mainly comes from caliper error. = 0.02 mm and image processing error ,in To address pixel errors in image processing, = 0.1585 mm / pixel is the scale factor, and it satisfies the following formula: ; The pixel error in image processing can be calculated from the above formula. Approximately 0.2 pxiel. In field measurements, due to the excessive height of the wall, it was difficult to measure the crack width; therefore, the camera's scale factor was adjusted when measuring the wall surface. Substituting 0.3689 mm / pixel into the above formula, we can estimate that the average width error of the wall crack is 0.07 mm.

[0092] The results show that the accuracy of the cracks in the bridge and walls detected by machine vision is better than 0.1 mm, which meets the engineering inspection requirements according to the technical specifications.

[0093] Secondly, the present invention also provides an image processing-based device for identifying cracks in ancient buildings, such as... Figure 8As shown, it includes: The acquisition module is used to acquire close-up images of cracks in ancient buildings.

[0094] The filtering module is used to traverse the near-field crack image with a preset sliding window, and calculate the local Otsu threshold and local gray-scale mean for each window respectively. For the center pixel of each window, if its gray-scale value is greater than the local Otsu threshold of the window and the local gray-scale mean of the window is less than the preset seed point filtering threshold, then the center pixel is marked as a seed point.

[0095] The segmentation module is used to merge pixels whose gray values ​​in the neighborhood of all marked seed points are less than the gray value of the current seed point region with a growth threshold as the starting point. The current seed point region is then grown to obtain the segmented crack region.

[0096] The processing module is used to perform skeletonization processing on the segmented crack region to obtain a crack skeleton with a single pixel width.

[0097] The identification module is used to calculate the length and average width of the crack based on the area of ​​the crack region and the size of the crack skeleton, thereby achieving quantitative identification of the crack.

[0098] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0099] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, as well as combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0100] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0101] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0102] It should be noted that the specific embodiments described above enable those skilled in the art to more fully understand the present invention, but do not limit the present invention in any way. Therefore, although the present invention has been described in detail in this specification, those skilled in the art should understand that modifications or equivalent substitutions can still be made to the present invention; and all technical solutions and improvements that do not depart from the spirit and scope of the present invention are covered within the protection scope of the patent of the present invention. No reference numerals in the claims should be construed as limiting the scope of the claims.

Claims

1. A method for identifying cracks in ancient buildings based on image processing, characterized in that, The method includes: Obtain close-up images of cracks in ancient buildings; The near-field crack image is traversed using a preset sliding window, and the local Otsu threshold and local gray mean value of each window are calculated respectively. For the center pixel of each window, if its gray value is greater than the local Otsu threshold of the window and the local gray mean value of the window is less than the preset seed point screening threshold, then the center pixel is marked as a seed point. Starting from all marked seed points, pixels whose gray values ​​in their neighborhoods differ from the average gray value of the current seed point region by less than the growth threshold are merged as the current seed point region. The current seed point region is then grown to obtain the segmented crack region. The segmented crack region is skeletonized to obtain a crack skeleton with a width of one pixel. Based on the area of ​​the crack region and the size of the crack skeleton, the length and average width of the crack are calculated to achieve quantitative identification of the crack.

2. The method according to claim 1, characterized in that, The step of traversing the near-field crack image using a preset sliding window, calculating the local Otsu threshold and local gray-scale mean for each window; for the center pixel of each window, if its gray-scale value is greater than the local Otsu threshold of that window and the local gray-scale mean of that window is less than a preset seed point screening threshold, then marking the center pixel as a seed point includes: Set the sliding window size to 3×3 pixels and traverse the entire enhanced crack image in row-major order. For each window, the local threshold of that window is calculated using Otsu's method. And calculate the average grayscale value of all pixels within the window. ; For the center pixel of the window, if its grayscale value If a preset condition is met, the center pixel is marked as a seed point; the preset condition is: ; in, This is a preset seed point screening threshold used to ensure that seed points are located within the crack area.

3. The method according to claim 1, characterized in that, Starting from all marked seed points, pixels whose grayscale value differs from the average grayscale value of the current seed point region by less than a growth threshold within their neighborhood are merged to form the current seed point region. The segmented crack region obtained after region growing from the current seed point region includes: Starting from each seed point, the difference between the gray values ​​of its 8 neighboring regions and the average gray value of the current seed point region is less than the growth threshold. The pixels are merged into the current region, and the gray-scale mean of that region is updated, until the absolute value of the difference between the gray-scale value of all remaining pixels in the 8-neighborhood of the current region and the gray-scale mean of the current seed point region is greater than or equal to the growth threshold. In the case of [a specific condition], growth is stopped, resulting in segmented crack regions; wherein, the growth threshold [is specified]. Based on the preset contrast between the crack and the background.

4. The method according to claim 1, characterized in that, The process of skeletonizing the segmented crack region to obtain a crack skeleton with a single pixel width includes: The Zhang parallel fast thinning algorithm is used to iteratively erode the binarized crack region, deleting boundary pixels that meet specific conditions each time, until a crack skeleton with a width of 1 pixel is obtained.

5. The method according to claim 4, characterized in that, After obtaining the crack skeleton with a single pixel width, burr removal is also performed on the crack skeleton, including: Traverse the crack skeleton image and identify all nodes and endpoints; a node is a pixel with 3 or more skeleton points in its 8-neighborhood; an endpoint is a pixel with only 1 skeleton point in its 8-neighborhood. Starting from each endpoint, search along the skeleton to the node and count the number of pixels in that branch; If the branch length is less than the preset burr threshold, all pixels of that branch are removed from the skeleton until no new branches are removed, resulting in a burr-free crack skeleton.

6. The method according to claim 1, characterized in that, The step of calculating the length and average width of the crack based on the area of ​​the crack region and the dimensions of the crack skeleton includes: The total number of pixels in the crack region is used as the area of ​​the crack region. The total number of pixels in the crack skeleton is used as the crack skeleton length. This yields the average width of the crack in pixels. : ; Multiply the average width in pixels by the scale factor The average width of the crack, measured in millimeters, was obtained. : ; Crack length in millimeters Based on the length of the crack skeleton Multiply by the scaling factor get: 。 7. The method according to claim 1, characterized in that, Before traversing the near-field crack image with a preset sliding window, the near-field crack image is preprocessed, which includes grayscale processing, filtering and noise reduction, and contrast enhancement performed sequentially. The grayscale conversion process uses a weighted average method to convert the original RGB image to grayscale, and the grayscale value calculation formula is as follows: ; in, Represents the corresponding pixel after grayscale conversion of an RGB image. grayscale value, , , These represent the corresponding pixels in the three channels of an RGB image. Pixel values; The filtering and denoising uses a mean filter, which traverses the grayscale image with a sliding window of a set size, and replaces the grayscale value of the center pixel of the window with the mean grayscale value of all pixels in the window. The contrast enhancement employs a three-segment linear transformation, dividing the image's grayscale values ​​into three intervals, and using different linear mapping functions to stretch the grayscale difference between the crack and the background.

8. A device for identifying cracks in ancient buildings based on image processing, characterized in that, The device includes: The acquisition module is used to acquire close-up images of cracks in ancient buildings; The filtering module is used to traverse the near-field crack image with a preset sliding window, and calculate the local Otsu threshold and local gray mean of each window respectively; for the center pixel of each window, if its gray value is greater than the local Otsu threshold of the window and the local gray mean of the window is less than the preset seed point filtering threshold, then the center pixel is marked as a seed point. The segmentation module is used to merge pixels whose gray values ​​in their neighborhoods are less than the average gray value of the current seed point region, starting from all marked seed points, as the current seed point region. The current seed point region is then grown to obtain the segmented crack region. The processing module is used to perform skeletonization processing on the segmented crack region to obtain a crack skeleton with a single pixel width. The identification module is used to calculate the length and average width of the crack based on the area of ​​the crack region and the size of the crack skeleton, so as to achieve quantitative identification of the crack.