Surface defect detection method, device, terminal and computer readable storage medium

By segmenting the image to be detected and analyzing its feature information, the problem of low generalization performance in existing technologies is solved, and efficient surface defect detection applicable to a variety of objects is achieved.

CN115841450BActive Publication Date: 2026-05-08ZHEJIANG DAHUA TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
ZHEJIANG DAHUA TECH CO LTD
Filing Date
2022-09-21
Publication Date
2026-05-08

AI Technical Summary

Technical Problem

Existing surface defect detection methods have low generalization performance, cannot be applied to a variety of objects, and are complex to use.

Method used

By acquiring the image to be detected and performing block processing based on the reference image, a sub-image to be detected is obtained. The differences are analyzed using surface feature information to determine defects. The defect type and level are identified by combining grayscale and contour information. This method is applicable to the detection of different types of surface defects.

Benefits of technology

It improves the generalization performance of surface defect detection, making it applicable to surface defect detection of various objects and simplifying the detection process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115841450B_ABST
    Figure CN115841450B_ABST
Patent Text Reader

Abstract

The application provides a surface defect detection method, device, terminal and computer readable storage medium, the surface defect detection method comprises: obtaining an image to be detected; based on each reference subgraph in a reference image, the image to be detected is processed by blocking to obtain a plurality of subgraphs to be detected corresponding to the image to be detected; the surface characteristic information of the subgraph to be detected is obtained by analyzing the subgraph to be detected; in response to the difference between the surface characteristic information of the subgraph to be detected and the surface preset information of the reference subgraph not meeting the corresponding preset requirement, it is determined that the surface of the target to be detected has defects. According to the application, the image to be detected is processed by blocking according to each reference subgraph in the reference image to obtain the subgraph to be detected, and the surface characteristic information of the subgraph to be detected is determined, and whether the surface of the target to be detected has defects 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 target to be detected, and the generalization performance of the surface defect detection method is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image processing technology, and in particular to a surface defect detection method, apparatus, terminal, and computer-readable storage medium. Background Technology

[0002] As a major manufacturing country, my country produces a large number of products daily on factory assembly lines. These products need to undergo inspection before leaving the factory, one of which is surface defect detection. Different objects will produce different types of defects, and even the same object will produce different defects due to different manufacturing processes. Current surface defect detection methods can only be used to inspect a single surface, such as metal surfaces or even steel surfaces. Furthermore, surface defect detection methods are relatively complex and have low generalization ability. Summary of the Invention

[0003] The main technical problem solved by this invention is to provide a surface defect detection method, device, terminal and computer-readable storage medium, thereby solving the problem of low generalization performance of existing surface detection methods.

[0004] To solve the above-mentioned technical problems, the first technical solution adopted by the present invention is: to provide a surface defect detection method, the surface defect detection method comprising: acquiring an image to be detected, the image to be detected being a surface image containing a target to be detected; dividing the image to be detected into blocks based on each reference sub-image in a reference image to obtain multiple sub-images to be detected corresponding to the image to be detected; the reference image being an image of a reference target with no surface defects; analyzing the sub-images to be detected to obtain surface feature information of the sub-images to be detected; and determining that the surface of the target to be detected has defects if the difference between the surface feature information of the sub-images to be detected and the surface preset information of the reference sub-images does not meet the corresponding preset requirements.

[0005] The process includes, after the step of acquiring the image to be detected, which contains the target to be detected, and before the step of segmenting the image to be detected based on each reference sub-image in the reference image to obtain multiple sub-images to be detected corresponding to the image to be detected, the following steps are also included: segmenting the acquired image to be detected to obtain a mask image of the image to be detected; extracting the contour of the target to be detected from the mask image of the image to be detected, and determining the position information of the contour of the target to be detected in the mask image of the image to be detected; in response to the inconsistency between the position information of the contour of the target to be detected and the position information of the contour of the reference target in the mask image of the reference image, correcting the position information of the contour of the target to be detected based on the position information of the contour of the reference target; the size of the reference target is the same as the size of the target to be detected.

[0006] The process of acquiring the image to be detected includes, prior to: acquiring a reference image; the reference image containing a reference target; in response to the presence of contour features in the reference image, dividing the reference image into multiple reference sub-images based on each contour feature; and in response to the absence of contour features in the reference image, dividing the reference image into multiple reference sub-images based on the position and grayscale value of each pixel.

[0007] The reference sub-image has a first identifier; the surface feature information includes detection grayscale information; the surface feature information of the sub-image to be detected is analyzed to obtain the surface feature information of the sub-image to be detected, including: in response to the reference sub-image corresponding to the sub-image to be detected having a first identifier, grayscale analysis is performed on the sub-image to be detected to obtain the detection grayscale information of the sub-image to be detected.

[0008] The reference sub-image has a second identifier; the surface feature information includes detection contour information; the surface feature information of the sub-image to be detected is analyzed to obtain the surface feature information of the sub-image to be detected, including: in response to the reference sub-image corresponding to the sub-image to be detected having a second identifier, the sub-image to be detected is contour analyzed to obtain the detection contour information of the sub-image to be detected.

[0009] Specifically, if the difference between the surface feature 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, then it is determined that the surface of the target to be detected has a defect, including: if the difference between the surface feature 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, then it is determined that the sub-image to be detected is a defective sub-image; if the image to be detected contains at least one defective sub-image, then it is determined that the surface of the target to be detected has a defect.

[0010] The surface defect detection method further includes: identifying the defect type in the defect sub-image of the image to be detected to obtain the defect category of the target to be detected.

[0011] The process of identifying the defect type of the defect sub-image in the image to be detected and obtaining the defect category of the target to be detected includes: determining the defect level of the defect sub-image based on the difference between the surface feature information of the defect sub-image and the surface preset information of the reference sub-image at the corresponding position; and determining whether the defect sub-image needs to be merged with other neighboring defect sub-images before performing defect type identification to obtain the defect category corresponding to the defect sub-image based on the defect level and size of the defect sub-image.

[0012] The surface feature information includes detection grayscale information and detection contour information. The defect level of the defect sub-image is determined based on the difference between the surface feature information of the defect sub-image and the preset surface information of the reference sub-image at the corresponding position. This includes: determining a first defect level of the defect sub-image based on a first difference between the detection grayscale information of the defect sub-image and the preset grayscale information of the reference sub-image at the corresponding position; determining a second defect level of the defect sub-image based on a second difference between the detection contour information of the defect sub-image and the preset contour information of the reference sub-image at the corresponding position; and determining the defect level of the defect sub-image based on the weighted sum of the first and second defect levels.

[0013] Specifically, based on the defect level and size of the defect sub-image, it is determined whether the defect sub-image needs to be merged with other neighboring defect sub-images before defect type identification to obtain the defect category corresponding to the defect sub-image. This includes: if the defect level of the defect sub-image does not exceed a preset level and the size of the defect sub-image exceeds a preset size, then defect type identification is directly performed on the defect sub-image to obtain the defect category corresponding to the defect sub-image.

[0014] Specifically, based on the defect level and size of the defect sub-image, it is determined whether the defect sub-image needs to be merged with other neighboring defect sub-images before defect type identification to obtain the defect category corresponding to the defect sub-image. This includes: in response to the defect level of the defect sub-image exceeding a preset level and the size of the defect sub-image not exceeding a preset size, merging the defect sub-image with neighboring defect sub-images to obtain a defect merged sub-image; and performing defect type identification on the defect merged sub-image to obtain the defect category corresponding to the defect sub-image.

[0015] Specifically, based on the defect level and size of the defect sub-image, it is determined whether the defect sub-image needs to be merged with other neighboring defect sub-images before defect type identification to obtain the defect category corresponding to the defect sub-image. This includes: in response to the defect sub-image's defect level exceeding a preset level and its size exceeding a preset size, or the defect sub-image's defect level not exceeding a preset level and its size not exceeding a preset size, the defect sub-image is merged with neighboring defect sub-images that are also adjacent in location and defect level to obtain a defect merged sub-image; and defect type identification is performed on the defect merged sub-image to obtain the defect category corresponding to the defect sub-image.

[0016] To solve the above-mentioned technical problems, the second technical solution adopted by the present invention is: to provide a surface defect detection device, the surface defect detection device comprising: an acquisition module for acquiring an image to be detected, the image to be detected being a surface image of a target to be detected; a segmentation module for segmenting the image to be detected based on each reference sub-image in a reference image to obtain multiple sub-images to be detected corresponding to the image to be detected; the reference image being an image of a reference target with no surface defects; an analysis module for analyzing the sub-images to be detected to obtain surface feature information of the sub-images to be detected; and a determination module for determining that the surface of the target to be detected has defects if the difference between the surface feature 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.

[0017] To solve the above-mentioned technical problems, the third technical solution adopted by the present invention is to provide a terminal, which includes a memory, a processor, and a computer program stored in the memory and running on the processor. The processor is used to execute program data to implement the steps in the above-mentioned surface defect detection method.

[0018] To solve the above-mentioned technical problems, the fourth technical solution adopted by the present invention is to provide a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, it implements the steps in the above-mentioned surface defect detection method.

[0019] The beneficial effects of this invention are as follows: Unlike existing technologies, this invention provides a surface defect detection method, apparatus, terminal, and computer-readable storage medium. The surface defect detection method includes: acquiring an image to be detected, which is a surface image containing a target to be detected; segmenting the image to be detected based on reference sub-images in a reference image to obtain multiple sub-images to be detected corresponding to the image to be detected; the reference image is an image of a reference target with a defect-free surface; analyzing the sub-images to be detected to obtain surface feature information; and determining that the surface of the target to be detected has a defect if the difference between the surface feature 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. This application segments the image to be detected based on reference sub-images in a reference image to obtain sub-images to be detected, analyzes the surface features of the sub-images to be detected to determine their surface feature information, and determines whether the surface of the target to be detected has a defect based on the surface feature differences between the sub-images to be detected and the corresponding reference sub-images. This method is not limited to the type of target to be detected, thereby improving the generalization performance of the surface defect detection method. Attached Figure Description

[0020] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0021] Figure 1 This is a schematic flowchart of the surface defect detection method provided by the present invention;

[0022] Figure 2 This is a flowchart illustrating a specific embodiment of the surface defect detection method provided by the present invention;

[0023] Figure 3 yes Figure 2 A flowchart illustrating a specific embodiment of step S210 in the provided surface defect detection method;

[0024] Figure 4 This is a schematic diagram of the framework of an embodiment of the surface defect detection device provided by the present invention;

[0025] Figure 5 This is a schematic diagram of the frame of another embodiment of the surface defect detection device provided by the present invention;

[0026] Figure 6 This is a schematic diagram of the framework of an embodiment of the terminal provided in this application;

[0027] Figure 7 A schematic diagram of a framework of an embodiment of the computer-readable storage medium provided in this application. Detailed Implementation

[0028] The embodiments of this application will now be described in detail with reference to the accompanying drawings.

[0029] In the following description, specific details such as particular system architectures, interfaces, and technologies are presented for illustrative purposes rather than for limiting purposes, in order to provide a thorough understanding of this application.

[0030] In this article, the term "and / or" simply describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone. Additionally, the character " / " generally indicates that the preceding and following related objects have an "or" relationship. Furthermore, "more" in this article means two or more objects.

[0031] To enable those skilled in the art to better understand the technical solution of the present invention, the following describes in further detail a surface defect detection method provided by the present invention in conjunction with the accompanying drawings and specific embodiments.

[0032] With the development of technologies such as machine vision, machine learning, and deep learning, many methods have been applied to the field of surface defect detection. However, current methods are relatively targeted, such as those for metal surfaces or even steel surfaces. These methods are quite complex and cannot be used for a wide range of objects.

[0033] Please see Figure 1 , Figure 1 This is a schematic flowchart of the surface defect detection method provided by the present invention. This embodiment provides a surface defect detection method, which includes the following steps.

[0034] S11: Obtain the image to be detected.

[0035] Specifically, the image to be detected contains the target to be detected.

[0036] In one embodiment, a reference image is acquired; the reference image contains a reference target; in response to the presence of contour features in the reference image, a reference sub-image is obtained by segmenting the reference image based on each contour feature; in response to the absence of contour features in the reference image, a reference sub-image is obtained by segmenting the reference image based on the position and grayscale value of each pixel. The reference sub-image has a first identifier and a second identifier.

[0037] S12: Based on each reference sub-image in the reference image, the image to be detected is divided into blocks to obtain multiple sub-images to be detected corresponding to the image to be detected.

[0038] The acquired image to be detected is segmented to obtain a mask image of the image to be detected; the contour of the target to be detected is extracted from the mask image of the image to be detected, and the position information of the contour of the target to be detected in the mask image of the image to be detected is determined; in response to the inconsistency between the position information of the contour of the target to be detected and the position information of the contour of the reference target in the mask image of the reference image, the position information of the contour of the target to be detected is corrected according to the position information of the contour of the reference target; the size of the reference target is the same as the size of the target to be detected.

[0039] In response to the fact that the size of the reference image is the same as the size of the target to be detected, and the position information of the target to be detected in the target image is consistent with the position information of the reference target in the reference image, the target image to be detected is divided into blocks based on each reference sub-image in the reference image. Here, the target to be detected is the same as the reference target. The reference image is an image of a reference target with a defect-free surface.

[0040] S13: Analyze the sub-image to be detected to obtain the surface feature information of the sub-image to be detected.

[0041] Specifically, the surface feature information includes at least one of the detected grayscale information and detected contour information.

[0042] In one embodiment, in response to the reference sub-image corresponding to the sub-image to be detected having a first identifier, grayscale analysis is performed on the sub-image to be detected to obtain the detection grayscale information of the sub-image to be detected; the detection grayscale information includes at least one of the maximum grayscale value, minimum grayscale value, average grayscale value, grayscale variance value, and grayscale histogram.

[0043] In one embodiment, in response to the reference subgraph corresponding to the subgraph to be detected having a second identifier, contour analysis is performed on the subgraph to be detected to obtain the detection contour information of the subgraph to be detected; the detection contour information includes at least one of contour shape, contour area, contour number, contour position, and contour perimeter.

[0044] S14: In response to the fact that the difference between the surface feature 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, it is determined that there is a defect on the surface of the target to be detected.

[0045] Specifically, if the grayscale difference between the detected grayscale information of the sub-image to be detected and the preset grayscale information of the reference sub-image, or the contour difference between the detected contour information of the sub-image to be detected and the preset contour information of the reference sub-image, does not meet the corresponding preset requirements, then it is determined that there is a defect on the surface of the target to be detected.

[0046] Specifically, if the difference between the surface feature 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, then the sub-image to be detected is determined to be a defective sub-image; if the image to be detected contains at least one defective sub-image, then the surface of the target to be detected is determined to have a defect.

[0047] In one embodiment, defect type identification is performed on the defect sub-image in the image to be detected to obtain the defect category of the target to be detected.

[0048] Based on the difference between the surface feature information of the defect sub-image and the preset surface information of the reference sub-image at the corresponding position, the defect level of the defect sub-image is determined; based on the defect level and size of the defect sub-image, it is determined whether the defect sub-image needs to be merged with other neighboring defect sub-images before defect type identification to obtain the defect category corresponding to the defect sub-image.

[0049] In one embodiment, the defect level of the defect sub-image is determined based on a first difference between the detected grayscale information of the defect sub-image and the preset grayscale information of the reference sub-image at the corresponding position, and / or a second difference between the detected contour information of the defect sub-image and the preset contour information of the reference sub-image at the corresponding position. Based on the defect level and size of the defect sub-image, it is determined whether the defect sub-image needs to be merged with other neighboring defect sub-images before defect type identification is performed to obtain the defect category corresponding to the defect sub-image.

[0050] In one embodiment, a first defect level of the defect sub-image is determined based on a first difference between the detected grayscale information of the defect sub-image and the preset grayscale information of the reference sub-image at the corresponding position; a second defect level of the defect sub-image is determined based on a second difference between the detected contour information of the defect sub-image and the preset contour information of the reference sub-image at the corresponding position; and a defect level of the defect sub-image is determined based on a weighted sum of the first and second defect levels corresponding to the defect sub-image.

[0051] In one embodiment, in response to the defect level of the defect subgraph not exceeding a preset level and the size of the defect subgraph exceeding a preset size, the defect type is directly identified to obtain the defect category corresponding to the defect subgraph.

[0052] In one specific embodiment, in response to the defect level of a defect subgraph exceeding a preset level and the size of the defect subgraph not exceeding a preset size, the defect subgraph is merged with neighboring defect subgraphs to obtain a defect merged subgraph; the defect type is identified on the defect merged subgraph to obtain the defect category corresponding to the defect subgraph.

[0053] In one specific embodiment, in response to the defect level of the defect sub-image exceeding a preset level and the size of the defect sub-image exceeding a preset size, or the defect level of the defect sub-image not exceeding a preset level and the size of the defect sub-image not exceeding a preset size, the defect sub-image is merged with a defect sub-image that is adjacent in location and has an adjacent defect level to obtain a defect merged sub-image; the defect type is identified on the defect merged sub-image to obtain the defect category corresponding to the defect sub-image.

[0054] The surface defect detection method provided in this application acquires an image to be detected, which contains the target to be detected; it divides the image to be detected into blocks based on each reference sub-image in a reference image to obtain multiple sub-images to be detected corresponding to the image to be detected; the reference image is an image of a reference target with no surface defects; the sub-images to be detected are analyzed to obtain the detection grayscale information and / or detection contour information of the sub-images to be detected; in response to the grayscale difference between the detection grayscale information of the sub-image to be detected and the preset grayscale information of the reference sub-image, or the contour difference between the detection contour information of the sub-image to be detected and the preset contour information of the reference sub-image, the surface of the target to be detected is determined to have defects. This application divides the image to be detected into blocks based on each reference sub-image in the reference image to obtain the sub-images to be detected, performs grayscale analysis and / or contour analysis on the sub-images to be detected to determine the detection grayscale information and detection contour information of the sub-images to be detected, and determines whether there are defects on the surface of the target to be detected based on the grayscale difference and contour difference between the sub-images to be detected and the corresponding reference sub-images. This method is not limited to the type of target to be detected, thereby improving the generalization performance of the surface defect detection method.

[0055] Please see Figure 2 , Figure 2 This is a flowchart illustrating a specific embodiment of the surface defect detection method provided by the present invention. This embodiment provides a surface defect detection method applicable to situations where the target to be detected has a reference target that conforms to a standard, and the reference target that conforms to the standard can serve as a reference object for the target to be detected. The surface defect detection method includes the following steps.

[0056] S201: Obtain a reference image.

[0057] Specifically, the reference image includes a reference target. The reference image is simply a surface image of the reference target with a defect-free surface.

[0058] Image acquisition equipment is installed on the production line. The field of view, position, and parameters of the equipment are adjusted to ensure the lens can capture the area of ​​the target to be identified. Specifically, by adjusting the number, position, and type of light sources, the acquired images can be effectively distinguished between foreground and background areas during subsequent processing. Adjusting the camera's exposure time ensures that the images of moving targets on the production line are not blurry. Adjacent images may overlap.

[0059] In one embodiment, a surface image of a target conforming to a standard is acquired using an image acquisition device. The target conforming to the standard is a reference target with a defect-free surface. The acquired standard image with a defect-free surface is used as a reference image. The reference image does not include a background image.

[0060] In one specific embodiment, a surface image of a standard target with no surface defects is acquired and binarized to obtain a mask image of the surface image. Based on the position and contour of the foreground region in the mask image, a region image is extracted from the surface image and used as a reference image. In other embodiments, the foreground image and background image can also be distinguished in other ways to obtain a foreground image as a reference image.

[0061] S202: In response to the presence of contour features in the reference image, the reference image is divided into reference sub-images based on each contour feature.

[0062] Specifically, this is determined by whether contour features exist in the mask image corresponding to the reference image. These contour features include features that are clearly distinguishable from a flat surface, such as circular holes, protrusions, and depressions.

[0063] If the reference image contains contour features, it is divided into multiple reference sub-images based on these features. Specifically, the area containing a circular hole is divided into one reference sub-image, and the area containing a protrusion or a depression is divided into another reference sub-image.

[0064] S203: In response to the absence of contour features in the reference image, the reference image is divided into reference sub-images based on the position and gray value of each pixel.

[0065] Specifically, if the reference image lacks contour features, it can be segmented based on the position and grayscale value of each pixel. Since the grayscale values ​​of pixels corresponding to surfaces with the same feature are similar, the reference image can be divided into multiple reference sub-images based on these similar grayscale values.

[0066] Specifically, the difference between the grayscale values ​​of two adjacent pixels is calculated. If the difference exceeds a threshold, a reference image is segmented between the two pixels. All adjacent pixels in the reference image are traversed to determine the segmentation boundaries. Based on these boundaries, the reference image is divided into multiple reference sub-images.

[0067] In another embodiment, the reference image can be divided into blocks according to the actual situation to obtain multiple reference sub-images corresponding to the reference image. The sizes of the multiple reference sub-images can all be different, or they can be partially the same or completely identical. For example, the sizes of the reference sub-images can be 16*16, 32*32, 4*80, etc.

[0068] In one embodiment, since the reference sub-images contain diverse features, only grayscale analysis or contour analysis can be performed on the reference sub-images to reduce computational load, accelerate processing speed, and identify defects. Furthermore, based on the presence or absence of obvious contour features in the reference sub-images, an association identifier is determined for the reference sub-images. Specifically, the reference sub-images are associated with a first identifier and / or a second identifier.

[0069] If a reference sub-image is associated only with a first identifier, then grayscale analysis is performed only on the reference sub-image. Specifically, based on the grayscale values ​​of all pixels contained in each reference sub-image, the preset grayscale information corresponding to each reference sub-image is determined. The preset grayscale information of the reference sub-image includes the maximum grayscale value, minimum grayscale value, average grayscale value, grayscale variance value, and grayscale histogram.

[0070] If a reference subgraph is associated only with a second identifier, contour analysis is performed only on the reference subgraph. Specifically, each reference subgraph is binarized to obtain a mask image of each reference subgraph. Contour extraction is then performed on the mask images of the reference subgraphs to obtain the preset contour information of each reference subgraph. The preset contour information of the reference subgraph includes contour shape, contour area, contour number, contour position, and contour perimeter.

[0071] When a reference subgraph is associated with both a first identifier and a second identifier, grayscale analysis and contour analysis are required for the reference subgraph.

[0072] S204: Acquire the image to be detected.

[0073] Specifically, the image to be detected contains the target to be detected.

[0074] In one embodiment, the acquired image to be detected is binarized to obtain a mask image of the image to be detected. The contour of the target to be detected is extracted from the mask image of the image to be detected, and the position information of the contour of the target to be detected in the mask image of the image to be detected is determined.

[0075] In response to a discrepancy between the positional information of the target's contour and the positional information of the reference target's contour in the mask image of the reference image, the positional information of the target's contour is corrected based on the positional information of the reference target's contour; the size of the reference target is the same as the size of the target to be detected. The image to be detected is the image of the surface of the target to be detected.

[0076] In one specific embodiment, the contour of the target to be detected can be initially compared with the contour of a reference target. If the dimensions and shape of the contours of the target to be detected and the reference target are identical, further contour analysis and / or grayscale analysis are performed on the target to be detected. If the dimensions or shape of the contours of the target to be detected are inconsistent with the contours of the reference target, in order to reduce computational load, it is directly determined that a defect exists on the surface of the target to be detected, and contour analysis and / or grayscale analysis are not required.

[0077] S205: Based on each reference sub-image in the reference image, the image to be detected is divided into blocks to obtain multiple sub-images to be detected corresponding to the image to be detected.

[0078] Specifically, the locations of the dividing boundaries of the reference image are mapped onto the image to be detected, and the image to be detected is divided into blocks to obtain multiple sub-images to be detected. The size and shape of each sub-image to be detected in the image to be detected are identical to the size and shape of the corresponding reference sub-image in the reference image. Figure 1 One-to-one correspondence.

[0079] S206: In response to the fact that the reference sub-image corresponding to the sub-image to be detected has a first identifier, grayscale analysis is performed on the sub-image to be detected to obtain the detection grayscale information of the sub-image to be detected.

[0080] Specifically, in response to the reference sub-image corresponding to the sub-image to be detected having a first identifier, grayscale analysis is performed on the sub-image to be detected corresponding to the reference sub-image to obtain the detection grayscale information of the sub-image to be detected. The detection grayscale information includes at least one of the following: maximum grayscale value, minimum grayscale value, average grayscale value, grayscale variance value, and grayscale histogram.

[0081] S207: In response to the fact that the reference subgraph corresponding to the subgraph to be detected has a second identifier, contour analysis is performed on the subgraph to be detected to obtain the detection contour information of the subgraph to be detected.

[0082] Specifically, in response to the reference subgraph corresponding to the subgraph to be detected having a second identifier, contour analysis is performed on the subgraph to be detected corresponding to the reference subgraph to obtain the detection contour information of the subgraph to be detected. The detection contour information includes at least one of contour shape, contour area, contour quantity, contour position, and contour perimeter.

[0083] S208: In response to the grayscale difference between the detected grayscale information of the sub-image to be detected and the preset grayscale information of the reference sub-image, or the contour difference between the detected contour information of the sub-image to be detected and the preset contour information of the reference sub-image, which does not meet the corresponding preset requirements, the sub-image to be detected is determined to be a defective sub-image.

[0084] Specifically, in response to the reference sub-image corresponding to the sub-image to be detected having a first identifier, the grayscale difference between the detected grayscale information of the sub-image to be detected at the corresponding position and the preset grayscale information of the reference sub-image is calculated, and based on whether the grayscale difference between the sub-image to be detected and the reference sub-image meets the preset requirements, it is determined whether the sub-image to be detected is a defective sub-image.

[0085] In one embodiment, it is determined whether the difference between the maximum grayscale value of the sub-image to be detected and the maximum grayscale value of the reference sub-image is greater than a threshold. If the difference between the maximum grayscale value of the sub-image to be detected and the maximum grayscale value of the reference sub-image is greater than the threshold, the sub-image to be detected is determined to be a defective sub-image. If the difference between the maximum grayscale value of the sub-image to be detected and the maximum grayscale value of the reference sub-image is not greater than the threshold, the sub-image to be detected is determined to be a defect-free sub-image. All sub-images to be detected contained in the image to be detected are traversed to determine whether each sub-image to be detected is a defective or defect-free sub-image.

[0086] In one specific embodiment, if the difference between the average grayscale value of the sub-image to be detected and the average grayscale value of the reference sub-image is greater than a threshold, then the sub-image to be detected is directly determined to be a defective sub-image.

[0087] In another specific embodiment, the sub-image to be detected can be determined to be a defective sub-image only when the difference between the maximum gray value of the sub-image to be detected and the maximum gray value of the reference sub-image is greater than a threshold, and the difference between the minimum gray value of the sub-image to be detected and the minimum gray value of the reference sub-image is greater than a threshold.

[0088] In response to the reference sub-image corresponding to the sub-image to be detected having a second identifier, the contour difference between the detection contour information of the sub-image to be detected at the corresponding position and the preset contour information of the reference sub-image is calculated. Based on whether the contour difference between the sub-image to be detected and the reference sub-image meets the preset requirements, it is determined whether the sub-image to be detected is a defective sub-image.

[0089] In one embodiment, it is determined whether the similarity between the contour shape of the sub-image to be detected and the contour shape of the reference sub-image is greater than a threshold. If the similarity between the contour shape of the sub-image to be detected and the contour shape of the reference sub-image is greater than the threshold, the sub-image to be detected is determined to be a defect-free sub-image. If the similarity between the contour shape of the sub-image to be detected and the contour shape of the reference sub-image is not greater than the threshold, the sub-image to be detected is determined to be a defective sub-image. All sub-images to be detected contained in the image to be detected are traversed to determine whether each sub-image to be detected is a defective or defect-free sub-image.

[0090] In one embodiment, it is determined whether the difference between the contour position / contour perimeter / contour quantity of the sub-image to be detected and the contour position / contour perimeter / contour quantity of the reference sub-image is greater than a threshold. If the difference between the contour position / contour perimeter / contour quantity of the sub-image to be detected and the contour position / contour perimeter / contour quantity of the reference sub-image is greater than the threshold, the sub-image to be detected is determined to be a defective sub-image. If the difference between the contour position / contour perimeter / contour quantity of the sub-image to be detected and the contour position / contour perimeter / contour quantity of the reference sub-image is not greater than the threshold, the sub-image to be detected is determined to be a defect-free sub-image.

[0091] S209: In response to the fact that the image to be detected contains at least one defect sub-image, it is determined that there is a defect on the surface of the target to be detected.

[0092] Specifically, if there is a defective sub-image in the image to be detected, it is directly determined that there is a defect in the image to be detected, and that the target to be detected in the image to be detected is defective.

[0093] S210: Perform defect type identification on the defect sub-image in the image to be detected to obtain the defect category of the target to be detected.

[0094] Specifically, the steps for identifying the defect categories in the image to be detected are as follows.

[0095] Please see Figure 3 , Figure 3 yes Figure 2 A flowchart illustrating a specific embodiment of step S210 in the provided surface defect detection method.

[0096] S2101: Determine the defect level of the defect sub-image based on the first difference between the detected grayscale information of the defect sub-image and the preset grayscale information of the reference sub-image at the corresponding position and / or the second difference between the detected contour information of the defect sub-image and the preset contour information of the reference sub-image at the corresponding position.

[0097] Specifically, a first defect level of the defect sub-image is determined based on a first difference between the detected grayscale information of the defect sub-image and the preset grayscale information of the reference sub-image at the corresponding position; a second defect level of the defect sub-image is determined based on a second difference between the detected contour information of the defect sub-image and the preset contour information of the reference sub-image at the corresponding position; and the final defect level of the defect sub-image is determined based on a weighted sum of the first and second defect levels. The weighting coefficients for the first and second defect levels can be set empirically.

[0098] In one specific embodiment, the grayscale defect value tmp_level_gray_i is calculated based on the following formula 1.

[0099] tmp_level_gray_i=k_min_i*diff_min_i+k_max_i*diff_max_i+k_mean_i*diff_mean_i+k_var_i*diff_var_i (Formula 1)

[0100] In Formula 1: tmp_level_gray_i represents the grayscale defect value of the defect sub-image, k_min_i, k_max_i, k_mean_i and k_var_i represent weighting coefficients, and k_min_i+k_max_i+k_mean_i+k_var_i=1, diff_min_i represents the deviation value of the minimum grayscale value, diff_max_i represents the deviation value of the maximum grayscale value, diff_mean_i represents the deviation value of the average grayscale value, and diff_var_i represents the deviation value of the grayscale variance value.

[0101] Specifically, the deviation of the minimum grayscale value is determined by subtracting a threshold from the absolute value of the difference between the minimum grayscale value of the defect subimage and the minimum grayscale value of the reference subimage. The deviation of the maximum grayscale value is also determined by subtracting a threshold from the absolute value of the difference between the maximum grayscale value of the defect subimage and the maximum grayscale value of the reference subimage. The deviation of the average grayscale value is determined by subtracting a threshold from the absolute value of the difference between the average grayscale value of the defect subimage and the average grayscale value of the reference subimage. The deviation of the grayscale variance is determined by subtracting a threshold from the absolute value of the difference between the grayscale variance value of the defect subimage and the grayscale variance value of the reference subimage.

[0102] The deviation value of the minimum grayscale value is determined to be 0 if the absolute value of the difference between the minimum grayscale value of the defect subimage and the minimum grayscale value of the reference subimage is not greater than a threshold. Similarly, the deviation value of the maximum grayscale value is determined to be 0 if the absolute value of the difference between the maximum grayscale value of the defect subimage and the maximum grayscale value of the reference subimage is not greater than a threshold. The deviation value of the average grayscale value is determined to be 0 if the absolute value of the difference between the average grayscale value of the defect subimage and the average grayscale value of the reference subimage is not greater than a threshold. Finally, the deviation value of the grayscale variance value is determined to be 0 if the absolute value of the difference between the grayscale variance value of the defect subimage and the grayscale variance value of the reference subimage is not greater than a threshold.

[0103] The grayscale defect level of the defect sub-image is determined based on its grayscale defect value, and this grayscale defect level serves as the first defect level. Specifically, multiple preset grayscale defect ranges are pre-set. For example, there are five preset grayscale defect ranges: 0, (0,10], (10,40], (40,100), and 100. These five defect ranges correspond to five defect levels: 0 corresponds to level 0, (0,10] to level 1, (10,40] to level 2, (40,100) to level 3, and 100 to level 4. The preset grayscale defect ranges and their corresponding defect levels can be set according to actual conditions.

[0104] In one specific embodiment, the contour defect value tmp_level_contours_i is calculated based on the following formula 2.

[0105] tmp_level_contours_i=k_circumference_i*diff_circumference_i+k_position_i*diff_position_i (Formula 2)

[0106] In Formula 2: tmp_level_contours_i represents the contour defect value of the defect submap, k_circumference_i and k_position_i represent weighting coefficients, and k_circumference_i+k_position_i=1, diff_circumference_i represents the deviation value of the contour perimeter, and diff_position_i represents the deviation value of the contour center point.

[0107] Specifically, the deviation value of the contour perimeter is determined by subtracting a threshold from the absolute value of the difference between the contour perimeter of the defect sub-image and the contour perimeter of the reference sub-image. The deviation value of the contour center point is determined by subtracting a threshold from the absolute value of the difference between the contour center point of the defect sub-image and the contour center point of the reference sub-image.

[0108] If the absolute value of the difference between the perimeter of the defect sub-image and the perimeter of the reference sub-image is not greater than a threshold, then the deviation value of the perimeter is determined to be 0. If the absolute value of the difference between the center point of the defect sub-image and the center point of the reference sub-image is not greater than a threshold, then the deviation value of the center point is determined to be 0.

[0109] The contour defect level of the defect sub-image is determined based on the contour defect value, and this contour defect level serves as the second defect level. Specifically, multiple preset contour defect ranges are pre-set. For example, there are five preset contour defect ranges: 0, (0,1], (1,4], (4,10), and 10. These five ranges correspond to five defect levels: 0 for level 0, (0,1] for level 1, (1,4] for level 2, (4,10) for level 3, and 10 for level 4. The preset contour defect ranges and their corresponding defect levels can be set according to actual conditions.

[0110] S2102: Based on the defect level and size of the defect subgraph, determine whether it is necessary to merge the defect subgraph with other neighboring defect subgraphs before performing defect type identification to obtain the defect category corresponding to the defect subgraph.

[0111] Specifically, in response to the defect level of the defect subgraph not exceeding the preset level and the size of the defect subgraph exceeding the preset size, the defect type is directly identified to obtain the defect category corresponding to the defect subgraph.

[0112] In one specific embodiment, in response to the defect level of a defect subgraph exceeding a preset level and the size of the defect subgraph not exceeding a preset size, the defect subgraph is merged with neighboring defect subgraphs to obtain a defect merged subgraph; the defect type is identified on the defect merged subgraph to obtain the defect category corresponding to the defect subgraph.

[0113] In another specific embodiment, in response to the defect level of the defect sub-image exceeding a preset level and the size of the defect sub-image exceeding a preset size, or the defect level of the defect sub-image not exceeding a preset level and the size of the defect sub-image not exceeding a preset size, the defect sub-image is merged with a defect sub-image that is adjacent in location and has an adjacent defect level to obtain a defect merged sub-image; the defect type is identified on the defect merged sub-image to obtain the defect category corresponding to the defect sub-image.

[0114] In other embodiments, the defect categories in the defect subgraph can also be identified based on a deep learning network or a classification and recognition module.

[0115] The surface defect detection method provided in this application includes: acquiring an image to be detected, the image to be detected containing a target to be detected; dividing the image to be detected into blocks based on each reference sub-image in a reference image to obtain multiple sub-images to be detected corresponding to the image to be detected; the reference image is an image of a reference target with no surface defects; analyzing the sub-images to be detected to obtain detection grayscale information and / or detection contour information of the sub-images to be detected; in response to the grayscale difference between the detection grayscale information of the sub-image to be detected and the preset grayscale information of the reference sub-image, or the contour difference between the detection contour information of the sub-image to be detected and the preset contour information of the reference sub-image, not meeting the corresponding preset requirements, it is determined that the surface of the target to be detected has defects. This application divides the image to be detected into blocks based on each reference sub-image in a reference image to obtain sub-images to be detected, performs grayscale analysis and / or contour analysis on the sub-images to be detected to determine the detection grayscale information and detection contour information of the sub-images to be detected, and determines whether the surface of the target to be detected has defects based on the grayscale difference and contour difference between the sub-images to be detected and the corresponding reference sub-images. This method is not limited to the type of target to be detected, thereby improving the generalization performance of the surface defect detection method.

[0116] See Figure 4 , Figure 4 This is a schematic diagram of a framework of an embodiment of the surface defect detection device provided by the present invention. This embodiment provides a surface defect detection device 60, which includes an acquisition module 61, a segmentation module 62, an analysis module 63, and a determination module 64.

[0117] The acquisition module 61 is used to acquire the image to be detected, which contains the target to be detected.

[0118] The segmentation module 62 is used to segment the image to be detected based on each reference sub-image in the reference image to obtain multiple sub-images to be detected corresponding to the image to be detected; the reference image is an image of a reference target with no surface defects.

[0119] The analysis module 63 is used to analyze the sub-image to be detected to obtain surface feature information of the sub-image. The surface feature information includes at least one of detection grayscale information and detection contour information.

[0120] The determination module 64 determines that the surface of the target to be detected has a defect if the difference between the surface feature 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.

[0121] The acquisition module 61 is further configured to perform segmentation processing on the acquired image to be detected to obtain a mask image of the image to be detected; extract the contour of the target to be detected from the mask image of the image to be detected, and determine the position information of the contour of the target to be detected in the mask image of the image to be detected; in response to the inconsistency between the position information of the contour of the target to be detected and the position information of the contour of the reference target in the mask image of the reference image, correct the position information of the contour of the target to be detected according to the position information of the contour of the reference target; the size of the reference target is the same as the size of the target to be detected.

[0122] The acquisition module 61 is also used to acquire a reference image; the reference image contains a reference target; in response to the presence of contour features in the reference image, the reference image is divided into multiple reference sub-images based on each contour feature; in response to the absence of contour features in the reference image, the reference image is divided into multiple reference sub-images based on the position and gray value of each pixel.

[0123] The analysis module 63 is used to perform grayscale analysis on the sub-image to be detected in response to the reference sub-image corresponding to the sub-image to be detected having a first identifier, so as to obtain the detection grayscale information of the sub-image to be detected; the detection grayscale information includes at least one of the following: maximum grayscale value, minimum grayscale value, average grayscale value, grayscale variance value, and grayscale histogram.

[0124] The analysis module 63 is also used to perform contour analysis on the sub-image to be detected in response to the reference sub-image corresponding to the sub-image to be detected having a second identifier, so as to obtain the detection contour information of the sub-image to be detected; the detection contour information includes at least one of contour shape, contour area, contour number, contour position, and contour perimeter.

[0125] The determination module 64 is used to determine that the sub-image to be detected is a defective sub-image if the difference between the surface feature 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; and to determine that the surface of the target to be detected has a defect if the image to be detected contains at least one defective sub-image.

[0126] Please see Figure 5 , Figure 5 This is a schematic diagram of another embodiment of the surface defect detection device provided by the present invention.

[0127] In one embodiment, the surface defect detection device 60 further includes a defect category identification module 65. The defect category identification module 65 is used to identify the defect type in the defect sub-image of the image to be detected, and obtain the defect category of the target to be detected.

[0128] The defect category identification module 65 is also used to determine the defect level of the defect sub-image based on the difference between the surface feature information of the defect sub-image and the surface preset information of the reference sub-image at the corresponding position; and to determine whether the defect sub-image needs to be merged with other neighboring defect sub-images before defect type identification to obtain the defect category corresponding to the defect sub-image based on the defect level and size of the defect sub-image.

[0129] Specifically, the defect category identification module 65 is further used to determine the defect level of the defect sub-image based on the first difference between the detected grayscale information of the defect sub-image and the preset grayscale information of the reference sub-image at the corresponding position and / or the second difference between the detected contour information of the defect sub-image and the preset contour information of the reference sub-image at the corresponding position; and based on the defect level and size of the defect sub-image, to determine whether it is necessary to merge the defect sub-image with other neighboring defect sub-images before performing defect type identification to obtain the defect category corresponding to the defect sub-image.

[0130] The defect category identification module 65 is further used to determine a first defect level of the defect sub-image based on a first difference between the detected grayscale information of the defect sub-image and the preset grayscale information of the reference sub-image at the corresponding position; to determine a second defect level of the defect sub-image based on a second difference between the detected contour information of the defect sub-image and the preset contour information of the reference sub-image at the corresponding position; and to determine the defect level of the defect sub-image based on the weighted sum of the first defect level and the second defect level corresponding to the defect sub-image.

[0131] The defect category identification module 65 is also used to directly identify the defect type of the defect sub-image to obtain the defect category corresponding to the defect sub-image if the defect level of the defect sub-image does not exceed the preset level and the size of the defect sub-image exceeds the preset size.

[0132] The defect category identification module 65 is also used to respond to the defect sub-image having a defect level exceeding a preset level and a defect sub-image having a size not exceeding a preset size, by merging the defect sub-image with neighboring defect sub-images to obtain a defect merged sub-image; and to perform defect type identification on the defect merged sub-image to obtain the defect category corresponding to the defect sub-image.

[0133] The defect category identification module 65 is further configured to, in response to the defect sub-image having a defect level exceeding a preset level and a defect sub-image having a size exceeding a preset size, or the defect sub-image having a defect level not exceeding a preset level and a defect sub-image having a size not exceeding a preset size, merge the defect sub-image with a defect sub-image that is adjacent in location and has an adjacent defect level to obtain a defect merged sub-image; and perform defect type identification on the defect merged sub-image to obtain the defect category corresponding to the defect sub-image.

[0134] The surface defect detection device provided in this embodiment divides the image to be detected into blocks based on each reference sub-image in the reference image to obtain the sub-image to be detected. Gray-scale analysis and / or contour analysis are performed on the sub-image to be detected to determine the detection gray-scale information and detection contour information of the sub-image to be detected. Based on the gray-scale difference and contour difference between the sub-image to be detected and the corresponding reference sub-image, it is determined whether there are defects on the surface of the target to be detected. This method is not limited to the type of target to be detected, thereby improving the generalization performance of the surface defect detection method.

[0135] Please see Figure 6 , Figure 6 This is a schematic diagram of a terminal embodiment provided in this application. The terminal 80 includes a memory 81 and a processor 82 coupled to each other. The processor 82 is used to execute program instructions stored in the memory 81 to implement the steps of any of the above-described surface defect detection method embodiments. In a specific implementation scenario, the terminal 80 may include, but is not limited to, a microcomputer or a server. In addition, the terminal 80 may also include mobile devices such as laptops and tablets, which are not limited here.

[0136] Specifically, processor 82 controls itself and memory 81 to implement the steps of any of the above-described surface defect detection method embodiments. Processor 82 can also be referred to as a CPU (Central Processing Unit). Processor 82 may be an integrated circuit chip with signal processing capabilities. Processor 82 can also be a general-purpose processor, digital signal processor (DSP), application-specific integrated circuit (ASIC), field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. A general-purpose processor can be a microprocessor or any conventional processor. Furthermore, processor 82 can be implemented using integrated circuit chips.

[0137] Please see Figure 7 , Figure 7 This is a schematic diagram of an embodiment of a computer-readable storage medium provided in this application. The computer-readable storage medium 90 stores program instructions 901 that can be executed by a processor. The program instructions 901 are used to implement the steps of any of the above-described embodiments of the surface defect detection method.

[0138] In some embodiments, the functions or modules of the apparatus provided in this disclosure can be used to perform the methods described in the above method embodiments. The specific implementation can be referred to the description of the above method embodiments, and for the sake of brevity, it will not be repeated here.

[0139] The description of the various embodiments above tends to emphasize the differences between the various embodiments. The similarities or similarities between them can be referred to, and for the sake of brevity, they will not be repeated here.

[0140] In the several embodiments provided in this application, it should be understood that the disclosed methods and apparatus can be implemented in other ways. For example, the apparatus implementations described above are merely illustrative. For instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection of devices or units may be electrical, mechanical, or other forms.

[0141] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0142] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute all or part of the steps of the methods of various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0143] If the technical solution of this application involves personal information, the product using this technical solution has clearly informed the user of the personal information processing rules and obtained the user's voluntary consent before processing the personal information. If the technical solution of this application involves sensitive personal information, the product using this technical solution has obtained the user's separate consent before processing the sensitive personal information, and also meets the requirement of "express consent". For example, at personal information collection devices such as cameras, clear and prominent signs are set up to inform users that they have entered the scope of personal information collection and that personal information will be collected. If an individual voluntarily enters the collection scope, it is deemed that they have agreed to the collection of their personal information; or on the personal information processing device, with clear signs / information informing users of the personal information processing rules, authorization is obtained from the individual through pop-up information or by asking the individual to upload their personal information; wherein, the personal information processing rules may include information such as the personal information processor, the purpose of personal information processing, the processing method, and the types of personal information processed.

[0144] The above are merely embodiments of the present invention and do not limit the scope of patent protection of the present invention. Any equivalent structural or procedural transformations made based on the content of the present invention's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the scope of patent protection of the present invention.

Claims

1. A method for detecting surface defects, characterized in that, The surface defect detection method includes: Acquire an image to be detected, wherein the image to be detected is a surface image containing the target to be detected; The image to be detected is segmented to obtain a mask image of the image to be detected; Extract the outline of the target to be detected from the mask image of the image to be detected, and determine the position information of the outline of the target to be detected in the mask image of the image to be detected; In response to the fact 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 contour of the target to be detected is consistent with the position information of the contour of the reference target in the mask image of the reference image, the target to be detected is divided into blocks based on each reference sub-image in the reference image to obtain multiple sub-images to be detected corresponding to the target to be detected; the reference image is an image of a reference target with no surface defects; The surface feature information of the sub-image to be detected is obtained by analyzing the sub-image to be detected. If the difference between the surface feature 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, it is determined that there is a defect on the surface of the target to be detected.

2. The surface defect detection method according to claim 1, characterized in that, After the step of acquiring the image to be detected, wherein the image to be detected contains the target to be detected, and before the step of performing block processing on the image to be detected based on each reference sub-image in the reference image to obtain multiple sub-images to be detected corresponding to the image to be detected, the method further includes: In response to the inconsistency between the position information of the contour of the target to be detected and the position information of the contour of the reference target in the mask image of the reference image, the position information of the contour of the target to be detected is corrected according to the position information of the contour of the reference target; the size of the reference target is the same as the size of the target to be detected.

3. The surface defect detection method according to claim 1, characterized in that, The process of acquiring the image to be detected, prior to this step, also includes: The reference image is acquired; the reference image contains the reference target; In response to the presence of contour features in the reference image, the reference image is divided based on each contour feature to obtain multiple reference sub-images; In response to the absence of the contour feature in the reference image, the reference image is divided into multiple reference sub-images based on the position and gray value of each pixel.

4. The surface defect detection method according to claim 1, characterized in that, The reference sub-image has a first identifier; the surface feature information includes detected grayscale information; The analysis of the sub-image to be detected to obtain the surface feature information of the sub-image to be detected includes: In response to the fact that the reference sub-image corresponding to the sub-image to be detected has the first identifier, grayscale analysis is performed on the sub-image to be detected to obtain the detection grayscale information of the sub-image to be detected.

5. The surface defect detection method according to claim 1 or 4, characterized in that, The reference sub-image has a second identifier; the surface feature information includes detection contour information; The analysis of the sub-image to be detected to obtain the surface feature information of the sub-image to be detected includes: In response to the fact that the reference sub-image corresponding to the sub-image to be detected has the second identifier, contour analysis is performed on the sub-image to be detected to obtain the detection contour information of the sub-image to be detected.

6. The surface defect detection method according to claim 1, characterized in that, The determination that the surface of the target object has a defect in response to a difference between the surface feature information of the sub-image to be detected and the surface preset information of the reference sub-image not meeting the corresponding preset requirements includes: If the difference between the surface feature 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, then the sub-image to be detected is determined to be a defective sub-image. If the image to be detected contains at least one of the defect sub-images, then it is determined that there is a defect on the surface of the target to be detected.

7. The surface defect detection method according to claim 6, characterized in that, The surface defect detection method further includes: Defect type identification is performed on the defect sub-image in the image to be detected to obtain the defect category of the target to be detected.

8. The surface defect detection method according to claim 7, characterized in that, The step of identifying the defect type of the defect sub-image in the image to be detected to obtain the defect category of the target to be detected includes: The defect level of the defect sub-image is determined based on the difference between the surface feature information of the defect sub-image and the surface preset information of the reference sub-image at the corresponding position. Based on the defect level and size of the defect subgraph, it is determined whether the defect subgraph needs to be merged with other neighboring defect subgraphs before defect type identification is performed to obtain the defect category corresponding to the defect subgraph.

9. The surface defect detection method according to claim 8, characterized in that, The surface feature information includes detected grayscale information and detected contour information; The method of determining the defect level of the defect sub-image based on the difference between the surface feature information of the defect sub-image and the preset surface information of the reference sub-image at the corresponding position includes: Based on the first difference between the detected grayscale information of the defect sub-image and the preset grayscale information of the reference sub-image at the corresponding position, the first defect level of the defect sub-image is determined. Based on the second difference between the detected contour information of the defect sub-image and the preset contour information of the reference sub-image at the corresponding position, the second defect level of the defect sub-image is determined. The defect level of the defect subgraph is determined based on the weighted sum of the first defect level and the second defect level corresponding to the defect subgraph.

10. The surface defect detection method according to claim 8, characterized in that, The step of determining whether to merge the defect sub-image with other neighboring defect sub-images and then perform defect type identification based on the defect level and size of the defect sub-image includes: If the defect level of the defect sub-image does not exceed a preset level and the size of the defect sub-image exceeds a preset size, then the defect type is directly identified to obtain the defect category corresponding to the defect sub-image.

11. The surface defect detection method according to claim 8, characterized in that, The step of determining whether to merge the defect sub-image with other neighboring defect sub-images and then perform defect type identification based on the defect level and size of the defect sub-image includes: If the defect level of the defect subgraph exceeds a preset level and the size of the defect subgraph does not exceed a preset size, then the defect subgraph is merged with the neighboring defect subgraphs to obtain a defect merged subgraph. Defect type identification is performed on the defect merged subgraph to obtain the defect category corresponding to the defect subgraph.

12. The surface defect detection method according to claim 8, characterized in that, The step of determining whether to merge the defect sub-image with other neighboring defect sub-images and then perform defect type identification based on the defect level and size of the defect sub-image includes: In response to the defect level of the defect sub-image exceeding a preset level and the size of the defect sub-image exceeding a preset size, or the defect level of the defect sub-image not exceeding the preset level and the size of the defect sub-image not exceeding the preset size, the defect sub-image is merged with the defect sub-image that is adjacent in position and has adjacent in defect level to obtain a defect merged sub-image. Defect type identification is performed on the defect merged subgraph to obtain the defect category corresponding to the defect subgraph.

13. A surface defect detection device, characterized in that, The surface defect detection device includes: The acquisition module is used to acquire the image to be detected, wherein the image to be detected is the surface image of the target to be detected; A segmentation module is used to segment the image to be detected to obtain a mask image of the image to be detected; extract the contour of the target to be detected from the mask image of the image to be detected, and determine the position information of the contour of the target to be detected in the mask image of the image to be detected; in response to the fact 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 contour of the target to be detected is consistent with the position information of the contour of the reference target in the mask image of the reference image; then, based on each reference sub-image in the reference image, the image to be detected is segmented to obtain multiple sub-images to be detected corresponding to the image to be detected; the reference image is an image of a reference target with no surface defects; The analysis module is used to analyze the sub-image to be detected and obtain the surface feature information of the sub-image to be detected; The determination module is configured to determine that the surface of the target to be detected has a defect if the difference between the surface feature 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.

14. A terminal, characterized in that, The terminal includes a memory, a processor, and a computer program stored in the memory and running on the processor, the processor being used to execute program data to implement the steps in the surface defect detection method as described in any one of claims 1 to 12.

15. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of the surface defect detection method as described in any one of claims 1 to 12.

Citation Information

Patent Citations

  • Product defect detection method, device and equipment and readable storage medium

    CN114612469A

  • Food foreign matter detection method and device, computer equipment and storage medium

    CN115082819A