CN-115841450-B - Surface defect detection method, device, terminal and computer readable storage medium
Abstract
The application provides a surface defect detection method, a device, a terminal and a computer readable storage medium, wherein the surface defect detection method comprises the steps of obtaining an image to be detected; the method comprises the steps of carrying out blocking processing on an image to be detected based on each reference sub-image in the reference image to obtain a plurality of sub-images to be detected corresponding to the image to be detected, analyzing the sub-images to be detected to obtain surface characteristic information of the sub-images to be detected, and determining that defects exist on the surface of a target to be detected if differences between the surface characteristic information of the sub-images to be detected and surface preset information of the reference sub-images do not meet corresponding preset requirements. According to the method, the image to be detected is subjected to blocking processing according to each reference subgraph in the reference image to obtain the subgraph to be detected, the surface characteristic information of the subgraph to be detected is determined, whether the surface of the target to be detected has defects or not is determined according to the difference between the subgraph to be detected and the reference subgraph, the method is not limited to the type of the target to be detected, and the generalization performance of the surface defect detection method is improved.
Inventors
- LI NINGCHUAN
- YAN JIN
- XIONG JIANPING
- SUN HAITAO
- ZHAO LEI
- YANG JIANBO
Assignees
- 浙江大华技术股份有限公司
Dates
- Publication Date
- 20260508
- Application Date
- 20220921
Claims (15)
- 1. A surface defect detection method, characterized in that the surface defect detection method comprises: acquiring an image to be detected, wherein the image to be detected is a surface image containing an object to be detected; dividing the image to be detected to obtain a mask image of the image to be detected; extracting the outline of the object to be detected from the mask image of the image to be detected, and determining the position information of the outline of the object to be detected in the mask image of the image to be detected; In response to that the size of the reference target is the same as the size of the target to be detected and the position information of the outline of the target to be detected is consistent with the position information of the outline of the reference target in the mask image of the reference image, the image to be detected is subjected to block processing based on each reference sub-image in the reference image to obtain a plurality of sub-images to be detected corresponding to the image to be detected; Analyzing the subgraph to be detected to obtain surface characteristic information of the subgraph to be detected; And determining that the surface of the target to be detected has defects in response to the fact that the difference between the surface characteristic information of the sub-image to be detected and the surface preset information of the reference sub-image does not meet the corresponding preset requirements.
- 2. The surface defect detection method according to claim 1, wherein after the step of obtaining the image to be detected, wherein the image to be detected includes the target to be detected, the step of performing the partitioning processing on the image to be detected based on each reference sub-image in the reference image to obtain a plurality of sub-images to be detected corresponding to the image to be detected, further includes: And correcting the position information of the outline of the object to be detected according to the position information of the outline of the reference object if the position information of the outline of the object to be detected is inconsistent with the position information of the outline of the reference object in the mask image of the reference image, wherein the size of the reference object is the same as that of the object to be detected.
- 3. The surface defect detection method according to claim 1, wherein the acquiring the image to be detected further comprises: Acquiring the reference image, wherein the reference image comprises the reference target; dividing the reference image based on each contour feature to obtain a plurality of reference subgraphs in response to the existence of the contour feature in the reference image; and in response to the fact that the outline features are not present in the reference image, dividing the reference image based on the positions and gray values of all pixel points to obtain a plurality of reference subgraphs.
- 4. The surface defect detection method of claim 1, wherein the reference subgraph has a first identifier; the surface characteristic information comprises detection gray scale information; analyzing the sub-graph to be detected to obtain surface characteristic information of the sub-graph to be detected, wherein the method comprises the following steps: and responding to the first identifier of the reference subgraph corresponding to the subgraph to be detected, and carrying out gray analysis on the subgraph to be detected to obtain detection gray information of the subgraph to be detected.
- 5. The surface defect detection method of claim 1 or 4, wherein the reference subgraph has a second identifier; the surface feature information includes detection profile information; analyzing the sub-graph to be detected to obtain surface characteristic information of the sub-graph to be detected, wherein the method comprises the following steps: And responding to the second identifier of the reference subgraph corresponding to the subgraph to be detected, and performing contour analysis on the subgraph to be detected to obtain detection contour information of the subgraph to be detected.
- 6. The method for detecting surface defects according to claim 1, wherein, And if the difference between the surface characteristic information of the sub-image to be detected and the surface preset information of the reference sub-image does not meet the corresponding preset requirement, determining that the surface of the target to be detected has a defect, including: determining the sub-image to be detected as a defect sub-image if the difference between the surface characteristic information of the sub-image to be detected and the surface preset information of the reference sub-image does not meet the corresponding preset requirement; And determining that the surface of the target to be detected has defects in response to the fact that the image to be detected contains at least one defect subgraph.
- 7. The surface defect detection method of claim 6, wherein the surface defect detection method further comprises: and carrying out defect type identification on the defect subgraph in the image to be detected to obtain the defect type of the target to be detected.
- 8. The method for detecting surface defects according to claim 7, wherein, Performing defect type recognition on the defect subgraph in the image to be detected to obtain a defect type of the target to be detected, including: Determining a defect grade of the defect subgraph based on a difference value between the surface characteristic information of the defect subgraph and the surface preset information of the reference subgraph at a corresponding position; And determining whether the defect subgraph and other adjacent defect subgraphs need to be combined based on the defect grade and the size of the defect subgraphs, and then carrying out defect type identification to obtain the defect type corresponding to the defect subgraph.
- 9. The surface defect detection method according to claim 8, wherein the surface characteristic information includes detection gray scale information and detection contour information; the determining the defect level of the defect subgraph based on the difference value between the surface characteristic information of the defect subgraph and the surface preset information of the reference subgraph at the corresponding position comprises the following steps: Determining a first defect level of the defect subgraph based on a first difference value between the detected gray level information of the defect subgraph and preset gray level information of the reference subgraph at a corresponding position; Determining a second defect grade of the defect subgraph based on a second difference value between the detected contour information of the defect subgraph and the preset contour information of the reference subgraph at a corresponding position; and determining the defect level of the defect subgraph based on the weighted sum of the first defect level and the second defect level corresponding to the defect subgraph.
- 10. The method for detecting surface defects according to claim 8, wherein, Determining whether the defect sub-graph needs to be combined with other adjacent defect sub-graphs based on the defect level and the size of the defect sub-graph, and then performing defect type recognition to obtain a defect type corresponding to the defect sub-graph, wherein the method comprises the following steps: And in response to the defect grade of the defect subgraph not exceeding a preset grade and the size of the defect subgraph exceeding a preset size, directly identifying the defect type of the defect subgraph to obtain the defect type corresponding to the defect subgraph.
- 11. The method for detecting surface defects according to claim 8, wherein, Determining whether the defect sub-graph needs to be combined with other adjacent defect sub-graphs based on the defect level and the size of the defect sub-graph, and then performing defect type recognition to obtain a defect type corresponding to the defect sub-graph, wherein the method comprises the following steps: in response to the defect level of the defect subgraph exceeding a preset level and the size of the defect subgraph not exceeding a preset size, merging the defect subgraph with the adjacent defect subgraphs to obtain a defect merging subgraph; and carrying out defect type identification on the defect merging subgraph to obtain a defect type corresponding to the defect subgraph.
- 12. The method for detecting surface defects according to claim 8, wherein, Determining whether the defect sub-graph needs to be combined with other adjacent defect sub-graphs based on the defect level and the size of the defect sub-graph, and then performing defect type recognition to obtain a defect type corresponding to the defect sub-graph, wherein the method comprises the following steps: In response to the defect level of the defect subgraph exceeding a preset level and the size of the defect subgraph exceeding a preset size, or if the defect level of the defect subgraph does not exceed the preset level and the size of the defect subgraph does not exceed the preset size, merging the defect subgraph with the defect subgraph adjacent to the defect level and adjacent to the defect level to obtain a defect merged subgraph; and carrying out defect type identification on the defect merging subgraph to obtain a defect type corresponding to the defect subgraph.
- 13. A surface defect detection apparatus, characterized in that the surface defect detection apparatus comprises: The acquisition module is used for acquiring an image to be detected, wherein the image to be detected is a surface image of a target to be detected; The device comprises a segmentation module, a reference image processing module, a segmentation module and a processing module, wherein the segmentation module is used for carrying out segmentation processing on the image to be detected to obtain a mask image of the image to be detected, extracting the outline of a target to be detected from the mask image of the image to be detected, determining the position information of the outline of the target to be detected in the mask image of the image to be detected, responding to the fact that the size of the reference target is the same as that of the target to be detected and the position information of the outline of the target to be detected is consistent with the position information of the outline of the reference target in the mask image of the reference image, and carrying out blocking processing on the image to be detected based on each reference subgraph in the reference image to obtain a plurality of subgraphs to be detected corresponding to the image to be detected; The analysis module is used for analyzing the subgraph to be detected to obtain the surface characteristic information of the subgraph to be detected; And the determining module is used for determining that the surface of the target to be detected has defects in response to the fact that the difference between the surface characteristic information of the sub-image to be detected and the surface preset information of the reference sub-image does not meet the corresponding preset requirement.
- 14. A terminal comprising a memory, a processor and a computer program stored in the memory and running on the processor, the processor being configured to execute program data to implement the steps of the surface defect detection method according to any one of claims 1 to 12.
- 15. A computer readable storage medium, wherein a computer program is stored on the computer readable storage medium, and the computer program when executed by a processor implements the steps of the surface defect detection method according to any one of claims 1 to 12.
Description
Surface defect detection method, device, terminal and computer readable storage medium Technical Field The present invention relates to the field of image processing technologies, and in particular, to a surface defect detection method, a surface defect detection device, a surface defect detection terminal, and a computer readable storage medium. Background The method is characterized in that the method is used as a manufacturing industry country, a large number of products are produced on a factory assembly line every day, and the products can leave a factory after being inspected, wherein one of the products is surface defect detection. Different objects may produce different defect types, and even the same object may produce defects of different situations due to different production processes. Current surface defect detection methods can only detect for a single surface, such as for metal surfaces, even for steel surfaces. And the surface defect detection method is complex and has low generalization performance. Disclosure of Invention The invention mainly solves the technical problem of providing a surface defect detection method, a device, a terminal and a computer readable storage medium, and solves the problem of low generalization performance of the surface detection method in the prior art. The first technical scheme adopted by the invention is to provide a surface defect detection method, which comprises the steps of obtaining an image to be detected, wherein the image to be detected is a surface image containing a target to be detected, carrying out blocking processing on the image to be detected based on each reference sub-image in a reference image to obtain a plurality of sub-images to be detected corresponding to the image to be detected, analyzing the reference image which is an image of the reference target without defects on the surface to obtain surface characteristic information of the sub-image to be detected, and determining that the surface of the target to be detected has defects if the difference between the surface characteristic information of the sub-image to be detected and the surface preset information of the reference sub-image does not meet the corresponding preset requirements. The method comprises the steps of obtaining an image to be detected, after the image to be detected contains a target to be detected, carrying out blocking processing on the image to be detected based on each reference sub-image in a reference image, and before the step of obtaining a plurality of sub-images to be detected corresponding to the image to be detected, further comprising the steps of carrying out segmentation processing on the obtained image to be detected to obtain a mask image of the image to be detected, extracting the outline of the target to be detected from the mask image of the image to be detected, determining the position information of the outline of the target to be detected in the mask image of the image to be detected, and correcting the position information of the outline of the target to be detected according to the position information of the outline of the reference target if the position information of the outline of the target to be detected is inconsistent with the position information of the outline of the reference target in the mask image of the reference image, wherein the size of the reference target is identical with the size of the target to be detected. The method comprises the steps of obtaining an image to be detected, obtaining a reference image, wherein the reference image comprises a reference target, dividing the reference image based on contour features to obtain a plurality of reference subgraphs in response to the existence of the contour features in the reference image, and dividing the reference image based on the positions and gray values of all pixel points to obtain a plurality of reference subgraphs in response to the absence of the contour features in the reference image. The method comprises the steps of responding to the first identifier of the reference sub-image corresponding to the sub-image to be detected, carrying out gray analysis on the sub-image to be detected, and obtaining the detection gray information of the sub-image to be detected. The method comprises the steps of responding to the second identifier of the reference sub-graph corresponding to the sub-graph to be detected, carrying out contour analysis on the sub-graph to be detected, and obtaining detection contour information of the sub-graph to be detected. The method comprises the steps of determining that a target to be detected has defects on the surface in response to the fact that the difference between the surface characteristic information of the sub-image to be detected and the surface preset information of the reference sub-image does not meet corresponding preset requirements, determining that the sub-image to be detected is the defect sub-image in response to the