CN-119941624-B - Pattern defect detection method, device and storage medium
Abstract
The application discloses a pattern defect detection method, equipment and a storage medium, wherein the method comprises the steps of obtaining an integral pattern area and a plurality of local pattern areas corresponding to a target pattern in an image to be detected, and obtaining an integral template image and a plurality of local template images from template information corresponding to the target pattern; the method comprises the steps of aligning an integral pattern area with an integral template image, aligning each local pattern area with a corresponding local template image respectively, determining a first defect position in the integral pattern area based on a first pixel value difference between the integral pattern area and the integral template image after alignment, determining a second defect position in each local pattern area based on a second pixel value difference between each local pattern area and the corresponding local template image after alignment respectively, and determining a third defect position of a target pattern in an image to be detected by integrating the first defect position and each second defect position. By the method, the accuracy of pattern defect detection can be improved.
Inventors
- XU WENLIN
- LI JING
- Yu Chaorui
- ZHOU LU
Assignees
- 浙江华睿科技股份有限公司
Dates
- Publication Date
- 20260508
- Application Date
- 20241204
Claims (14)
- 1. A pattern defect detection method, the method comprising: Acquiring an integral pattern area and a plurality of local pattern areas corresponding to a target pattern in an image to be detected, and acquiring an integral template image and a plurality of local template images from template information corresponding to the target pattern, wherein each local pattern area corresponds to different local areas of the target pattern, the integral template image and the local template image are an integral image and a local image of the target pattern in a defect-free state, and each local pattern area corresponds to each local template image one by one; Aligning the global pattern area with the global template image, and aligning each local pattern area with the corresponding local template image respectively; determining a first defect position in the global pattern region based on a first pixel value difference between the aligned global pattern region and a global template image, and determining a second defect position in each local pattern region based on a second pixel value difference between each local pattern region and a corresponding local template image after alignment, respectively; And integrating the first defect position and each second defect position, and determining a third defect position of the target pattern in the image to be detected.
- 2. The method of claim 1, wherein the determining a first defect location in the global pattern area based on a first pixel value difference between the registered global pattern area and a global template image or the determining a second defect location in each local pattern area based on a second pixel value difference between each local pattern area and a corresponding local template image, respectively, comprises: acquiring a first difference image between a target template image and a target pattern area, wherein each pixel value in the first difference image represents a target pixel value difference between each pixel point in the target pattern area and a corresponding pixel point in the target template image; Searching a plurality of first target pixel points with pixel values larger than a preset difference threshold value from the first difference image, wherein the plurality of first target pixel points are used for defining a first target defect position; The target template image is the whole template image, the target pattern area is the whole pattern area, the target pixel value difference is the first pixel value difference, the first target defect position is the first defect position, or the target template image is the local template image, the target pattern area is the local pattern area, the target pixel value difference is the second pixel value difference, and the first target defect position is the second defect position.
- 3. The method according to claim 2, wherein the searching for a number of first target pixels having pixel values greater than a preset difference threshold from the first difference image includes: acquiring a threshold image corresponding to the target template image from the template information; setting a pixel value of a second target pixel point in the first difference image as an invalid value to obtain a second difference image, wherein the pixel value of the second target pixel point is not greater than the pixel value of a corresponding pixel point in the threshold image; and searching the first target pixel points with pixel values larger than the preset difference threshold value from the second difference image.
- 4. The method of claim 2, wherein the acquiring a first difference image between the target template image and the target pattern region comprises: acquiring a standard deviation image corresponding to the target template image from the template information; Acquiring a difference image between the target pattern area and the standard deviation image as the first difference image; And/or, before the acquiring the first difference image between the target template image and the target pattern area, further comprising: acquiring a normalization mode from the template information; And carrying out normalization processing on the target pattern area in the normalization mode, wherein the target pattern area subjected to the normalization processing is used for acquiring the first difference image.
- 5. The method of claim 1, wherein prior to said determining a first defect location in the global pattern area based on a first pixel value difference between the registered global pattern area and a global template image, and determining a second defect location in each of the local pattern areas based on a second pixel value difference between each of the registered local pattern areas and a corresponding local template image, respectively, further comprising: acquiring a target mapping relation between a target pattern area and a target template image; Determining a deformation area of which the deformation degree meets the deformation requirement in the target pattern area in response to determining that the deformation degree of the target pattern area is greater than a preset degree threshold based on the target mapping relation, taking the deformation area as a second target defect position, directly executing the steps of integrating the first defect position and each second defect position, and determining a third defect position of the target pattern in the image to be detected; The target template image is the whole template image, the target pattern area is the whole pattern area, the second target defect position is the first defect position, or the target template image is the local template image, the target pattern area is the local pattern area, and the second target defect position is the second defect position.
- 6. The method of claim 1, wherein prior to said determining a first defect location in the global pattern area based on a first pixel value difference between the registered global pattern area and a global template image, and determining a second defect location in each of the local pattern areas based on a second pixel value difference between each of the registered local pattern areas and a corresponding local template image, respectively, further comprising: acquiring a target mapping relation between a target pattern area and a target template image; Correcting the target pattern region by utilizing the target mapping relation in response to the fact that the target pattern region is deformed and the deformation degree is not larger than a preset degree threshold value based on the target mapping relation, wherein the corrected target pattern region is used for carrying out the alignment and determining a first target defect position in the target pattern region; Before the first defect position and each second defect position are combined to determine the third defect position of the target pattern in the image to be detected, the method further comprises: mapping the first target defect position into the target pattern area before correction by utilizing the target mapping relation; The target template image is the whole template image, the target pattern area is the whole pattern area, the first target defect position is the first defect position, or the target template image is the local template image, the target pattern area is the local pattern area, and the first target defect position is the second defect position.
- 7. The method according to claim 5 or 6, wherein the acquiring the target mapping relationship between the target pattern area and the target template image comprises: randomly selecting a plurality of groups of characteristic point pairs from the target pattern area and the target template image, and determining initial mapping relations between the target pattern area and the target template image from the plurality of groups of characteristic point pairs; and obtaining a plurality of concentrated trend characterization values of the initial mapping relationship as the target mapping relationship.
- 8. The method of claim 7, further comprising, prior to said randomly selecting a plurality of sets of feature point pairs from said target pattern region and said target template image: and filtering the characteristic points in the target pattern area and the target template area based on the pixel number of the target template image.
- 9. The method of claim 1, further comprising, prior to said aligning said global pattern region with said global template image and each of said local pattern regions with a corresponding one of said local template images, respectively: searching the local pattern areas with the number of the characteristic points smaller than the preset number as areas to be combined, and combining the areas to be combined with the adjacent local pattern areas to be used as new local pattern areas; And merging the local template image corresponding to the region to be merged and the local template image corresponding to the adjacent local pattern region to be used as the new local template image.
- 10. The method of claim 1, wherein said aligning the global pattern region with the global template image or said aligning each of the local pattern regions with the corresponding local template image, respectively, comprises: acquiring alignment fine granularity information from the template information; Aligning the whole pattern area with the whole template image or aligning the local pattern area with the corresponding local template image according to the alignment fine granularity information; and/or, the step of integrating the first defect position and each second defect position to determine a third defect position of the target pattern in the image to be detected includes: and weighting the first defect position and each second defect position to obtain the third defect position.
- 11. The method of claim 1, wherein acquiring the overall pattern area comprises: Performing target detection on the image to be detected by using a target detection model to obtain the whole pattern area, or performing template matching on the image to be detected by using a whole template image corresponding to the target pattern to obtain the whole pattern area; in response to the overall pattern area not conforming to the overall template image in size, adjusting the overall pattern area to conform to the overall template image in size; and/or, acquiring the plurality of local pattern areas, including: Partitioning the whole pattern area in a mode of overlapping sliding windows to obtain a plurality of local pattern areas, wherein the sizes of windows of the overlapping sliding windows are the same as those of the local template images, and the overlapping proportion of the overlapping sliding windows is preset or input by a user; and/or before the whole pattern area and a plurality of local pattern areas corresponding to the target pattern in the image to be detected are acquired, the method further comprises the steps of: The image to be detected is preprocessed, wherein the preprocessing comprises at least one of noise reduction, filtering and morphological transformation.
- 12. The method according to claim 1, wherein the method is implemented by a defect detection model, the template information being learned by the defect detection model during training with non-defective pattern samples corresponding to the target pattern; and/or, the first defect position, the second defect position and the third defect position are characterized by using a mask chart.
- 13. An electronic device comprising a memory storing program instructions and a processor for executing the program instructions to implement the pattern defect detection method according to any one of claims 1-12.
- 14. A computer readable storage medium, characterized in that the computer readable storage medium is for storing program instructions, the program instructions being executable to implement the pattern defect detection method according to any one of claims 1 to 12.
Description
Pattern defect detection method, device and storage medium Technical Field The present application relates to the field of machine vision, and in particular, to a method and apparatus for detecting pattern defects, and a storage medium. Background In the field of machine vision, in the case where there is deformation of an image with respect to a fixed pattern or character sequence, an abnormal region present in the image can be detected by using a pattern defect detection method. However, for complex situations such as distortion or irregular deformation in an image, the existing defect detection algorithm has poor adaptability, so that the defect detection accuracy is low. Disclosure of Invention The application mainly solves the technical problem of providing a pattern defect detection method, device and medium, which can improve the accuracy of pattern defect detection. In order to solve the technical problems, the technical scheme adopted by the application is that the method comprises the steps of obtaining an integral pattern area and a plurality of local pattern areas corresponding to a target pattern in an image to be detected, obtaining an integral template image and a plurality of local template images from template information corresponding to the target pattern, wherein each local pattern area corresponds to different local areas of the target pattern respectively, the integral template image and the local template image are respectively an integral image and a local image of the target pattern in a non-defective state, each local pattern area corresponds to each local template image one by one, aligning each integral pattern area with the integral template image, aligning each local pattern area with the corresponding local template image respectively, determining a first defect position in the integral pattern area based on a first pixel value difference between the aligned integral pattern area and the integral template image, determining a second defect position in the integral pattern area based on a second pixel value difference between the aligned local pattern area and the corresponding local template image respectively, and determining a second defect position in the target pattern area based on a second integrated defect position. In order to solve the technical problem, the application adopts another technical scheme that the electronic equipment comprises a memory and a processor, wherein the memory stores program instructions, and the processor is used for executing the program instructions to realize the pattern defect detection method. In order to solve the technical problem, the application adopts a further technical scheme that a computer readable storage medium is provided, the computer readable storage medium is used for storing program instructions, and the program instructions can be executed to realize the pattern defect detection method. In the scheme, the whole pattern area is aligned with the whole template image, and each local pattern area is aligned with the corresponding local template image. The method comprises the steps of determining a first defect position in the overall pattern area based on a first pixel value difference between the aligned overall pattern area and the overall template image, and determining a second defect position in each local pattern area based on a second pixel value difference between each local pattern area and the corresponding local template image after alignment. And combining the first defect position and each second defect position to determine a third defect position of the target pattern in the image to be detected. The application can identify the first defect position in the integral pattern area based on the first pixel value difference between the integral pattern area and the integral template image after alignment. For each local pattern region, a second pixel value difference between the local pattern region and the corresponding local template image is also calculated, so that a second defect position in each local pattern region is determined. And comprehensively analyzing the first defect position and the second defect position, and obtaining a third defect position of the target pattern in the image to be detected by integrating defect information of different dimensions. When complex conditions such as distortion or irregular deformation and the like existing in the image are processed, the method adopts a block detection mode so as to realize deep analysis of details of the distortion or the irregular deformation. And simultaneously, carrying out overall analysis on the overall condition of the image by using an overall image detection method. The method of combining whole-image detection and block detection enables defects in the target pattern to be more comprehensively and accurately positioned, and accordingly accuracy of defect detection is improved. Drawings FIG. 1 is a flow chart illustrating an embodiment of