Image recognition method and system for stone slab crack detection
Through the method of combining gradient direction and Hessian matrix, the problem of indistinguishable cracks and patterns in crack detection of stone slabs is solved, and high-precision crack detection is achieved, which is suitable for small and medium-sized stone processing enterprises.
Patent Information
- Application Number
- CN202510314175.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-17
- Publication Date
- 2025-07-18
AI Technical Summary
The prior art is difficult to distinguish cracks and patterns with high precision in the background of complex stone textures, and the traditional method has a high error detection rate, making it difficult to meet the needs of small and medium-sized stone processing enterprises.
The method of combining gradient direction and Hessian matrix is adopted to achieve high-precision extraction and refined distinction of cracks through pre-processing, gradient threshold segmentation, Hessian matrix analysis and non-maximum suppression, and visual annotation is performed on the original picture of the stone slab.
It significantly reduces the error detection rate and missed detection rate, and can detect subtle cracks with widths greater than 0.5 mm and lengths greater than 3.5 mm, improving detection accuracy and practicality.
Smart Images

Figure CN120339184A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image recognition, and involves crack detection occurring during the cutting process of stone plates, in particular to an image recognition method and system for crack detection of stone plates. Background Art
[0002] The statements in this part only provide background technical information related to the present invention, and do not necessarily constitute prior art.
[0003] Stone plates are usually made of natural stones such as granite and marble. With the rapid development of the building decoration industry, stone plates are widely used in fields such as wall surfaces, floors, and furniture due to their beautiful appearance and easy processing characteristics. However, cracks are likely to occur during the production process of stone plates. These cracks not only affect the aesthetics of the material, but may also lead to structural failure during long-term use, seriously threatening the engineering quality and use safety. Therefore, accurately and quickly detecting cracks on the surface of stone plates has become a technical problem urgently to be solved in the stone processing industry. Crack detection is mainly carried out after cutting and before polishing on the production line to ensure quality, or during the acceptance before the finished products leave the factory, and is applicable to quality control in stone plate production workshops and construction projects.
[0004] In the prior art, crack detection of stone plates mainly relies on manual visual inspection and traditional image processing techniques. Although manual detection is intuitive, it is inefficient and limited by the experience and subjective judgment of the inspectors, making it difficult to ensure consistency and accuracy. With the development of image processing technology, automated methods based on edge detection (such as the Canny algorithm and Sobel operator) have been introduced into the field of crack recognition. These methods initially extract the crack edges by calculating the first-order gradient information of the image. Existing bridge cutting machines are equipped with cameras for cutting monitoring, and some support basic image processing (such as edge detection), but it is difficult to distinguish cracks from patterns, relying on manual or simple threshold methods, with a high false detection rate. The slender characteristics of cracks and their low contrast in complex backgrounds further increase the detection difficulty.
[0005] Some studies have attempted to introduce machine learning or deep learning techniques to achieve crack recognition by training a large number of samples. Industrial scanners can detect surface defects, but mostly rely on first-order gradients or deep learning. Although such methods show high accuracy in specific scenarios, they rely on large-scale labeled datasets and high-performance computing devices, with high costs, and have high requirements for the diversity of samples, making it difficult to be popularized and applied in small and medium-sized stone processing enterprises. At the same time, existing methods still have deficiencies in the refined detection of cracks and result visualization, especially lacking customized solutions for the geometric characteristics of cracks in ultra-stone plates. Summary of the Invention
[0006] To solve the above problems, the present invention proposes an image recognition method and system for crack detection of stone plates. By combining the gradient direction with the Hessian matrix, high-precision extraction and refined differentiation of cracks are achieved under the background of complex stone textures, effectively overcoming the limitation that it is difficult for traditional methods to separate cracks from patterns. At the same time, crack annotation is directly performed on the original image of the stone plate, significantly improving the accuracy and practicality of stone plate quality detection.
[0007] To achieve the above object, the present invention adopts the following technical solutions:
[0008] In the first aspect, the present invention provides an image recognition method for crack detection of stone plates,
[0009] Obtain a color image of a stone plate, and preprocess the color image of the stone plate to obtain a grayscale image;
[0010] Calculate the gradient magnitude of the grayscale image, perform threshold segmentation on the gradient magnitude, and determine the optimal threshold. Normalize the optimal threshold and generate a binary image; Perform area opening operation on the binary image to obtain a preliminary edge image;
[0011] Calculate the first-order gradient and direction of the preliminary edge image, and smooth the preliminary edge image; Construct a Hessian matrix and generate a crack response image; Perform edge detection on the crack response image, combine non-maximum suppression to refine the crack boundary, and generate an initial edge image; Perform connected component analysis on the initial edge image to generate a final edge image;
[0012] Extract the crack point coordinates from the final edge image to obtain a crack point set, map the crack points to the color image of the stone plate and perform visual annotation to generate a marked image.
[0013] In a further technical solution, the preprocessing method is: use a grayscale conversion function to convert the color image of the stone plate into a grayscale image; Divide the grayscale image into several sub-regions by setting cropping limit parameters and splitting tile parameters, and then adjust the grayscale values based on histogram equalization to obtain new grayscale values.
[0014] In a further technical solution, the specific method for obtaining the new grayscale value is: independently calculate the cumulative distribution function for each sub-region, and the formula is: where P(k) represents the probability of the grayscale value k, and i represents the grayscale value range; The new grayscale value is expressed as:
[0015] A further technical solution is to calculate the gradient magnitude of the grayscale image using the Prewitt operator. Specifically, the Prewitt operator performs convolution calculations on the grayscale image through a first horizontal direction convolution kernel and a first vertical direction convolution kernel respectively to calculate a first horizontal gradient and a first vertical gradient, and calculates the gradient magnitude of the grayscale image based on the first horizontal gradient and the first vertical gradient.
[0016] Perform threshold segmentation on the gradient magnitude of the grayscale image based on the Otsu algorithm. Set the grayscale value range, count the probability of the grayscale value appearing in the gradient magnitude of the grayscale image, and calculate the total number of pixels. Divide the pixels of the grayscale image into a background class and a foreground class through a threshold, and calculate the background class weight, foreground class weight, background class mean, and foreground class mean respectively. Determine the optimal threshold by maximizing the between-class variance.
[0017] A further technical solution, the specific method for performing area opening operation on the binary image is: set the connected domain area threshold, calculate the number of pixels of each connected domain. If the number of pixels of the connected domain is less than the connected domain area threshold, remove it; if the number of pixels of the connected domain is greater than or equal to the connected domain area threshold, retain it, and finally generate a preliminary edge image.
[0018] A further technical solution is to calculate the first-order gradient of the preliminary edge image using the Sobel operator. Specifically, the Sobel operator performs convolution calculations on the preliminary edge image through a second horizontal direction convolution kernel and a second vertical direction convolution kernel respectively to calculate a second horizontal gradient and a second vertical gradient, and calculates the first-order gradient and direction of the preliminary edge image based on the second horizontal gradient and the second vertical gradient.
[0019] A further technical solution, the non-maximum suppression retains the local maximum by comparing the magnitudes of the first-order gradient along the gradient direction; performs dilation operation using a vertical linear structure element to connect discontinuous cracks; applies slight erosion to remove small noises; connects the remaining breakpoints through bridging operation and removes isolated sharp points to obtain an initial edge image.
[0020] In a second aspect, the present invention provides an image recognition system for detecting cracks in stone slabs, including:
[0021] An image preprocessing module, configured to: obtain a color image of a stone slab and preprocess the color image of the stone slab to obtain a grayscale image;
[0022] A preliminary crack edge extraction module, configured to: calculate the gradient magnitude of the grayscale image, perform threshold segmentation on the gradient magnitude, determine the optimal threshold, normalize the optimal threshold and generate a binary image; perform area opening operation on the binary image to obtain a preliminary edge image;
[0023] The refined crack feature optimization module is configured to: calculate the first-order gradient and direction of the preliminary edge image, and smooth the preliminary edge image; construct a Hessian matrix and generate a crack response image; perform edge detection on the crack response image, refine the crack boundary by combining non-maximum suppression, and generate an initial edge image; perform connected component analysis on the initial edge image to generate a final edge image.
[0024] The crack point localization and visualization module is configured to: extract crack point coordinates from the final edge image to obtain a set of crack points, map the crack points to the color image of the stone slab and perform visual annotation to generate a marked image.
[0025] Compared with the prior art, the beneficial effects of the present invention are as follows:
[0026] Through the collaborative analysis of the gradient direction and the Hessian matrix, combined with CLAHE contrast enhancement and geometric feature filtering, the present invention can accurately separate cracks and patterns in complex stone textures, significantly reducing the false detection rate and missed detection rate. The multi-level optimization based on the first-order and second-order gradient information realizes the refined detection of cracks, and has higher specificity compared with traditional single-edge detection methods; the method can detect fine cracks with a width greater than 0.5 mm and a length greater than 3.5 mm, and is applicable to cracks in stone slabs that are difficult to directly observe with the naked eye, improving the detection accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] The specification drawings forming a part of the present invention are used to provide a further understanding of the present invention. The schematic embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention.
[0028] Figure 1 It is a flowchart of an image recognition method for refined detection of stone slab cracks in Embodiment 1 of the present invention;
[0029] Figure 2 It is a flowchart of an image recognition system for refined detection of stone slab cracks in Embodiment 2 of the present invention;
[0030] Figure 3 It is the color image of the stone slab obtained in Embodiment 1 of the present invention;
[0031] Figure 4 It is the grayscale image in Embodiment 1 of the present invention;
[0032] Figure 5 It is the final preliminary edge image in Embodiment 1 of the present invention;
[0033] Figure 6 It is the final edge image in Embodiment 1 of the present invention
[0034] Figure 7 This is the marked image in the first embodiment of the present invention. Specific embodiments
[0035] The present invention will be further described below in conjunction with the accompanying drawings and embodiments.
[0036] It should be noted that the following detailed description is exemplary and is intended to provide further illustration of the present invention. Unless otherwise specified, all technical and scientific terms used herein have the same meaning as commonly understood by those of ordinary skill in the technical field to which the present invention belongs. In the case of no conflict, the embodiments in the present invention and the features in the embodiments can be combined with each other.
[0037] Embodiment 1
[0038] This embodiment provides an image recognition method for detecting cracks in stone slabs, as Figure 1 shown, specifically including the following steps:
[0039] S1: Obtain a color image of the stone slab, and preprocess the color image of the stone slab to obtain a grayscale image;
[0040] S2: Calculate the gradient magnitude of the grayscale image, perform threshold segmentation on the gradient magnitude, and determine the optimal threshold. Normalize the optimal threshold and generate a binary image; Perform area opening operation on the binary image to obtain a preliminary edge image;
[0041] S3: Calculate the first-order gradient and direction of the preliminary edge image, and smooth the preliminary edge image; Construct a Hessian matrix and generate a crack response image; Perform edge detection on the crack response image, refine the crack boundary by combining non-maximum suppression, and generate an initial edge image; Perform connected component analysis on the initial edge image to generate a final edge image;
[0042] S4: Extract the crack point coordinates from the final edge image to obtain a crack point set, map the crack points to the color image of the stone slab and perform visual annotation to generate a marked image.
[0043] In step S1, based on the original high-definition image of the stone slab, this embodiment first obtains a color image with a resolution of 1024×768 pixels through an image processing device as the original input image, and preprocesses the original input image to obtain a grayscale image.
[0044] The method of the above preprocessing is: Use a grayscale conversion function to convert the color image of the stone slab as Figure 3 shown into the grayscale image as Figure 4 shown, and perform the conversion according to formula (1):
[0045] gray = 0.2989×R + 0.5870×G + 0.1140×B (1)
[0046] Where R, G, and B are the pixel values of the red, green, and blue channels respectively.
[0047] Apply the Contrast Limited Adaptive Histogram Equalization (CLAHE) method to the grayscale image gray to enhance the local contrast of the grayscale image gray. The grayscale image is divided into several sub-regions by setting the clipping limit parameter (ClipLimit, which limits the histogram height to prevent over-enhancement, with a value of 0.012) and the segmentation tile parameter (NumTiles, which divides the image into small blocks for local processing, with a value of 8×8). Then, the grayscale values are adjusted based on histogram equalization to obtain new grayscale values. The clipping limit parameter determines that the maximum frequency of each sub-region histogram is 0.012 times the total number of sub-region pixels, and the segmentation tile parameter enables each sub-region to independently calculate the cumulative distribution function.
[0048] The specific method for obtaining the new grayscale values is as follows: independently calculate the cumulative distribution function for each sub-region, as shown in formula (2):
[0049]
[0050] Where P(k) represents the probability of the grayscale value k, and i represents the grayscale value range (from 0 to 255); the new grayscale values are mapped according to formula (3) to significantly improve the grayscale value difference of white cracks in the complex texture background, as described below:
[0051]
[0052] In step S2, using the grayscale image obtained in step S1 as the input, calculate the gradient magnitude of the grayscale image using the Prewitt operator to quickly locate the rough edges of the cracks.
[0053] The Prewitt operator performs convolution calculations on the grayscale image through the first horizontal direction convolution kernel and the first vertical direction convolution kernel respectively, calculates the first horizontal gradient and the first vertical gradient, and calculates the gradient magnitude of the grayscale image based on the first horizontal gradient and the first vertical gradient. Specifically:
[0054] The first horizontal direction convolution kernel is shown in formula (4):
[0055]
[0056] The second vertical direction convolution kernel is shown in formula (5):
[0057]
[0058] Perform convolution operations on the images separately to calculate the first horizontal gradient Gx and the first vertical gradient Gy. The convolution process is to perform weighted summation of the gray values of each pixel point (x, y) and its 3×3 neighborhood, as shown in formulas (6) and (7) respectively:
[0059]
[0060] And generate the gradient magnitude image Gmag through formula (8). At this time, it can be obtained that the crack edge presents a relatively high gradient value (about 200) due to the sudden change of gray value (from 50 to 180), while the gradient of the smooth pattern area is relatively low (about 50), so as to quickly locate the rough edge of the crack.
[0061]
[0062] Where:
[0063] Gx(x, y) represents the horizontal gradient of the grayscale image at the position (x, y), indicating the grayscale change in the horizontal direction;
[0064] Gy(x, y) represents the vertical gradient of the grayscale image at the position (x, y), indicating the grayscale change in the vertical direction;
[0065] Gmag(x, y) represents the gradient magnitude of the grayscale image at the position (x, y), combining the horizontal and vertical gradients, indicating the total intensity of the edge.
[0066] I(x, y) represents the grayscale value of the input grayscale image, the pixel value at the position (x, y) (range 0 to 255);
[0067] i and j represent the relative coordinates of the convolution kernel, with a range of -1 to 1, indicating the offset of the 3×3 neighborhood centered on the kernel.
[0068] Based on the Otsu algorithm, perform threshold segmentation on the gradient magnitude of the grayscale image to determine the optimal threshold. The specific method is as follows: Set the grayscale value range from 0 to 255, count the probability P(k) of the grayscale value k appearing in the gradient magnitude of the grayscale image, and calculate the total number of pixels as N; Divide the pixels of the grayscale image into the background class C0 (from 0 to T - 1) and the foreground class C1 (from T to 255) through the threshold T, and calculate the background class weight Foreground class weight Background class mean And the foreground class mean Determine the optimal threshold by maximizing the between-class variance. Among them, the between-class variance is defined as: By maximizing Determine the optimal threshold T, and the normalized optimal threshold level = T / 255 (range 0 to 1). Generate a binary image edges, retaining the crack edge pixels (such as gradient value 120) while removing the low-gradient background (such as 50) or high-gradient noise (such as 300).
[0069] Apply an area opening operation to the binary image edges, setting the connected component area threshold to 10. This operation traverses all connected components in the image, calculates the number of pixels A of each connected component. If A < 10, it is removed (such as an isolated noise point with an area of 5), and if A ≥ 10, it is retained (such as a 20×2 pixel crack with an area of 40), as Figure 5 shown, generating the final preliminary edge image edges, effectively extracting the crack features and significantly reducing the noise interference.
[0070] In step S3, to further distinguish the cracks in the stone slab from the patterns of the stone itself, the collaborative analysis of the gradient direction and the Hessian matrix is introduced to achieve refined detection of the cracks.
[0071] Using the preliminary edge image as the input of step S3, the Sobel operator is used to calculate the first-order gradient of the preliminary edge image to locate the edge features. The Sobel operator performs convolution calculations on the preliminary edge image through the second horizontal direction convolution kernel and the second vertical direction convolution kernel respectively, calculating the second horizontal gradient and the second vertical gradient, and calculating the first-order gradient and direction of the preliminary edge image based on the second horizontal gradient and the second vertical gradient. Specifically:
[0072] The second horizontal direction convolution kernel is shown in formula (9):
[0073]
[0074] The second vertical direction convolution kernel is shown in formula (10):
[0075]
[0076] Perform convolution operations on the image respectively to calculate the second horizontal gradient Gx1 and the second vertical gradient Gy1, specifically as follows:
[0077]
[0078] Gdir(x,y) = arctan2(Gy1(x,y), Gx1(x,y)) (14) where:
[0079] Gx1(x,y) represents the horizontal gradient of the preliminary edge image at position (x,y), indicating the gray level change in the horizontal direction;
[0080] Gy1(x, y) represents the vertical gradient of the preliminary edge image at the position (x, y), indicating the gray-scale change in the vertical direction;
[0081] Gmag(x, y) represents the gradient magnitude of the preliminary edge image at the position (x, y), combining the horizontal and vertical gradients, indicating the total intensity of the edge.
[0082] I(x, y) represents the gray-scale value of the input image, the pixel value at the position (x, y) (range 0 to 255);
[0083] i and j represent the relative coordinates of the convolution kernel, ranging from -1 to 1, indicating the 3×3 neighborhood offset of the kernel center;
[0084] Gdir(x, y) represents the calculated gradient direction, indicating the edge orientation (radian value, range -π to π).
[0085] The specific method for constructing the Hessian matrix and generating the crack response image is as follows:
[0086] To detect the crack structure, apply Gaussian filtering smoothing to the preliminary edge image. In this implementation case, set the standard deviation of the Gaussian kernel σ = 1.8 and the kernel size to 5×5 to generate the smoothed image S, so as to reduce the influence of noise on the second derivative. Then, calculate the second partial derivatives and generate G xx 、G yy 、G xy .
[0087] Among them:
[0088]
[0089] Construct the Hessian matrix H(x, y)
[0090]
[0091] Calculate the eigenvalues λ1 and λ2 (|λ1| ≥ |λ2|) of H(x, y) for each pixel point (x, y)
[0092] The eigenvalue formula is:
[0093]
[0094] The crack determination condition for the stone slab is λ2 < 0 and |λ1| > τ, where
[0095] τ = 0.015 × max(|λ1|) (21)
[0096] Generate the crack response image crack_response.
[0097] Then, edge detection is performed on the crack response image, and non-maximum suppression is combined to refine the crack boundary to generate an initial edge image. Apply Sobel edge detection to the crack response image, and combine non-maximum suppression to refine the crack boundary to generate the initial edge image crack_edges, where non-maximum suppression compares the magnitudes of the first-order gradients along the gradient direction and only retains the local maximum values; then morphological optimization is performed. First, a vertical linear structure element (length 20, angle 90°) is used for dilation operation to connect discontinuous cracks; then, slight erosion is applied to remove small noises; then, the remaining breakpoints are connected through bridging operation, and isolated cusps are removed. After optimization, the continuity of the crack edges is enhanced to obtain the initial edge image.
[0098] In step S3, it also includes performing connected component analysis on the initial edge image crack_edges, calculating the area (number of pixels), major axis length (length of the major axis, in pixels), and minor axis length (length of the minor axis, in pixels) of each connected component. The screening conditions are that the area of each connected component > 200, and the aspect ratio R = major axis length / minor axis length > 7, as Figure 6 shown, to generate the final edge image crack_edges_final. It can detect fine cracks with a width greater than 0.5 mm and a length greater than 3.5 mm, which is applicable to the cracks in stone slabs that are difficult to directly observe with the naked eye, improving the detection accuracy.
[0099] In step S4, the crack point coordinates are extracted from the final edge image. Specifically: read the final edge image generated in step S3, extract the crack point coordinates with a pixel value of 1, and record them as set Q.
[0100] Map the crack points to the stone slab color image and perform visual annotation. With each crack point as the center, draw a 3×3 pixel red square (RGB = [255, 0, 0]) on the image, as Figure 7 shown, to generate the marked image.
[0101] Embodiment 2
[0102] In this embodiment, an image recognition system for crack detection of stone slabs is disclosed, including:
[0103] A stone material image acquisition module, configured to: acquire a color image of the stone slab and preprocess the color image of the stone slab to obtain a grayscale image;
[0104] A preliminary crack edge extraction module, configured to: calculate the gradient magnitude of the grayscale image, perform threshold segmentation on the gradient magnitude, determine the optimal threshold, normalize the optimal threshold and generate a binary image; perform area opening operation on the binary image to obtain a preliminary edge image;
[0105] The refined crack feature optimization module is configured to: calculate the first-order gradient and direction of the preliminary edge image, and smooth the preliminary edge image; construct a Hessian matrix and generate a crack response image; perform edge detection on the crack response image, refine the crack boundary by combining non-maximum suppression, and generate an initial edge image; perform connected component analysis on the initial edge image to generate a final edge image.
[0106] The crack visualization output module is configured to: extract crack point coordinates from the final edge image to obtain a set of crack points, map the crack points to the stone slab color image and perform visual annotation to generate a marked image.
[0107] Embodiment III
[0108] This embodiment provides a computer-readable storage medium, on which a program is stored. When the program is executed by a processor, it implements the steps in an image recognition method for crack detection of stone slabs as described in Embodiment I above.
[0109] Embodiment IV
[0110] An electronic device includes a memory, a processor, and a program stored on the memory and executable on the processor. It is characterized in that when the processor executes the program, it implements the steps in an image recognition method for crack detection of stone slabs as described in Embodiment I above.
[0111] It should be noted here that each module in this embodiment corresponds one by one to the method in Embodiment I, and its specific implementation process is the same, so it will not be repeated here.
[0112] The above are only the preferred embodiments of the present invention and are not used to limit the present invention. For those skilled in the art, the present invention can have various changes and modifications. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of the present invention shall be included within the protection scope of the present invention.
[0113] Although the specific implementation manners of the present invention are described above in conjunction with the accompanying drawings, it is not a limitation to the protection scope of the present invention. Those skilled in the art should understand that based on the technical solutions of the present invention, various modifications or deformations that can be made by those skilled in the art without creative efforts are still within the protection scope of the present invention.
Claims
1. An image recognition method for detecting cracks in stone plates, characterized in that, Including: Obtain a color image of the stone slab, and preprocess the color image of the stone slab to obtain a grayscale image; Calculate the gradient magnitude of the grayscale image, perform threshold segmentation on the gradient magnitude, determine the optimal threshold, normalize the optimal threshold, and generate a binary image; Perform an area opening operation on the binary image to obtain a preliminary edge image; Calculate the first-order gradient and direction of the preliminary edge image, and perform smoothing processing on the preliminary edge image; construct a Hessian matrix and generate a crack response image; perform edge detection on the crack response image, refine the crack boundary by combining non-maximum suppression, and generate an initial edge image; perform connected component analysis on the initial edge image to generate a final edge image; Extract the crack point coordinates from the final edge image to obtain a crack point set, map the crack points to the color image of the stone slab and perform visual annotation to generate a marked image.
2. The image recognition method for detecting cracks in stone plates according to claim 1, wherein, The method of the preprocessing is: use a grayscale conversion function to convert the color image of the stone slab into a grayscale image; divide the grayscale image into several sub-regions by setting cropping limit parameters and dividing tile parameters, and then adjust the grayscale value based on histogram equalization to obtain a new grayscale value.
3. The image recognition method for detecting cracks in stone plates according to claim 2, wherein, The specific method for obtaining the new gray value is as follows: Calculate the cumulative distribution function independently for each sub-region, and the formula is: where P(k) represents the probability of the gray value k, and i represents the gray value range; the new gray value is expressed as:
4. The image recognition method for detecting cracks in stone plates according to claim 1, characterized in that, Use the Prewitt operator to calculate the gradient magnitude of the grayscale image. Specifically, the Prewitt operator performs convolution calculations on the grayscale image through a first horizontal direction convolution kernel and a first vertical direction convolution kernel respectively, calculates the first horizontal gradient and the first vertical gradient, and calculates the gradient magnitude of the grayscale image according to the first horizontal gradient and the first vertical gradient; Perform threshold segmentation on the gradient magnitude of the grayscale image based on the Otsu algorithm, set the grayscale value range, count the probability of the grayscale value appearing in the gradient magnitude of the grayscale image, and calculate the total number of pixels; divide the pixels of the grayscale image into a background class and a foreground class through the threshold, and calculate the background class weight, foreground class weight, background class mean, and foreground class mean respectively, and determine the optimal threshold by maximizing the between-class variance.
5. The image recognition method for detecting cracks in stone slabs according to claim 1, characterized in that, The specific method of performing an area opening operation on the binary image is: set a connected component area threshold, calculate the number of pixels of each connected component, if the number of pixels of the connected component is less than the connected component area threshold, then remove it, if the number of pixels of the connected component is greater than or equal to the connected component area threshold, then retain it, and finally generate a preliminary edge image.
6. The image recognition method for detecting cracks in stone plates according to claim 1, characterized in that, Use the Sobel operator to calculate the first-order gradient of the preliminary edge image. Specifically, the Sobel operator performs convolution calculations on the preliminary edge image through a second horizontal direction convolution kernel and a second vertical direction convolution kernel respectively, calculates the second horizontal gradient and the second vertical gradient, and calculates the first-order gradient and direction of the preliminary edge image according to the second horizontal gradient and the second vertical gradient.
7. The image recognition method for detecting cracks in stone plates according to claim 1, characterized in that, The non-maximum suppression retains the local maximum by comparing the magnitudes of the first-order gradient along the gradient direction; uses a vertical linear structure element for dilation operation to connect discontinuous cracks; applies slight erosion to remove small noises; connects the remaining breakpoints through a bridging operation, removes isolated sharp points, and obtains an initial edge image.
8. An image recognition system for detecting cracks in stone slabs, characterized in that, Including: A stone material image acquisition module, configured to: obtain a color image of the stone slab, and preprocess the color image of the stone slab to obtain a grayscale image; The preliminary crack edge extraction module is configured to: calculate the gradient magnitude of the grayscale image, perform threshold segmentation on the gradient magnitude, determine the optimal threshold, normalize the optimal threshold, and generate a binary image; Perform area opening operation on the binary image to obtain a preliminary edge image; The refined crack feature optimization module is configured to: calculate the first-order gradient and direction of the preliminary edge image, and smooth the preliminary edge image; construct a Hessian matrix and generate a crack response image; perform edge detection on the crack response image, refine the crack boundary by combining non-maximum suppression, and generate an initial edge image; perform connected component analysis on the initial edge image to generate a final edge image; The crack visualization output module is configured to: extract crack point coordinates from the final edge image to obtain a crack point set, map the crack points to the stone slab color image and perform visual annotation to generate a marked image.
9. A computer-readable storage medium having a program stored thereon, characterized in that, When the program is executed by a processor, it implements the steps in an image recognition method for crack detection of stone slabs according to any one of claims 1-7.
10. An electronic device, comprising a memory, a processor, and a program stored on the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the steps in an image recognition method for crack detection of stone slabs according to any one of claims 1-7.
Citation Information
Cited By
Method for detecting pollutants in high-purity quartz sand based on image recognition
CN120997832A
A method for detecting pollutants in high-purity quartz sand based on image recognition
CN120997832B