Image crack number recognition and statistics method, system and storage medium
By combining semantic segmentation and spatial position density clustering algorithms with fitting straight line calculations, the problem of inaccurate crack count statistics in the existing technology is solved, and accurate identification and statistics of scattered cracks with regular trends are achieved, thereby improving the accuracy of identification.
Patent Information
- Application Number
- CN202211422697.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-14
- Publication Date
- 2025-09-23
- Estimated Expiration
- 2042-11-14
AI Technical Summary
Existing technologies have difficulty in accurately counting cracks with obvious directions, especially when the texture is unclear or some areas are blocked, which can easily lead to misjudgment. Traditional methods such as morphology and clustering techniques are too rough, while deep learning requires a large number of labeled samples.
The semantic segmentation algorithm is used to identify pixel-level information of cracks. Combined with spatial position density clustering and fitting line calculation, the Hausdorff distance and the angle between the direction vectors are used to determine whether two cracks are the same crack, and clustering and merging are performed. Finally, the semantic segmentation algorithm is used to identify the fitting line of the cracks. Finally, the Hausdorff distance and the direction vector are used to perform clustering and merging, achieving accurate crack identification and storage medium.
It achieves accurate identification and statistics of scattered cracks with regular directions, improves the accuracy of identifying cracks with obvious directions, unclear textures, and partially obscured areas, and reduces the misjudgment rate.
Smart Images

Figure CN115761231B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of crack identification, and in particular to a method, system and storage medium for identifying and counting the number of cracks in an image. Background Art
[0002] In real-world scenarios, cracks with distinct orientations often appear discontinuous or disconnected when the texture is unclear or partially obscured. Classifying these cracks as distinct can easily lead to misjudgments when counting crack numbers and lengths, resulting in inaccurate decisions. There are two main approaches to this problem. The first involves pixel-level semantic segmentation of the cracks. Morphological and clustering techniques are then used to merge discontinuous cracks before counting them. The second approach utilizes deep learning-based object detection. However, this algorithm requires a large number of labeled samples of discontinuous cracks. The first approach, however, does not require the acquisition of discontinuous crack samples. Its semantic segmentation algorithm can employ conventional image thresholding or a deep learning-based fully convolutional neural network. However, morphological and clustering techniques ignore the inherent orientation of the cracks. The method of directly merging two closely spaced cracks into a single crack is overly crude. This is because for orientation-dependent cracks, if the orientations of two cracks are nearly parallel or completely opposite, they may not be the same crack. Therefore, a better solution to strike-type cracks is needed. Summary of the Invention
[0003] In response to the shortcomings of the existing technology, the purpose of the present invention is to provide a method, system and storage medium for identifying and counting the number of cracks in an image. The cracks are analyzed and counted based on their direction characteristics, and scattered cracks with regular directions can be divided into the same crack. This method has great practical value for cracks with obvious directions, unclear textures, and partially obscured areas.
[0004] In order to achieve the above-mentioned purpose, the present invention adopts the following technical solutions.
[0005] In a first aspect, a method for identifying and counting cracks in an image is provided, comprising:
[0006] S1: Acquire the crack image to be identified;
[0007] S2: Using semantic segmentation algorithm to identify the pixel-level information of cracks in the crack image to be identified;
[0008] S3: Perform spatial position density clustering on the identified crack pixel-level information, with each cluster corresponding to a crack;
[0009] S4: Calculate the fitting line for each crack;
[0010] S5: Calculate the spatial position of the projection point of each crack on its corresponding fitting line, and obtain the two crack endpoint sets corresponding to each crack;
[0011] S6: Select two cracks in a loop and execute the following process:
[0012] S61: Calculate the Hausdorff distance between the crack endpoint sets corresponding to the two cracks, obtain the minimum Hausdorff distance and its corresponding two points as the endpoints of the two cracks, and if the minimum Hausdorff distance is less than the distance threshold, proceed to S62;
[0013] S62: Calculate the direction vectors of the two cracks, the angle between the direction vectors of the two cracks, and the angle between the direction vectors of the two cracks and the direction vectors formed by the endpoints of the two cracks. If all three angles are greater than an angle threshold, the two cracks are determined to be the same crack.
[0014] S7: Merge all two cracks that are considered to be the same crack into one crack, and return to step S4 until all cracks cannot be merged into new cracks, and finally count the final number of cracks.
[0015] Furthermore, the semantic segmentation algorithm adopts a fully convolutional neural network algorithm.
[0016] Furthermore, the DBSCAN algorithm is used to perform spatial position density clustering on the identified crack pixel-level information to obtain the information of each crack and eliminate noise information at the same time.
[0017] Furthermore, the least squares algorithm is used to calculate the fitting line of each crack.
[0018] Furthermore, the two crack endpoint sets corresponding to each crack are obtained in the following manner:
[0019] The two endpoints of the fitting line corresponding to each crack are obtained, and the projection points on the fitting line whose distances from the two endpoints are less than a preset distance are obtained respectively, and two projection point sets are constructed. The points on the crack corresponding to the two projection point sets constitute two crack endpoint sets.
[0020] Furthermore, the step S61 specifically includes:
[0021] For two cracks, the two crack endpoints of one crack are sequentially compared with the two crack endpoints of the other crack to calculate the Hausdorff distance.
[0022] Obtain the minimum Hausdorff distance and the corresponding two crack endpoint sets, and select the two points corresponding to the minimum Hausdorff distance as the endpoints of the two cracks;
[0023] If the minimum Hausdorff distance is less than the distance threshold, it is preliminarily considered that they are the same crack and the process proceeds to S62; otherwise, it is considered that they are not the same crack and two new cracks are selected for calculation.
[0024] Furthermore, the calculating of the direction vectors of the two cracks includes:
[0025] The projection points corresponding to the endpoints of the two cracks are respectively used as the end points of the direction vectors of the two cracks, and the other ends of the fitting lines corresponding to the two cracks are respectively used as the starting points of the direction vectors of the two cracks, thereby obtaining the direction vectors of the two cracks.
[0026] Furthermore, the calculating of the angle between the direction vectors of the two cracks and the angle between the direction vectors of the two cracks and the direction vectors formed by the endpoints of the two cracks specifically includes:
[0027] The angle between the direction vectors of the two cracks is expressed as θ0; the angle between the direction vector of one crack and the direction vector formed by the endpoint A of the crack and the endpoint B of the other crack is expressed as θ1; the angle between the direction vector of the other crack and the direction vector formed by the endpoint B and the starting point A is expressed as θ2; calculate the angles of θ0, θ1, and θ2.
[0028] In a second aspect, a system for identifying and counting cracks in an image is provided, comprising:
[0029] one or more memories having a computer program stored thereon;
[0030] One or more processors are used to implement the steps of the above-mentioned image crack number identification and statistics method when loading and executing the computer program.
[0031] In a third aspect, a computer storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the above-mentioned image crack number identification and statistics method are implemented.
[0032] The present invention proposes a method, system and storage medium for image crack count identification and statistics. First, a semantic segmentation algorithm is used to identify crack pixel information. Then, a spatial position density clustering algorithm is used for clustering, each discontinuous crack is distinguished, and noise pixels are removed. Then, whether two cracks are the same crack is judged, and the judgment criteria include whether the Hausdorff distance between the crack endpoints of the two cracks and the angle between the direction vectors related to the two cracks meet the requirements. For two cracks that are considered to be the same crack, they are merged, and then iterative calculations are performed again until all cracks cannot be merged into new cracks. Finally, accurate crack count statistics are achieved. The present invention uses the crack direction characteristics to analyze and count cracks. It can classify scattered cracks with regular direction as the same crack. It has good practical value for cracks with obvious direction, unclear texture, and partially obscured areas. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0034] Figure 1 This is a flow chart of a method for identifying and counting cracks in an image provided by an embodiment of the present invention;
[0035] Figure 2 This is a schematic diagram of a process for determining whether two cracks are the same crack, provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0036] To make the objectives, technical solutions, and advantages of the present invention more apparent, the technical solutions of the present invention will be described in detail below. Obviously, the embodiments described are only some of the embodiments of the present invention, not all of them. Based on the embodiments of the present invention, all other implementations obtained by those of ordinary skill in the art without inventive effort are within the scope of protection of the present invention.
[0037] Existing crack counting methods are relatively crude, particularly ineffective for processing direction-specific cracks. Therefore, the present invention provides an image crack count identification and counting method, system, and storage medium. These methods utilize the direction characteristics of cracks to analyze and count cracks, classifying scattered cracks with regular directions as the same crack. This method has significant practical value for cracks with distinct directions, unclear textures, or partially obscured areas. The technical solution of the present invention is described in detail below with reference to specific embodiments.
[0038] like Figure 1 As shown, an embodiment of the present invention provides a method for identifying and counting cracks in an image, including:
[0039] S1: Obtain an image of a crack to be identified.
[0040] S2: Use semantic segmentation algorithm to identify the pixel-level information of cracks in the crack image to be identified.
[0041] During implementation, a conventional image threshold segmentation algorithm or a deep learning-based fully convolutional neural network algorithm can be used to perform pixel-level semantic segmentation of cracks in the crack image to be identified to obtain pixel-level crack information.
[0042] S3: Perform spatial position density clustering on the identified crack pixel-level information, with each cluster corresponding to a crack.
[0043] In this embodiment, the DBSCAN algorithm is used to perform spatial position density clustering on the identified crack pixel-level information to obtain the information of each crack and eliminate noise information at the same time.
[0044] Specifically, all crack pixel points identified in step S2 are used as objects to be clustered, and the domain radius R and the minimum number of points MinPts are pre-set. Then, the crack pixel-level information is clustered. It should be noted that the value of the domain radius R is set according to the actual situation and cannot be too large, otherwise two close cracks will be easily merged into one. Through the above-mentioned spatial position density clustering, each discontinuous crack can be distinguished, that is, each cluster corresponds to a crack, and discrete points are eliminated to remove noise pixels and eliminate the interference of noise information.
[0045] S4: Calculate the fitting straight line for each crack.
[0046] In this embodiment, it is assumed that each crack has an obvious direction, and the least squares algorithm is used to calculate the fitting line of each crack, such as Figure 2 As shown, the fitting straight line l1 and the fitting straight line l2 are the fitting straight lines of the two cracks.
[0047] S5: Calculate the spatial position of the projection point of each crack on its corresponding fitting line, and obtain the two crack endpoint sets corresponding to each crack.
[0048] Specifically, the two endpoints of the fitting line corresponding to each crack are obtained, and the distance from each projection point on the fitting line to the two end points of the fitting line is calculated using the Euclidean distance. The projection points on the fitting line whose distances to its two end points are less than the preset distance are obtained respectively, and two projection point sets are constructed. The points on the crack corresponding to each of the two projection point sets constitute two crack endpoint sets, as shown in the following example: Figure 2 The rectangular portion shown.
[0049] S6: Circularly select two cracks and execute steps S61 to S62:
[0050] S61: Calculate the Hausdorff distance between the crack endpoint sets corresponding to the two cracks, obtain the minimum Hausdorff distance and its corresponding two points as the endpoints of the two cracks, and if the minimum Hausdorff distance is less than the distance threshold, enter S62.
[0051] More specifically, step S61 includes:
[0052] S611: For two cracks, the two crack endpoint sets of one crack are sequentially compared with the two crack endpoint sets of the other crack to perform Hausdorff distance calculation.
[0053] S612: Obtain the minimum Hausdorff distance and the corresponding two crack endpoint sets, and select the two points corresponding to the minimum Hausdorff distance as the endpoints of the two cracks.
[0054] S63: If the minimum Hausdorff distance is less than the distance threshold, it is preliminarily considered to be the same crack and enter S62; otherwise, it is considered not to be the same crack, and it is determined whether the cyclic selection of cracks is completed. If not, two cracks are reselected and the process returns to step S611. If so, the process enters step S7.
[0055] The calculation principle of Hausdorff distance is as follows: Assume that there are two crack endpoint sets A = {a1, ..., a p}、B={b1,...,b q}, then the Hausdorff distance between these two crack endpoint sets is defined as:
[0056] H(A,B)=max(h(A,B),h(B,A)) (1)
[0057] h(A, B)=max (a∈A) min (b∈B) ||ab|| (2)
[0058] h(B, A)=max (b∈B) min (a∈A) ||ba|| (3)
[0059] ||·|| is the distance paradigm between the crack endpoint set A and the crack endpoint set B. Formula (1) is called the bidirectional Hausdorff distance, which is the most basic form of the Hausdorff distance; h(A, B) and h(B, A) in Formulas (2) and (3) are called the one-way Hausdorff distances from the crack endpoint set A to the crack endpoint set B and from the crack endpoint set B to the crack endpoint set A, respectively. From Formula (1), we know that the bidirectional Hausdorff distance H(A, B) is the larger of the one-way distances h(A, B) and h(B, A). Figure 2 A schematic diagram of the Hausdorff distance is shown. It can be seen that it is neither the distance between the two edge endpoints of the crack nor the shortest distance between point sets, but rather reflects the distance of the spatial position morphology.
[0060] S62: Calculate the direction vectors of the two cracks, the angle between the direction vectors of the two cracks, and the angle between the direction vectors of the two cracks and the direction vectors formed by the endpoints of the two cracks. If all three angles are greater than the angle threshold, the two cracks are determined to be the same crack.
[0061] More specifically, step S62 includes:
[0062] S621: Determine the direction vectors of the two cracks in the following manner: use the projection points corresponding to the endpoints of the two cracks as the end points of the direction vectors of the two cracks, and use the other ends of the fitting lines corresponding to the two cracks as the starting points of the direction vectors of the two cracks, to obtain the direction vectors of the two cracks. Figure 2 As shown, the endpoints of the two cracks are A and B respectively, and the corresponding projection points a and b are the end points of the direction vector, and the vector parallel to the corresponding fitting line is and is the direction vector.
[0063] S622: The angle between the direction vectors of the two cracks is and The angle between the direction vector of a crack and the direction vector with the endpoint A of the crack as the end point and the endpoint B of the other crack as the starting point is and The angle between the direction vector of the other crack and the direction vector with B as the end point and A as the starting point is and The angle between the two cracks is denoted as θ2; the angles θ0, θ1, and θ2 are calculated. θ0 reflects the consistency of the overall orientation of the two cracks, while θ1 and θ2 reflect the consistency of the orientation of the crack itself and the local orientation of its end. The local orientation of the end is determined by both the end of the crack itself and the end of another nearby crack.
[0064] S623: If the angles of θ0, θ1, and θ2 are all greater than the angle threshold, the two cracks have the same direction and correspond to the vector formed by endpoints A and B. In this case, the two cracks are considered to be the same crack; otherwise, the two cracks are considered to have inconsistent directions and are not the same crack. The angle threshold is set according to the actual situation, such as within the range of 85° to 120°. Generally, 90° can ensure the consistency of the crack direction. Figure 2 As shown in Figure 3, the three angles θ0, θ1, and θ2 are all greater than 90°, and it can be considered that the two cracks have the same direction.
[0065] S624: Determine whether the cyclic selection of cracks is completed. If not, reselect two cracks and return to step S611. If so, enter step S7.
[0066] S7: Merge all two cracks that are considered to be the same crack into one crack, and return to step S4 to repeat the above process until all cracks cannot be merged into new cracks, and finally count the final number of cracks.
[0067] The embodiment of the present invention further provides an image crack number recognition and counting system, comprising:
[0068] one or more memories having a computer program stored thereon;
[0069] One or more processors are used to implement the steps of the above-mentioned image crack number identification and statistics method when loading and executing the computer program.
[0070] The system also includes: a communication interface for communicating with external equipment and performing data interactive transmission.
[0071] The memory may include a high-speed RAM memory, and may also include a non-volatile memory, such as at least one disk memory.
[0072] If the memory, processor, and communication interface are implemented independently, they can be interconnected via a bus and communicate with each other. The bus can be an industrial standard architecture bus, a peripheral device interconnect bus, or an extended industrial standard architecture bus. The bus can be divided into an address bus, a data bus, a control bus, etc.
[0073] Optionally, in a specific implementation, if the memory, processor, and communication interface are integrated on a chip, the memory, processor, and communication interface can communicate with each other through an internal interface.
[0074] For the specific implementation process of each step, please refer to the description of the above method.
[0075] It should be understood that in the embodiments of the present invention, the processor referred to may be a central processing unit (CPU), and the processor may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc. The memory may include a read-only memory and a random access memory, and provides instructions and data to the processor. A portion of the memory may also include a non-volatile random access memory. For example, the memory may also store information about the device type.
[0076] An embodiment of the present invention further provides a computer storage medium having a computer program stored thereon. When the computer program is executed by a processor, the steps of the above-mentioned method for identifying and counting crack numbers in an image are implemented.
[0077] Those skilled in the art will appreciate that the embodiments of the present application can be provided as methods, systems, or computer program products. Therefore, the present application can adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application can adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.
[0078] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the steps in the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0079] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.
[0080] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0081] It can be understood that the same or similar parts of the above embodiments can be referenced to each other, and the contents not described in detail in some embodiments can refer to the same or similar contents in other embodiments.
[0082] Although the embodiments of the present invention have been shown and described above, it will be understood that the above embodiments are illustrative and are not to be construed as limitations on the present invention. A person skilled in the art may change, modify, replace and modify the above embodiments within the scope of the present invention.
Claims
1. A method for identifying and counting crack numbers in an image, characterized in that: include: S1: Acquire the crack image to be identified; S2: Using semantic segmentation algorithm to identify the pixel-level information of cracks in the crack image to be identified; S3: Perform spatial position density clustering on the identified crack pixel-level information, with each cluster corresponding to a crack; S4: Calculate the fitting line for each crack; S5: Calculate the spatial position of the projection point of each crack on its corresponding fitting line, and obtain the two crack endpoint sets corresponding to each crack; S6: Select two cracks in a loop and execute the following process: S61: Calculate the Hausdorff distance between the crack endpoint sets corresponding to the two cracks, obtain the minimum Hausdorff distance and its corresponding two points as the endpoints of the two cracks, and if the minimum Hausdorff distance is less than the distance threshold, proceed to S62; S62: Calculate the direction vectors of the two cracks, the angle between the direction vectors of the two cracks, and the angle between the direction vectors of the two cracks and the direction vectors formed by the endpoints of the two cracks. If all three angles are greater than an angle threshold, the two cracks are determined to be the same crack. S7: Merge all two cracks that are considered to be the same crack into one crack, and return to step S4 until all cracks cannot be merged into new cracks, and finally count the final number of cracks.
2. The image crack number identification and counting method according to claim 1, characterized in that: The semantic segmentation algorithm adopts a fully convolutional neural network algorithm.
3. The image crack number identification and counting method according to claim 1, characterized in that: The DBSCAN algorithm is used to perform spatial position density clustering on the identified crack pixel-level information to obtain the information of each crack and remove noise pixels at the same time.
4. The image crack number identification and counting method according to claim 1, characterized in that: The least squares algorithm is used to calculate the fitting straight line for each crack.
5. The image crack number identification and counting method according to claim 1, characterized in that: The two crack endpoint sets corresponding to each crack are obtained as follows: The two endpoints of the fitting line corresponding to each crack are obtained, and the projection points on the fitting line whose distances from the two endpoints are less than a preset distance are obtained respectively, and two projection point sets are constructed. The points on the crack corresponding to the two projection point sets constitute two crack endpoint sets.
6. The method for identifying and counting crack numbers in an image according to any one of claims 1 to 5, characterized in that: The step S61 specifically includes: For two cracks, the two crack endpoints of one crack are sequentially compared with the two crack endpoints of the other crack to calculate the Hausdorff distance. Obtain the minimum Hausdorff distance and the corresponding two crack endpoint sets, and select the two points corresponding to the minimum Hausdorff distance as the endpoints of the two cracks; If the minimum Hausdorff distance is less than the distance threshold, it is preliminarily considered that they are the same crack and the process proceeds to S62; otherwise, it is considered that they are not the same crack and two new cracks are selected for calculation.
7. The method for identifying and counting crack numbers in an image according to any one of claims 1 to 5, characterized in that: The calculation of the direction vectors of the two cracks includes: The projection points corresponding to the endpoints of the two cracks are respectively used as the end points of the direction vectors of the two cracks, and the other ends of the fitting lines corresponding to the two cracks are respectively used as the starting points of the direction vectors of the two cracks, thereby obtaining the direction vectors of the two cracks.
8. The method for identifying and counting crack numbers in an image according to any one of claims 1 to 5, characterized in that: The calculating of the angle between the direction vectors of the two cracks and the angle between the direction vectors of the two cracks and the direction vectors formed by the endpoints of the two cracks specifically includes: The angle between the direction vectors of the two cracks is expressed as θ0; the angle between the direction vector of one crack and the direction vector formed by the endpoint A of the crack and the endpoint B of the other crack is expressed as θ1; the angle between the direction vector of the other crack and the direction vector formed by the endpoint B and the starting point A is expressed as θ2; calculate the angles of θ0, θ1, and θ2.
9. An image crack number recognition and statistics system, characterized in that: include: one or more memories having a computer program stored thereon; One or more processors are configured to implement the steps of the image crack number identification and statistics method according to any one of claims 1 to 8 when loading and executing the computer program.
10. A computer storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the image crack number identification and statistics method according to any one of claims 1 to 8 are implemented.
Citation Information
Patent Citations
NLM filtering finger vein denoising method based on skin crack segmentation
CN110188614A
Crack re-identification method and device
CN114898107A