Defect detection method and device, computer equipment and computer readable storage medium

By performing sub-region division and grayscale value fusion processing on the image to be detected, the problem of low accuracy of defect detection in the prior art is solved, and high accuracy defect detection of the image to be detected is realized.

CN119515761APending Publication Date: 2025-02-25SHENZHEN SMARTMORE TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311075254.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-08-24
Publication Date
2025-02-25

AI Technical Summary

Technical Problem

In the prior art, defect detection is low and is greatly affected by the normal noise brought by the item to be tested.

Method used

By dividing the image to be detected into a preset number of sub-regions to be measured, each target pixel point and its adjacent pixel point are determined, and the gray value difference is calculated, based on the gray value difference, the gray value of the target pixel point and the fusion The factor performs grayscale fusion to obtain the updated grayscale value, thereby generating a grayscale processing image, eliminating noise interference, and improving the accuracy of defect detection.

Benefits of technology

By balancing the pixel noise in each sub-region to be measured, the grayscale value is approached, and the interference of normal noise on defect detection is eliminated, which significantly improves the accuracy of defect detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119515761A_ABST
    Figure CN119515761A_ABST
Patent Text Reader

Abstract

The invention relates to a defect detection method and device, computer equipment and a computer readable storage medium. The method comprises the following steps: dividing an acquired to-be-detected image into a preset number of to-be-detected sub-regions; determining each target pixel point and an adjacent pixel point in each to-be-detected sub-region, and calculating a gray value difference between each target pixel point and the corresponding adjacent pixel point; based on the gray value differences, the gray values of the target pixel points and fusion factors, fusion is carried out to obtain updated gray values of all the target pixel points in all the to-be-detected sub-areas, and based on the updated gray values of all the target pixel points, gray processing images corresponding to the corresponding to-be-detected sub-areas are determined; the fusion factor is used for representing the gray value updating amplitude of the target pixel point; and performing gray value comparison on the gray processing images corresponding to the to-be-detected sub-regions of the to-be-detected image to determine a target defect region. By adopting the method, the accuracy of defect detection can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a defect detection method, apparatus, computer equipment, and computer-readable storage medium. Background Art

[0002] With the development of computer technology, the use of image recognition technology to automatically detect the appearance defects of industrial products, such as the detection of external surface defects of AG glass (anti-reflective glass) during the production process, has gradually replaced manual detection to improve the efficiency of defect detection, which has very important application value.

[0003] In the prior art, methods such as binarization are usually used for defect determination. However, due to the influence of normal noise points of the inspected objects, the accuracy of defect detection is low. Summary of the invention

[0004] Based on this, it is necessary to provide a defect detection method, device, computer equipment and computer-readable storage medium to address the above technical problems, which can effectively improve the accuracy of defect detection.

[0005] In a first aspect, the present application provides a defect detection method, comprising:

[0006] Dividing the acquired image to be detected into a preset number of sub-areas to be detected;

[0007] Determine each target pixel and its adjacent pixel in each sub-region to be tested, and calculate the gray value difference between each target pixel and the corresponding adjacent pixel;

[0008] For each sub-region to be tested, based on the grayscale value difference, the grayscale value of the target pixel and the fusion factor, the updated grayscale value of each target pixel in each sub-region to be tested is obtained by fusion, and based on the updated grayscale value of each target pixel, the grayscale processed image corresponding to the corresponding sub-region to be tested is determined; the fusion factor is used to characterize the magnitude of the grayscale value update amplitude of the target pixel;

[0009] The grayscale values ​​of the grayscale processed images corresponding to each sub-region to be inspected in the inspected image are compared to determine the target defect area.

[0010] In a second aspect, the present application also provides a defect detection device, comprising:

[0011] An acquisition module, used for dividing the acquired image to be detected into a preset number of sub-areas to be detected;

[0012] A processing module is used to determine each target pixel and its adjacent pixel points in each sub-region to be tested, and calculate the gray value difference between each target pixel point and the corresponding adjacent pixel point; for each sub-region to be tested, based on the gray value difference, the gray value of the target pixel point and the fusion factor, the updated gray value of each target pixel point in each sub-region to be tested is obtained by fusion, and based on the updated gray value of each target pixel point, the gray processing image corresponding to the corresponding sub-region to be tested is determined; the fusion factor is used to characterize the magnitude of the gray value update amplitude of the target pixel point;

[0013] The determination module is used to compare the grayscale values ​​of the grayscale processed images corresponding to each sub-region to be detected in the image to be detected, so as to determine the target defect area.

[0014] In a third aspect, the present application provides a computer device, which includes a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps in the above-mentioned defect detection method when executing the computer program.

[0015] In a fourth aspect, the present application provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps in the above-mentioned defect detection method are implemented.

[0016] The above-mentioned defect detection method, device, computer equipment and computer-readable storage medium balance the pixel noise points of each sub-area to be tested, so that the grayscale values ​​of the pixels with normal noise points and the pixels without noise points in each sub-area to be tested are close, so that the grayscale values ​​of the normal and defect-free pixels in the corresponding sub-area to be tested reach a predetermined balance state, and a grayscale processed image is obtained, thereby further highlighting the grayscale value difference between the defective area and the normal area, effectively eliminating the interference of normal noise points in the sub-area to be tested on defect detection, and then comparing the grayscale values ​​of the grayscale processed image to obtain the target defect area, complete defect detection, and effectively improve the accuracy of defect detection. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] Figure 1 A schematic diagram of a defect detection method provided in an embodiment of the present application;

[0018] Figure 2 A schematic diagram of a process for determining the position of an image to be detected provided in an embodiment of the present application;

[0019] Figure 3 A schematic diagram of a process for determining a target image to be detected provided in an embodiment of the present application;

[0020] Figure 4 A schematic diagram of a process for determining a grayscale processed image corresponding to a sub-region to be tested provided in an embodiment of the present application;

[0021] Figure 5 A schematic diagram of a process for determining a target defect area of ​​a sub-area to be tested provided in an embodiment of the present application;

[0022] Figure 6 A schematic diagram of a process for determining defect detection results provided in an embodiment of the present application;

[0023] Figure 7 A schematic flow chart of a defect detection method for AG glass provided in an embodiment of the present application;

[0024] Figure 8 A schematic diagram of positioning the edge of AG glass using a linear caliper provided in an embodiment of the present application;

[0025] Fig. 9 A schematic diagram of a process for performing gray balance processing on a sub-region to be tested provided in an embodiment of the present application;

[0026] Fig.10 A structural block diagram of a defect detection device provided in an embodiment of the present application;

[0027] Fig.11 An internal structure diagram of a computer device provided in an embodiment of the present application;

[0028] Fig.12 An internal structure diagram of another computer device provided in an embodiment of the present application;

[0029] Fig.13 An internal structure diagram of a computer-readable storage medium provided in an embodiment of the present application. DETAILED DESCRIPTION

[0030] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0031] In some embodiments, Figure 1 As shown, a defect detection method is provided. This embodiment takes the method applied to a terminal as an example. It can be understood that the method can also be applied to a server, and can also be applied to a system including a terminal and a server, and is implemented through the interaction between the terminal and the server. In this embodiment, the method includes the following steps:

[0032] Step S102: dividing the acquired image to be detected into a preset number of sub-areas to be detected.

[0033] The image to be detected contains normal noise. The so-called normal noise refers to the areas with different grayscale values ​​in the image to be detected due to the characteristics of the image to be detected, such as the pattern, surface texture, color, etc. For example, the grayscale images corresponding to AG glass, patterned wallpaper, clothing, and wood all have normal noise. When dividing the image to be detected into sub-areas to be detected, it can be divided evenly according to a certain shape, or it can be customized to divide the sub-areas to be detected into any shape, area, and number.

[0034] Step S104, determining each target pixel and its adjacent pixel in each sub-region to be detected, and calculating the gray value difference between each target pixel and the corresponding adjacent pixel.

[0035] The grayscale value difference may be a grayscale value difference, or may be a grayscale value difference degree label (eg, large grayscale difference, large grayscale difference, medium grayscale difference, small grayscale difference, etc.).

[0036] Specifically, the computer device performs pixel position analysis on each pixel in each sub-area to be tested, determines the position information of each pixel and its adjacent pixels, and then calculates the gray value difference between each target pixel and its surrounding adjacent pixels.

[0037] Optionally, the computer device can obtain an adjacent parameter; the adjacent parameter is a range value, which is used to characterize the pixel points within the range represented by the adjacent parameter, and is determined as the adjacent pixel points corresponding to the pixel point; in addition, the computer device can also determine the pixel points directly adjacent to each pixel point as the corresponding adjacent pixel points, and the target pixel point can be a pixel point of one or a part of the corresponding sub-area to be measured, or it can be all the pixel points in the corresponding sub-area to be measured.

[0038] Step S106, for each sub-region to be tested, based on the grayscale value difference, the grayscale value of the target pixel and the fusion factor, the updated grayscale value of each target pixel in each sub-region to be tested is obtained by fusion, and based on the updated grayscale value of each target pixel, the grayscale processed image corresponding to the corresponding sub-region to be tested is determined.

[0039] Among them, the fusion factor is used to characterize the magnitude of the grayscale value update amplitude of the target pixel point; the size of the fusion factor can be flexibly configured by technical personnel according to specific circumstances, or it can be determined through the historical image processing process, or it can be the optimal value determined by repeated iterations such as particle swarm algorithm and genetic algorithm.

[0040] Specifically, the computer device fuses the grayscale values ​​of the target pixels of each sub-area to be tested determined in the aforementioned steps, the grayscale value differences between the target pixels and adjacent pixels, and the fusion factors to obtain updated grayscale values ​​of each target pixel in each sub-area to be tested, and then obtains a grayscale processed image corresponding to the corresponding sub-area to be tested based on the updated grayscale values ​​of each target pixel. Compared with the image to be tested corresponding to the sub-area to be tested, the difference in grayscale values ​​between the defective area and the non-defective area in the grayscale processed image is more prominent, and the interference of normal noise on defect detection is effectively eliminated.

[0041] Step S108 , performing grayscale value comparison on the grayscale processed images corresponding to each sub-region to be inspected of the image to be inspected, and determining the target defect region.

[0042] Among them, the gray value comparison method can adopt common methods such as Blob analysis or binarization processing.

[0043] Specifically, the computer device compares the grayscale values ​​according to the grayscale processed images corresponding to each sub-region to be detected, and performs connected domain analysis to determine the edge position of the target defect region, and then determine the entire target defect region.

[0044] In this embodiment, the pixel noise points of each sub-region to be tested, into which the image to be tested is divided, are balanced so that the grayscale values ​​of the pixels with normal noise points and the pixels without noise points in each sub-region to be tested are close to each other, so that the grayscale values ​​of the pixels in the normal and defect-free areas in the corresponding sub-region to be tested reach a predetermined balance state, and a grayscale processed image is obtained, thereby further highlighting the grayscale value difference between the defective area and the normal area, effectively eliminating the interference of normal noise points in the sub-region to be tested on defect detection, and then comparing the grayscale values ​​of the grayscale processed image to obtain the target defective area, complete defect detection, and effectively improve the accuracy of defect detection.

[0045] In some embodiments, Figure 2 As shown, before dividing the acquired image to be detected into a preset number of sub-areas to be detected, the method further includes:

[0046] Step S202, obtaining an initial image.

[0047] Among them, the initial image includes a detection area and a non-detection area; the initial image is obtained by controlling an image acquisition device through a computer device to acquire an image of an object that needs to be defect-detected (such as AG glass, wallpaper, etc.), and the image acquisition device can be a commonly used image acquisition camera (such as a commonly used digital camera, infrared camera or depth camera, etc.) or an image acquisition sensor, and there is no specific limitation here.

[0048] Step S204, binarization processing is performed on the initial image to determine the position information of the detection area in the initial image.

[0049] Specifically, the computer device performs binarization processing on the initial image obtained in the above steps to obtain a processed binary grayscale image, and determines the position information of the detection area in the initial image according to the difference in grayscale values ​​of each area in the binary grayscale image.

[0050] Step S206, determining the image to be detected corresponding to the detection area according to the position information.

[0051] The image to be detected is the image portion corresponding to the detection area in the initial image.

[0052] In this embodiment, an initial image is acquired and then binarized to determine the position information of the detection area in the initial image. The image to be detected corresponding to the detection area is determined based on the position information. This enables the detection area in the initial image to be accurately located, thereby improving the accuracy of the generated image to be detected.

[0053] In some embodiments, Figure 3 As shown, the initial image is binarized to determine the position information of the detection area in the initial image, including:

[0054] Step S302: binarize the initial image to obtain first position information of the detection area in the initial image, and determine the target reference image according to the first position information.

[0055] The target reference image includes a target detection area and a target non-detection area; the target reference image is used to identify approximate position information of the detection area in the initial image.

[0056] Specifically, the computer device performs binarization processing on the initial image, determines the boundary position information between the detection area and the non-detection area in the initial image, then determines the detection area corresponding to the first position information in the initial image based on the boundary position information, and determines the target reference image based on the first position information.

[0057] Step S304: detecting a boundary between the target detection area and the target non-detection area based on the target functional component to obtain second position information of the target detection area in the target reference image.

[0058] Among them, the target function component is used to determine the edge point according to the change of the pixel grayscale value at the corresponding position in the image. For example, the target function component can be a common measuring tool such as a linear caliper; the second position information and the first position information in the aforementioned step S302 are both used to determine the specific position of the detection area in the initial image, but the second position information is based on the accuracy of the first position information. The information further accurately determines the position of the detection area, that is, the second position information is more accurate than the first position information.

[0059] Specifically, the computer device can set the target functional component at the boundary between the target detection area and the target non-detection area in the target reference image, and then measure the boundary more accurately, and determine the second position information of the target detection area in the target reference image according to the measurement result.

[0060] Determining the image to be detected corresponding to the area to be detected according to the position information includes:

[0061] Step S306: determining the target image to be detected corresponding to the target detection area based on the second position information.

[0062] Specifically, the computer device determines the boundary position information of the target detection area in the target reference image based on the second position information, thereby accurately determining the target image to be detected corresponding to the target detection area according to the boundary position information.

[0063] In this embodiment, the boundary position information of the detection area in the initial image is roughly located by binarization processing to obtain first position information, and then the target reference image corresponding to the first position information is used to further more accurately locate the boundary position information of the target detection area using the target function component to obtain the corresponding second position information, and finally the target image to be detected corresponding to the target detection area is determined based on the second position information, with higher accuracy.

[0064] In some embodiments, Figure 4 As shown, for each sub-region to be tested, based on the gray value difference, the gray value of the target pixel and the fusion factor, the updated gray value of each target pixel in each sub-region to be tested is obtained by fusion, and based on the updated gray value of each target pixel, the gray processing image corresponding to the corresponding sub-region to be tested is determined, including:

[0065] Step S402, for each sub-region to be tested, based on the current gray value difference corresponding to the current iteration number, the current gray value of the target pixel and the fusion factor, the current updated gray value of each target pixel in each sub-region to be tested under the current iteration number is fused.

[0066] Among them, iteration means that when all target pixels in the sub-area to be tested have completed an update of the grayscale value, the sub-area to be tested is regarded as having completed an iteration, and each iteration will generate the current grayscale value difference corresponding to the current number of iterations and the current grayscale value of the target pixel; the fusion method can be any one of addition, subtraction, multiplication, and division, or the superposition of several operation methods.

[0067] Specifically, the computer device generates a grayscale value correction term based on the current grayscale value difference corresponding to the target pixel point at the current iteration number and the fusion factor, and then fuses the current grayscale value of the target pixel point with the corresponding grayscale value correction term to obtain the currently updated grayscale value of each target pixel point in each sub-area to be tested at the current iteration number.

[0068] For example, the computer device may update the grayscale values ​​of the target pixel and its adjacent pixels according to the following formulas 1 to 3:

[0069]

[0070]

[0071]

[0072] in, and They are the target pixel points P i,j Grayscale values ​​before and after iteration, and They are adjacent pixel points P k,l Grayscale values ​​before and after iteration, α is the fusion factor, d i,j,k,l Used to characterize the target pixel P i,j and its adjacent pixel points P k,l The gray value difference before the iteration.

[0073] Step S404, when the current number of iterations is less than a preset threshold, return to the step of determining each target pixel and its adjacent pixel in each sub-region to be detected, and calculating the gray value difference between each target pixel and the corresponding adjacent pixel.

[0074] Step S406, when the current number of iterations reaches a preset threshold, the iteration is stopped, and based on the current updated grayscale value of each target pixel point, a grayscale processed image corresponding to the corresponding sub-region to be tested is determined.

[0075] In this embodiment, the grayscale values ​​of each target pixel in each sub-region to be tested are continuously iterated and updated, and the number of iterations is compared with a preset threshold value. The comparison result is used as the iteration stop condition, so as to achieve balanced processing of the grayscale values ​​of normal pixels in the corresponding sub-region to be tested, effectively filter out normal noise points in the sub-region to be tested, and improve the reliability of the corresponding grayscale processed image.

[0076] In some embodiments, Figure 5 As shown, grayscale values ​​of the grayscale processed images corresponding to each sub-region to be detected of the image to be detected are compared to determine the target defect area, including:

[0077] Step S502, determining a standard grayscale value and a preset grayscale value standard deviation corresponding to each grayscale processed image.

[0078] Among them, the standard grayscale value and the grayscale value standard deviation can be flexibly set by the technician according to the specific situation. It can be a pre-set fixed value or a dynamic value determined according to the number of iterations; the standard grayscale value and the grayscale value standard deviation can be a fixed value or a numerical range.

[0079] Optionally, the computer device may first obtain the correspondence between the number of iterations and the standard grayscale value and between the number of iterations and the grayscale value standard deviation, and then determine the standard grayscale value and the grayscale value standard deviation based on the correspondence and the current number of iterations or the maximum number of iterations corresponding to each grayscale processed image.

[0080] Step S504, for the grayscale processed images corresponding to each sub-region to be detected of the image to be detected, the grayscale values ​​of each region of each grayscale processed image are compared according to the standard grayscale value corresponding to each grayscale processed image and the preset grayscale value standard deviation, and the corresponding target defect area is determined, thereby obtaining the target defect area of ​​each sub-region to be detected.

[0081] In this embodiment, by comparing the grayscale values ​​of each area in the grayscale processed image determined in the aforementioned steps with the standard grayscale value of the acquired grayscale processed image and the preset grayscale value standard deviation, the corresponding target defect area is determined, and then the target defect area of ​​each sub-area to be detected is determined. It is possible to quickly compare the existence of abnormalities in the grayscale values ​​of the target defect area, thereby being able to quickly and accurately determine the target defect area in each sub-area to be detected.

[0082] In some embodiments, after grayscale values ​​of grayscale processed images corresponding to each sub-region to be inspected in the inspected image are compared and the target defect region is determined, the method further includes:

[0083] The grayscale processed image corresponding to the target defect area is input into the defect recognition model for processing, and the defect recognition result corresponding to the target defect area is output.

[0084] Among them, the defect recognition model can be a commonly used neural network model, a deep learning model or an image recognition model, etc.; the defect recognition result includes the defect type, defect area and defect severity corresponding to the target defect area; among them, the defect type can include scratches, bumps, nicks and pitting on the surface of the object, etc.

[0085] In this embodiment, further defect recognition is performed on the target defect area through the trained defect recognition model, which can output more detailed defect categories and defect area judgment results, thereby improving the accuracy of defect detection.

[0086] In some embodiments, Figure 6 As shown, the target defect area includes the defect type and defect area size; after grayscale value comparison is performed on the grayscale processed images corresponding to each sub-area to be detected in the image to be detected and the target defect area is determined, the method further includes:

[0087] Step S602: determining a corresponding defect area threshold according to the defect type of the target defect area.

[0088] Among them, different defect types correspond to different defect area thresholds.

[0089] Specifically, the computer device obtains the correspondence between various defect types and defect area thresholds, and then determines the corresponding defect area threshold according to the correspondence and the defect type of the target defect area.

[0090] Step S604, comparing the defect area size of the target defect region with the defect area threshold, and determining the defect detection result according to the comparison result.

[0091] Specifically, the computer device compares the defect area size of the target defect area with the defect area threshold. When the defect area is greater than or equal to the defect area threshold, the defect detection result is output as defect detection failure; when the defect area is less than the defect area threshold, the defect detection result is output as defect detection qualification.

[0092] In this embodiment, by determining the corresponding defect area threshold based on the specific defect type corresponding to the target defect area, and then comparing the target defect area with the defect area threshold, the defect detection result can be more accurately determined, which can effectively improve the accuracy of the defect detection result.

[0093] The present application also provides an application scenario, in which the method is applied to the scenario of AG glass defect detection. Specifically, the application of the defect detection method in the application scenario is as follows:

[0094] It should be noted that during the production process of AG glass, various surface defects often occur on the upper and lower surface areas of the glass, such as scratches, dents, nicks, pitting and other defect types. The surface of AG glass is microscopically uneven, so there will be a large number of normal tiny noise points in the imaging of AG glass. Therefore, the traditional defect detection method of the original glass surface using binarization and other methods cannot effectively distinguish between normal noise points and defective areas in AG glass.

[0095] In this embodiment, the defect detection method of AG glass includes the following steps: Figure 7 The detailed process is as follows:

[0096] (1) Positioning and division of detection areas

[0097] The image is compressed and sampled, and the sampled image is binarized using the difference in grayscale value between the AG glass and the background in the image, thereby achieving rough positioning of the AG glass area in the image, obtaining the first position information of the AG glass in the image (the first position information is the position information of the outer edge of the AG glass under rough positioning), and then resampling the outer edge of the AG glass based on the first position information to achieve fine-tuning of the edge area, thereby obtaining the second position information of the AG glass (the second position information is the accurate position). The specific fine-tuning method is to obtain the accurate edge point through a linear caliper, such as Figure 8 shown.

[0098] After obtaining the accurate position of the AG glass in the image, the inner area and the edge area of ​​the glass are divided, and then the inner area is divided again to obtain multiple independent sub-areas to be measured.

[0099] (2) Iterate the grayscale value of each sub-area to be tested

[0100] It should be noted that the surface of AG glass is uneven, and the defective area will have a feature different from the normal noise (that is, the overall grayscale mean distribution near the normal area tends to a constant value, while the grayscale value of the defective area will deviate from this constant value by a certain margin). The grayscale values ​​of each sub-area to be tested are balanced. The purpose of this balancing process is to make the grayscale values ​​of the normal / defect-free areas of the processed grayscale processed image tend to be within a similar range, thereby weakening the noise distribution characteristics caused by the normal property characteristics of the AG glass surface in the image, such as Fig. 9 As shown (the left picture shows the noise distribution in the AG glass image before balancing treatment, and the right picture shows the noise distribution in the AG glass image after balancing treatment).

[0101] In the specific process of balancing, the computer device performs iterative processing of the gray value of each target pixel in each sub-area to be tested according to the following formulas 4 to 6:

[0102]

[0103]

[0104]

[0105] in, and They are the target pixel points P i,j Grayscale values ​​before and after iteration, and The neighboring pixels P of the target pixel are k,l Grayscale values ​​before and after iteration, α is the fusion factor, d i,j,k,l Used to characterize the target pixel P i,j and its adjacent pixel points P k,l The gray value difference before the iteration.

[0106] (3) Determine the defect area based on the grayscale processing image

[0107] Using hypothesis testing, based on the mean and standard deviation obtained after the final iteration, the pixels that may have abnormalities in each sub-area to be tested are screened out, and then connected domain analysis is performed to obtain each area that may have abnormalities; the screened abnormal areas enter the deep segmentation model, and the defect type and detection results corresponding to the abnormal areas are output; then blob analysis is performed on the defective areas of deep reasoning to screen out defects that meet the defect requirements, and the target defective areas are output.

[0108] In this embodiment, the pixel noise points of each sub-region to be tested, into which the image to be tested is divided, are balanced so that the grayscale values ​​of the pixels with normal noise points and the pixels without noise points in each sub-region to be tested are close to each other, so that the grayscale values ​​of the pixels in the normal and defect-free areas in the corresponding sub-region to be tested reach a predetermined balance state, and a grayscale processed image is obtained, thereby further highlighting the grayscale value difference between the defective area and the normal area, effectively eliminating the interference of normal noise points in the sub-region to be tested on defect detection, and then comparing the grayscale values ​​of the grayscale processed image to obtain the target defective area, complete defect detection, and effectively improve the accuracy of defect detection.

[0109] It should be understood that, although the steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indications of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear description in this article, there is no strict order restriction on the execution of these steps, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments may include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.

[0110] In some embodiments, Fig.10 As shown, a defect detection device is provided, which can be a part of a computer device using a software module or a hardware module, or a combination of the two. The device specifically includes:

[0111] An acquisition module 1002 is used to divide the acquired image to be detected into a preset number of sub-areas to be detected;

[0112] The processing module 1004 is used to determine each target pixel and its adjacent pixel points in each sub-region to be tested, and calculate the gray value difference between each target pixel point and the corresponding adjacent pixel point; for each sub-region to be tested, based on the gray value difference, the gray value of the target pixel point and the fusion factor, the updated gray value of each target pixel point in each sub-region to be tested is obtained by fusion, and based on the updated gray value of each target pixel point, the gray processing image corresponding to the corresponding sub-region to be tested is determined; the fusion factor is used to characterize the magnitude of the gray value update amplitude of the target pixel point;

[0113] The determination module 1006 is used to compare the grayscale values ​​of the grayscale processed images corresponding to the sub-regions to be detected of the image to be detected, so as to determine the target defect region.

[0114] In some embodiments, the acquisition module 1002 is further configured to:

[0115] Acquire an initial image, the initial image includes a detection area and a non-detection area;

[0116] Binarize the initial image to determine the position information of the detection area in the initial image;

[0117] The image to be detected corresponding to the detection area is determined according to the position information.

[0118] In some embodiments, in performing binarization processing on the initial image and determining the position information of the detection area in the initial image, the acquisition module 1002 is specifically used to:

[0119] Binarization is performed on the initial image to obtain first position information of the detection area in the initial image, and a target reference image is determined according to the first position information; the target reference image includes a target detection area and a target non-detection area;

[0120] Based on the target function component, the boundary between the target detection area and the target non-detection area is detected to obtain the second position information of the target detection area in the target reference image; the target function component is used to determine the edge point according to the change of the pixel gray value at the corresponding position in the image;

[0121] In terms of determining the image to be detected corresponding to the area to be detected according to the position information, the acquisition module 1002 is specifically used for:

[0122] A target image to be detected corresponding to the target detection area is determined based on the second position information.

[0123] In some embodiments, for each sub-region to be tested, based on the gray value difference, the gray value of the target pixel and the fusion factor, the updated gray value of each target pixel in each sub-region to be tested is obtained by fusion, and based on the updated gray value of each target pixel, the gray processed image corresponding to the corresponding sub-region to be tested is determined, the processing module 1004 is specifically used to:

[0124] For each sub-region to be tested, based on the current gray value difference corresponding to the current iteration number, the current gray value of the target pixel and the fusion factor, the current updated gray value of each target pixel in each sub-region to be tested under the current iteration number is obtained by fusion;

[0125] When the current number of iterations is less than a preset threshold, return to the step of determining each target pixel and its adjacent pixel points in each sub-region to be tested, and calculating the gray value difference between each target pixel point and the corresponding adjacent pixel point;

[0126] When the current number of iterations reaches a preset threshold, the iteration is stopped, and based on the current updated grayscale value of each target pixel, a grayscale processed image corresponding to the corresponding sub-region to be tested is determined.

[0127] In some embodiments, in terms of comparing the grayscale values ​​of the grayscale processed images corresponding to the sub-regions to be detected in the image to be detected and determining the target defect region, the determination module 1006 is specifically used to:

[0128] Determine the standard grayscale value corresponding to each grayscale processed image and the preset grayscale value standard deviation;

[0129] For the grayscale processed images corresponding to each sub-area to be inspected of the image to be inspected, the grayscale values ​​of each area of ​​each grayscale processed image are compared according to the standard grayscale value corresponding to each grayscale processed image and the preset grayscale value standard deviation, and the corresponding target defect area is determined, thereby obtaining the target defect area of ​​each sub-area to be inspected.

[0130] In some embodiments, the determination module 1006 is further configured to:

[0131] The grayscale processed image corresponding to the target defect area is input into the defect recognition model for processing, and the defect recognition result corresponding to the target defect area is output; the defect recognition result includes the defect type, defect area and defect severity corresponding to the target defect area.

[0132] In some embodiments, the target defect area includes the defect type and defect area size; the determination module 1006 is further used to:

[0133] Determine a corresponding defect area threshold according to the defect type of the target defect area;

[0134] The defect area size of the target defect region is compared with the defect area threshold, and the defect detection result is determined based on the comparison result.

[0135] For the specific definition of the defect detection device, please refer to the definition of the defect detection method above, which will not be repeated here. Each module in the above-mentioned defect detection device can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.

[0136] In some embodiments, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Fig.11As shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. Among them, the processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store data of the image to be detected. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, the steps in the above-mentioned defect detection method are implemented.

[0137] In some embodiments, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Fig.12 As shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O), a communication interface, a display unit and an input device. Among them, the processor, the memory and the input / output interface are connected through a system bus, and the communication interface, the input device and the display unit are connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and the external device. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be implemented through WIFI, a mobile cellular network, NFC (near field communication) or other technologies. When the computer program is executed by the processor, the steps in the above-mentioned defect detection method are implemented. The display unit of the computer device is used to form a visually visible picture, which can be a display screen, a projection device or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covering the display screen, or a button, trackball or touchpad set on the computer device shell, or an external keyboard, touchpad or mouse.

[0138] Those skilled in the art will understand that Fig.11 and Fig.12The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0139] In some embodiments, a computer device is also provided. The computer device includes a memory and a processor. The memory stores a computer program. When the processor executes the computer program, the steps in the above method embodiments are implemented.

[0140] In some embodiments, a computer-readable storage medium 1300 is provided on which a computer program 1302 is stored. When the computer program 1302 is executed by a processor, the steps in the above-mentioned method embodiments are implemented. The internal structure diagram thereof can be as follows: Fig.13 shown.

[0141] In some embodiments, a computer program product is provided. The computer program product includes computer instructions. When a processor executes the computer instructions, the steps in the above-mentioned method embodiments are implemented.

[0142] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards of relevant countries and regions.

[0143] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.

[0144] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0145] The above embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. A defect detection method, characterized in that: include: Dividing the acquired image to be detected into a preset number of sub-areas to be detected; Determine each target pixel and its adjacent pixel in each sub-region to be tested, and calculate the gray value difference between each target pixel and the corresponding adjacent pixel; For each sub-region to be tested, based on the grayscale value difference, the grayscale value of the target pixel and the fusion factor, the updated grayscale value of each target pixel in each sub-region to be tested is obtained by fusion, and based on the updated grayscale value of each target pixel, the grayscale processed image corresponding to the corresponding sub-region to be tested is determined; the fusion factor is used to characterize the magnitude of the grayscale value update amplitude of the target pixel; Grayscale value comparison is performed on the grayscale processed images corresponding to each sub-region to be detected of the image to be detected to determine the target defect region.

2. The method according to claim 1, characterized in that Before dividing the acquired image to be detected into a preset number of sub-areas to be detected, the method further includes: Acquire an initial image, wherein the initial image includes a detection area and a non-detection area; Binarizing the initial image to determine the position information of the detection area in the initial image; The image to be detected corresponding to the detection area is determined according to the position information.

3. The method according to claim 2, characterized in that The binarization process is performed on the initial image to determine the position information of the detection area in the initial image, including: Binarizing the initial image to obtain first position information of the detection area in the initial image, and determining a target reference image according to the first position information; the target reference image includes a target detection area and a target non-detection area; Based on the target function component, the boundary between the target detection area and the target non-detection area is detected to obtain the second position information of the target detection area in the target reference image; the target function component is used to determine the edge point according to the change of the gray value of the pixel at the corresponding position in the image; The step of determining the image to be detected corresponding to the area to be detected according to the position information includes: A target image to be detected corresponding to the target detection area is determined based on the second position information.

4. The method according to claim 1, characterized in that: The method of obtaining, for each sub-region to be tested, an updated grayscale value of each target pixel in each sub-region to be tested by fusing the grayscale value difference, the grayscale value of the target pixel and the fusion factor, and determining a grayscale processed image corresponding to the sub-region to be tested based on the updated grayscale value of each target pixel, includes: For each sub-region to be tested, based on the current gray value difference corresponding to the current iteration number, the current gray value of the target pixel point and the fusion factor, the current updated gray value of each target pixel point in each sub-region to be tested at the current iteration number is obtained by fusion; When the current number of iterations is less than a preset threshold, returning to the step of determining each target pixel and its adjacent pixel points in each sub-region to be tested, and calculating the gray value difference between each target pixel point and the corresponding adjacent pixel point; When the current number of iterations reaches the preset threshold, the iteration is stopped, and based on the currently updated grayscale value of each target pixel, a grayscale processed image corresponding to the corresponding sub-region to be tested is determined.

5. The method according to claim 1, characterized in that The step of comparing the grayscale values ​​of the grayscale processed images corresponding to the sub-regions to be detected of the image to be detected to determine the target defect region includes: Determine the standard grayscale value corresponding to each grayscale processed image and the preset grayscale value standard deviation; For the grayscale processed images corresponding to each sub-area to be inspected of the image to be inspected, the grayscale values ​​of each area of ​​each grayscale processed image are compared according to the standard grayscale value corresponding to each grayscale processed image and the preset grayscale value standard deviation, and the corresponding target defect area is determined, thereby obtaining the target defect area of ​​each sub-area to be inspected.

6. The method according to claim 1, characterized in that After comparing the grayscale values ​​of the grayscale processed images corresponding to the sub-regions to be detected of the image to be detected and determining the target defect region, the method further includes: The grayscale processed image corresponding to the target defect area is input into the defect recognition model for processing, and the defect recognition result corresponding to the target defect area is output; the defect recognition result includes the defect type, defect area and defect severity corresponding to the target defect area.

7. The method according to claim 1, characterized in that The target defect area includes the defect type and defect area size; after the grayscale value comparison is performed on the grayscale processed images corresponding to each sub-area to be detected of the image to be detected and the target defect area is determined, the method further includes: Determining a corresponding defect area threshold according to the defect type of the target defect area; The defect area size of the target defect region is compared with the defect area threshold, and the defect detection result is determined according to the comparison result.

8. A defect detection device, characterized in that: include: An acquisition module, used for dividing the acquired image to be detected into a preset number of sub-areas to be detected; A processing module, used to determine each target pixel and its adjacent pixel points in each sub-region to be tested, and calculate the gray value difference between each target pixel point and the corresponding adjacent pixel point; for each sub-region to be tested, based on the gray value difference, the gray value of the target pixel point and the fusion factor, fuse to obtain the updated gray value of each target pixel point in each sub-region to be tested, and determine the gray processing image corresponding to the corresponding sub-region to be tested based on the updated gray value of each target pixel point; The fusion factor is used to characterize the magnitude of the grayscale value update of the target pixel; The determination module is used to compare the grayscale values ​​of the grayscale processed images corresponding to each sub-region to be detected of the image to be detected, so as to determine the target defect region.

9. A computer device, comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.