Dangerous rock crack width measuring method based on edge minimum width method
The Euclidean distance between crack edge pixels is directly calculated by the minimum edge width method, which solves the problems of high algorithm complexity and noise sensitivity in the existing technology and realizes efficient and stable crack width measurement.
Patent Information
- Application Number
- CN202510782401.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-12
- Publication Date
- 2025-09-23
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Existing crack width measurement methods have high algorithm complexity, are sensitive to noise, and have poor robustness, resulting in unstable calculations.
The minimum edge width method is adopted to directly calculate the minimum Euclidean distance between edge pixels, avoiding the use of skeleton extraction, simplifying the algorithm and improving noise resistance.
The calculation efficiency and accuracy of crack width measurement are significantly improved, noise interference is reduced, and the calculation results are not affected by the crack direction.
Smart Images

Figure CN120689385A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to computer vision and image processing technology, and in particular to a dangerous rock crack width measurement method based on an edge minimum width method. Background Art
[0002] Cracks are a key factor in rockfall collapses. Currently, the most commonly used collapse monitoring methods are surface instrumentation and physical quantity monitoring. However, traditional identification and measurement of rockfall cracks relies on manual on-site observation. Rockfalls often occur in areas with complex terrain and hazardous environments. Therefore, using machine vision instead of manual labor can enable safer and more efficient intelligent identification and measurement of rockfall cracks.
[0003] Existing crack width measurement methods rely on extracting the crack skeleton line, such as the medial axis transformation, and determining the width by calculating the distance between the two edges along the skeleton line. However, such methods have the following problems:
[0004] (1) High algorithm complexity: Skeleton extraction requires multiple steps, which is computationally intensive and time-consuming;
[0005] (2) Sensitive to noise: The skeleton is easily affected by crack branching or fracture, resulting in unstable width calculation;
[0006] (3) Poor robustness: Extremely small noise, such as the noise produced by binarization, will significantly interfere with the measurement results. Summary of the Invention
[0007] Purpose of the invention: In response to the above problems, the purpose of the present invention is to provide a dangerous rock crack width measurement method based on the minimum edge width method, which realizes crack width measurement by directly calculating the minimum Euclidean distance between edge pixels, significantly improving the noise resistance, stability and efficiency of the algorithm.
[0008] Technical solution: The method for measuring the width of dangerous rock cracks based on the minimum edge width method of the present invention comprises the following steps:
[0009] Obtain dangerous rock crack images and generate binary images after preprocessing;
[0010] Extract crack edges based on the binary image, determine edge pixels and store edge pixel information as a matrix;
[0011] Find the preset direction based on the 8-neighborhood and obtain the middle direction among the preset directions;
[0012] Traverse the edge pixel set on the opposite side, find the effective width between edge pixels, and obtain a width list;
[0013] Optimize the width list and calculate the average width of the cracks;
[0014] Calculate the actual width of dangerous rock cracks based on the average width.
[0015] Furthermore, the steps of extracting crack edges based on the binary image, determining edge pixels, and storing edge pixel information as a matrix include:
[0016] The matrix corresponding to the crack binary image is denoted as M B ;
[0017] Detection matrix M B The pixel value of each pixel in the , determines whether the pixel value at the current pixel is greater than 0. If it is greater than 0 and there is at least one background pixel in the 4 neighboring pixels of the current pixel, the current pixel is considered to be an edge pixel;
[0018] The detection results are stored in the edge pixel matrix M E In the edge pixel matrix M E The elements corresponding to edge pixels are set to 255, otherwise they are set to 0.
[0019] Furthermore, the step of searching for a preset direction based on the 8-neighborhood includes:
[0020] For the matrix M B For each pixel on the edge, compare the sizes of the two centrosymmetric pixels in the neighborhood of pixel point P0. If the values of the matrix elements corresponding to the two pixels are different, then the direction from pixel point P0 to the pixel with a value of 255 is determined to be the preset direction. The neighborhood of pixel point P0 is looped until all the preset directions in which pixel point P0 exists are found.
[0021] Let pixel point P0 to pixel point P i The direction is d i , then for all preset directions d i The following three conditions must be met at the same time, and all d i A list D of preset directions stored as edge pixels:
[0022] Condition 1: 1≤i≤8;
[0023] Condition 2: Pixel P i The pixel value V(P i )>0;
[0024] Condition 3: When i≤4, the pixel value V(P i+4 )=0, or when i≥5, the pixel value V(P i-4 )=0.
[0025] Furthermore, the step of obtaining an intermediate direction in the preset directions includes:
[0026] For a preset direction list D, if the number of elements in the list is greater than 1, adjust the elements in the list so that adjacent preset directions in the list are logically adjacent. For the i-th preset direction in the list, determine whether the following condition is satisfied: When 1 ≤ i < m, D i -D i-1 > 1. If this condition is satisfied, move the element at the end of the list to the beginning of the list, where n is the size of the list, and D i represents the i-th preset direction in the list. The judgment starts from i = 1 and increments until i = n - 1;
[0027] Take the median of the adjusted list D as the middle direction D in the preset directions mid .
[0028] Furthermore, the steps of traversing the opposite-side edge pixel set to find the effective width between edge pixel points and obtaining the width list include:
[0029] For each pixel point (x s , y s ) on the edge, traverse all preset directions D in the adjusted preset direction list D i , find the opposite-side edge pixel points, use the middle direction D mid as the starting point for traversing the width calculation, calculate the Euclidean distance between the two points as the width value w of this edge pixel point. If the minimum width value w min does not exist, then use w as the initial value of w min ;
[0030] Find the un-traversed edge pixel points in the neighborhood of the starting point of traversal, and calculate the Euclidean distance from the pixel point (x s , y s ). Update the minimum width value w<00,00026>, y s ) of this edge pixel point, and continue to find un-traversed edge pixels for cycling until no un-traversed edge pixel points can be found; min Set a threshold coefficient δ. During the cycling process, if w > w[[ID=,43]]
[0031] * δ is satisfied, then interrupt the traversal of the direction D min and continue to traverse the remaining un-traversed preset directions; i If the minimum width value is 0, then determine that the pixel point (x
[0032] [[ID=,52]] s , y, y s ) does not have an effective width, that is, determine that the pixel point (x s , y s ) is noise and discard the pixel point (x s , y s );
[0033] The minimum effective width w min As the edge pixel of this face (x s ,y s ) and store the pixel coordinates and width value in the width list R.
[0034] Furthermore, the steps of optimizing the width list and calculating the average width of the cracks include:
[0035] Taking the width value as the standard, the maximum value and the minimum value of ε% in the width list R are eliminated, 1<ε<6, and the optimized width list W is obtained. The average value of all width values in the width list W is calculated and the average value is used as the average width of dangerous rock cracks.
[0036] Furthermore, the step of calculating the actual width of the dangerous rock crack according to the average width includes:
[0037] According to the corner point list C, the proportional conversion relationship γ between the crack pixels and the actual size is calculated, and the average width is converted into the actual width set W according to the proportional conversion relationship r =W·γ.
[0038] Furthermore, the steps of obtaining the dangerous rock crack image and generating a binary image after preprocessing include:
[0039] The dangerous rock crack image was amplified, contrast adjusted and bilaterally filtered using bilinear interpolation to denoise the image while retaining edge sharpness. The processed crack image was converted into a binary image using threshold binarization.
[0040] Beneficial effects: Compared with the prior art, the present invention has the following significant advantages:
[0041] (1) The present invention calculates the width between crack edges, avoids the algorithm complexity and error caused by using a thinning algorithm to extract the central axis, and simplifies the algorithm process;
[0042] (2) The traversal method and judgment conditions of the present invention result in a situation where the width value is 0 during the calculation process. This point is automatically judged as noise and discarded, which can effectively avoid the influence of noise and has strong robustness to noise, greatly improving the calculation accuracy of the algorithm for crack width in complex environments;
[0043] (3) The edge search process of the present invention is independent of the crack direction, and no additional processing such as rotation of the crack image is required. The calculation result of the crack width is almost unaffected by the crack direction. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] Figure 1 This is a flow chart of the dangerous rock crack width measurement method based on the minimum edge width method;
[0045] Figure 2 Schematic diagram of detecting cracks and checkerboard corners;
[0046] Figure 3 It is a schematic diagram of eight neighborhoods;
[0047] Figure 4 This is a schematic diagram for judging the preset direction and the intermediate direction;
[0048] Figure 5 This is a schematic diagram of the minimum width calculation principle;
[0049] Figure 6 Schematic diagram of crack detection, binarization and edge extraction results;
[0050] Figure 7 Schematic diagram of width measurement results. DETAILED DESCRIPTION
[0051] In order to make the purpose, technical solutions and advantages of this application more clear, this application is further described in detail below with reference to the accompanying drawings and embodiments.
[0052] The method for measuring the width of dangerous rock cracks based on the minimum edge width method described in this embodiment is as follows: Figure 1 As shown, the measurement method includes the following steps:
[0053] Step 1: Obtain the dangerous rock crack image and generate a binary image after preprocessing.
[0054] Obtain the image of dangerous rock cracks and preprocess it. Use bilinear interpolation to amplify the image of dangerous rock cracks, adjust the contrast and perform bilateral filtering. Denoise the image while retaining edge sharpness. Use threshold binarization to convert the processed crack image into a binary image with the crack area white and the background black.
[0055] Combine Figure 2 , place a 5×5 chessboard next to the crack, take a picture of the dangerous rock to obtain the crack image, use the trained YOLOv10s target detection model to identify the crack in the image, separate the rectangular box where the crack is located from the image, and form an independent crack image. Grayscale the original crack image, use the Harris corner detection algorithm to detect the corner points of the chessboard in the image, and store the sub-pixel coordinates (x C ,y C ), get a 4×4 corner point list C, use C in the list i,jDenotes the corner point at row i and column j. The resulting crack image is amplified by a factor of 2 in both length and width using bilinear interpolation, and the contrast is adjusted to 1.4. A bilateral filter is used to remove noise while preserving edge sharpness. The processed crack image is converted into a binary image using a binarization algorithm, with the crack area being white (non-zero value) and the background being black (zero value).
[0056] Step 2: Extract the crack edge based on the binary image, determine the edge pixel points and store the edge pixel information as a matrix.
[0057] Furthermore, the steps of extracting crack edges based on the binary image, determining edge pixels, and storing edge pixel information as a matrix include:
[0058] The matrix corresponding to the crack binary image is denoted as M B ;
[0059] Detection matrix M B The pixel value of each pixel in the , determines whether the pixel value at the current pixel is greater than 0. If it is greater than 0 and there is at least one background pixel in the 4 neighboring pixels of the current pixel, the current pixel is considered to be an edge pixel;
[0060] The detection results are stored in the edge pixel matrix M E In the edge pixel matrix M E The elements corresponding to edge pixels are set to 255, otherwise they are set to 0.
[0061] like Figure 3 The figure shows the eight neighborhoods of point P0(i,j), where the eight neighborhoods are represented by points P1, P2, P3, P4, P5, P6, P7, and P8. Figure (a) shows the original eight neighborhoods, Figure (b) shows the eight neighborhoods of non-edge pixels, and Figure (c) shows the eight neighborhoods of edge pixels. In this example, a simplified edge extraction method based on binary images is used, using V(P i ) represents point P i If V(P0)>0 and there is at least one background pixel in its four neighboring pixels, that is, V(P1)·V(P3)·V(P5)·V(P7)=0, the current pixel point P0 is considered to be an edge pixel point, and the search for pixels that have not been traversed in its neighborhood is continued. The traversal results are stored as an edge pixel matrix M E , used to store the information of the crack edge, which serves as the basis for judging the edge pixels in the subsequent steps.
[0062] Step 3: Find the preset direction based on the 8-neighborhood and obtain the middle direction among the preset directions;
[0063] Furthermore, the step of searching for a preset direction based on the 8-neighborhood includes:
[0064] For each pixel point on the edge in the matrix M corresponding to the binary crack image B compare the magnitudes of the pixels that are centrosymmetric in pairs in the neighborhood of pixel point P0. If the values of the elements in the corresponding matrix M B of the two pixel points are different, then determine that the direction from pixel point P0 to the pixel point with a value of 255 is the preset direction, and loop through the neighborhood of pixel point P0 until all the preset directions where pixel point P0 exists are found;
[0065] Let the direction from pixel point P0 to pixel point P i be d i , then for all preset directions d i the following 3 conditions need to be satisfied simultaneously, and all d i that meet the conditions are stored as the preset direction list D of the edge pixels:
[0066] Condition 1: 1 ≤ i ≤ 8;
[0067] Condition 2: The pixel value V(P i ) > 0 at pixel point P i ;
[0068] Condition 3: When i ≤ 4, the pixel value V(P i+4 ) = 0, or when i ≥ 5, the pixel value V(P i-4 ) = 0.
[0069] The preset direction list D is only for the currently traversed pixels (not the pixels on the opposite edge), and is used for traversing the opposite edge. When traversing to the next edge pixel for which the width value has not been calculated, a new list D is created to replace the old list to perform the traversal of the preset directions and the opposite edge.
[0070] Furthermore, the steps to obtain the intermediate direction among the preset directions include:
[0071] For the preset direction list D, if the number of elements in the list is greater than 1, adjust the elements in the list so that the adjacent preset directions in the list are logically adjacent. For the i-th preset direction in the list, determine whether it satisfies: when 1 ≤ i < n, D i - D i-1 > 1. If it is satisfied, move the element at the end of the list to the head of the list, where n is the size of the list, and D i represents the i-th preset direction in the list, and the judgment ends when i increments from 1 until i = m - 1;
[0072] Take the median in the adjusted list D as the intermediate direction D mid among the preset directions. Combined with Figure 4In the figure, gray pixels are edges, white pixels are crack areas, and black pixels are non-crack areas. The gray and white pixels have a value of 255, and the black pixel has a value of 0; all arrows represent preset directions, and the orange arrow represents the middle direction.
[0073] Step 4: traverse the edge pixel set on the opposite side, find the effective width between edge pixels, and obtain a width list.
[0074] Furthermore, the steps of traversing the opposite edge pixel set and finding the effective width between edge pixels to obtain a width list include:
[0075] For each pixel on the edge (x s ,y s ), traverse all preset directions D in the adjusted preset direction list D i , find the opposite edge pixel point, in the middle direction D mid As the starting point of the traversal for width calculation, the Euclidean distance between the two points is calculated as the width value w of the edge pixel of this face. If the minimum width value w min If it does not exist, then w is taken as w min The initial value of
[0076] Find the edge pixel points that have not been traversed in the neighborhood of the traversal starting point, and calculate the distance between the pixel point (x s ,y s ) between the Euclidean distance, update the edge pixel point of this face (x s ,y s )'s minimum width w min , and continue to search for untraversed edge pixels and loop until no untraversed edge pixels are found;
[0077] Set the threshold coefficient δ, if w>w min *δ, then the interrupt direction D i Continue traversing the remaining preset directions that have not been traversed;
[0078] If the minimum width value is 0, then the pixel point (x s ,y s ) does not have a valid width, that is, to determine the pixel point (x s ,y s ) is noise, discard the pixel (x s ,y s );
[0079] The minimum effective width w min As the edge pixel of this face (x s ,y s ) width value, the pixel coordinates and width value are stored in the width list R. Figure 5 , for each pixel on the edge (x s ,y s ), which is the same as the edge pixel point (x i ,y i ) is calculated as follows:
[0080]
[0081] w min =min(w i ),
[0082] In the above formula, w min is the pixel (x s ,y s ), where P is the set of pixels on the opposite edge. Based on the starting point of the traversal of the opposite edge, find the edge pixels that have not been traversed in its neighborhood, and calculate the Euclidean distance between the two points. Update the minimum width value of the edge pixels of this face and repeat the cycle. If the minimum width value is 0, it is determined that the pixel does not have a valid width, that is, it is determined that the pixel is noise and discarded. Assume that the threshold coefficient δ = 2, when w i >δ·w min Stop traversal when , to reduce the amount of calculation.
[0083] After the width of the pixel is calculated, according to the edge pixel matrix M E Traverse the edge pixels whose width values have not been calculated, jump to step 3, calculate the width values of the edge pixels that have not been traversed, until the width values of all edge pixels are calculated, and obtain the width list R containing width information.
[0084] Step 5: Optimize the width list and calculate the average width of the cracks.
[0085] Furthermore, the steps of optimizing the width list and calculating the average width of the cracks include:
[0086] Taking the width value as the standard, the maximum value and the minimum value of ε% in the width list R are eliminated, 1<ε<6, and the optimized width list W is obtained. The average value of all width values in the width list W is calculated and the average value is used as the average width of dangerous rock cracks.
[0087] In an example, ε can be set to 5, and the 5% maximum values and 5% minimum values in the width list R are eliminated to obtain an optimized width list, and a truncated mean value is calculated as the average width of the crack.
[0088] Step 6: Calculate the actual width of the dangerous rock crack based on the average width.
[0089] Furthermore, the step of calculating the actual width of the dangerous rock crack according to the average width includes:
[0090] The proportional conversion relationship γ between the crack pixels and the actual size is calculated based on the corner point list C. The calculation formula is:
[0091]
[0092] Where, l act is the actual length of the chessboard square, which is 1 cm in this example, and n and m are the number of rows and columns of corner points respectively;
[0093] Convert the average width to the actual width set W according to the proportional conversion relationship r =W·γ.
[0094] In order to evaluate the measurement accuracy of the method described in the present invention, in this embodiment, a crack comparison card was used to uniformly sample 10 dangerous rock cracks, and their average width was obtained as the actual value. The average width was compared with the calculation results of the present invention and the skeleton algorithm. The results are shown in Table 1. Figure 6 In order to utilize the crack views at each stage in the present invention, Figure (a) is the crack detection result, Figure (b) is the binarization result, and Figure (c) is a schematic diagram of the edge extraction result.
[0095] Table 1 Experimental results
[0096]
[0097] By comparison, the relative error of the crack width measured by this method is 14.4% on average and 27.9% at most. After optimization, the relative error is 8.3% on average and 10.7% at most, which shows an improvement in accuracy. The relative error based on the skeleton algorithm is 32.9% on average and 53.5% at most, which is significantly higher than that of this method. Figure 7 As shown in the figure, (a) is the width measurement result of the present invention, (b) is the optimized width measurement result, and (c) is the width measurement result based on the skeleton method. It can be seen that this method has excellent filtering ability for minimum noise. By calculating the average value of the scalar difference between the algorithm result and the actual value, the standard deviation of the difference of the algorithm is obtained. The standard deviation of the difference of the result of this method is 0.085mm, the standard deviation of the difference of the optimized result is 0.032mm, and the standard deviation of the difference based on the skeleton algorithm is 0.132mm, indicating that the width measurement effect of this method is more stable than that based on the skeleton algorithm.
Claims
1. A method for measuring the width of dangerous rock cracks based on the minimum edge width method, characterized in that: The following steps are involved: Obtain dangerous rock crack images and generate binary images after preprocessing; Extract crack edges based on the binary image, determine edge pixels and store edge pixel information as a matrix; Find the preset direction based on the 8-neighborhood and obtain the middle direction among the preset directions; Traverse the edge pixel set on the opposite side, find the effective width between edge pixels, and obtain a width list; Optimize the width list and calculate the average width of the cracks; Calculate the actual width of dangerous rock cracks based on the average width.
2. The method for measuring the width of dangerous rock cracks based on the minimum edge width method according to claim 1, characterized in that: The steps of extracting crack edges based on the binary image, determining edge pixels, and storing edge pixel information as a matrix include: The matrix corresponding to the crack binary image is denoted as M B ; Detection matrix M B The pixel value of each pixel in the , determines whether the pixel value at the current pixel is greater than 0. If it is greater than 0 and there is at least one background pixel in the 4 neighboring pixels of the current pixel, the current pixel is considered to be an edge pixel; The detection results are stored in the edge pixel matrix M E In the edge pixel matrix M E The elements corresponding to edge pixels are set to 255, otherwise they are set to 0.
3. The method for measuring the width of dangerous rock cracks based on the minimum edge width method according to claim 2, characterized in that: The steps for finding a preset direction based on an 8-neighborhood include: For the matrix M B For each pixel on the edge, compare the sizes of the two centrosymmetric pixels in the neighborhood of pixel point P0. If the values of the matrix elements corresponding to the two pixels are different, then the direction from pixel point P0 to the pixel with a value of 255 is determined to be the preset direction. The neighborhood of pixel point P0 is looped until all the preset directions in which pixel point P0 exists are found. Let pixel point P0 to pixel point P i The direction is d i , then for all preset directions d i The following three conditions must be met at the same time, and all d i A list D of preset directions stored as edge pixels: Condition 1: 1≤i≤8; Condition 2: Pixel P i The pixel value V(P i )>0; Condition 3: When i≤4, the pixel value V(P i+4 )=0, or when i≥5, the pixel value V(P i-4 )=0.
4. The method for measuring the width of dangerous rock cracks based on the minimum edge width method according to claim 3, characterized in that: The steps of obtaining an intermediate direction among the preset directions include: For a preset direction list D, if the number of elements in the list is greater than 1, adjust the elements in the list so that adjacent preset directions in the list are logically adjacent. For the i-th preset direction in the list, determine whether it satisfies: when 1 ≤ i < n, D i -D i-1 > 1. If it is satisfied, move the element at the end of the list to the beginning of the list, where n is the size of the list, and D i represents the i-th preset direction in the list, starting from i = 1 and incrementing until i = n - 1 to end the judgment; Take the median of the adjusted list D as the middle direction D in the preset direction mid .
5. The method for measuring the width of dangerous rock cracks based on the minimum edge width method according to claim 4, characterized in that: Traversing the opposite edge pixel set to find the effective width between edge pixels, the steps of obtaining the width list include: For each pixel on the edge (x s ,y s ), traverse all preset directions D in the adjusted preset direction list D i , find the opposite edge pixel point, in the middle direction D mid As the starting point of the traversal for width calculation, the Euclidean distance between the two points is calculated as the width value w of the edge pixel of this face. If the minimum width value w min If it does not exist, then w is taken as w min The initial value of Find the edge pixel points that have not been traversed in the neighborhood of the traversal starting point, and calculate the distance between the pixel point (x s ,y s ) between the Euclidean distance, update the edge pixel point of this face (x s ,y s )'s minimum width w min , and continue to search for untraversed edge pixels and loop until no untraversed edge pixels are found; Set the threshold coefficient δ, if w>w min *δ, then the interrupt direction D i Continue traversing the remaining preset directions that have not been traversed; If the minimum width value is 0, then the pixel point (x s ,y s ) does not have a valid width, that is, to determine the pixel point (x s ,y s ) is noise, discard the pixel (x s ,y s ); The minimum effective width w min As the edge pixel of this face (x s ,y s ) and store the pixel coordinates and width value in the width list R.
6. The method for measuring the width of dangerous rock cracks based on the minimum edge width method according to claim 5, characterized in that: The steps for optimizing the width list and calculating the average width of the cracks include: Taking the width value as the standard, the maximum value and the minimum value of ε% in the width list R are eliminated, 1<ε<6, and the optimized width list W is obtained. The average value of all width values in the width list W is calculated and the average value is used as the average width of dangerous rock cracks.
7. The method for measuring the width of dangerous rock cracks based on the minimum edge width method according to claim 6, characterized in that: The steps for calculating the actual width of dangerous rock cracks based on the average width include: According to the corner point list C, the proportional conversion relationship γ between the crack pixels and the actual size is calculated, and the average width is converted into the actual width set W according to the proportional conversion relationship r =W·γ.
8. The method for measuring the width of dangerous rock cracks based on the minimum edge width method according to any one of claims 1 to 7, characterized in that: The steps of obtaining a dangerous rock crack image and generating a binary image after preprocessing include: The dangerous rock crack image was amplified, contrast adjusted and bilaterally filtered using bilinear interpolation to denoise the image while retaining edge sharpness. The processed crack image was converted into a binary image using threshold binarization.