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

By performing grayscale threshold segmentation and edge removal of the image to be detected, subdividing it into areas to be processed, and performing defect area proportion and density calculations, the problems of defect detection accuracy and inefficiency in the prior art are solved, and efficient and comprehensive defect detection is achieved.

CN119648634APending Publication Date: 2025-03-18ZHONGKE HUIYUAN VISUAL TECHNOLOGY (LUOYANG) CO LTD +2
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411615130.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-12
Publication Date
2025-03-18

AI Technical Summary

Technical Problem

The existing defect detection technology is not accurate, inefficient, and cannot fully reflect the product appearance defects.

Method used

By acquiring the image to be detected of the object to be detected, the area to be detected is determined based on the first preset grayscale threshold value, the edge part is removed to determine the target detection area, and subdividing it into a plurality of areas to be processed. The target operation types such as defect area proportional operations and defect density operations are used for analysis to obtain defect detection results.

Benefits of technology

It realizes accurate, efficient and comprehensive detection of product appearance defects, reduces external interference, improves the stability and accuracy of detection, and can comprehensively evaluate defect conditions from different angles.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119648634A_ABST
    Figure CN119648634A_ABST
Patent Text Reader

Abstract

The invention discloses a defect detection method and device, a storage medium, computer equipment and detection equipment, relates to the technical field of product surface quality detection, and mainly aims to eliminate external interference so as to realize accurate, efficient and comprehensive detection of product appearance defects. According to the main technical scheme, the defect detection method comprises the steps of obtaining a to-be-detected image of a to-be-detected object; segmenting the to-be-detected image based on a first preset gray threshold, and determining a to-be-detected area; removing an edge part of the to-be-detected area based on a preset edge range, and determining a target detection area in the to-be-detected area, the target detection area comprising a plurality of to-be-processed areas; each to-be-processed area is identified from the target detection area, a defect detection result corresponding to the to-be-detected object is obtained based on a target operation type and the to-be-processed areas, and the target operation type comprises defect area proportion operation and defect density operation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of product surface quality detection, and in particular to a defect detection method, device, storage medium, computer equipment and detection equipment. Background Art

[0002] In the fields of industrial production and quality inspection, defect detection of product appearance quality is crucial. Traditional defect detection methods often have problems such as low accuracy and low efficiency.

[0003] At present, many defect detection technologies usually use a single image processing method, such as determining the area where defects may exist only through simple grayscale threshold segmentation. However, this method is easily affected by image noise and edge interference, resulting in inaccurate detection results. Moreover, after determining the detection area, there is a lack of fine division and targeted analysis inside the detection area, and it is impossible to accurately identify different types of defect features.

[0004] At the same time, the existing methods are relatively single in operation type and often only focus on one aspect of the characteristics, such as only considering the area size of the defect, while ignoring other important characteristics such as the density of the defect, and cannot fully reflect the defect situation of the object to be inspected.

[0005] In summary, a more accurate, efficient and comprehensive defect detection method is needed to meet the needs of actual production and inspection. Summary of the invention

[0006] In view of this, the present application provides a defect detection method, device, storage medium, computer equipment and detection equipment, the main purpose of which is to eliminate external interference, thereby achieving accurate, efficient and comprehensive detection of product appearance defects.

[0007] In order to achieve the above objectives, this application mainly provides the following technical solutions:

[0008] In a first aspect of the present application, a defect detection method is provided, comprising:

[0009] Acquire an image of the object to be detected;

[0010] Segment the image to be detected based on a first preset grayscale threshold to determine an area to be detected;

[0011] Based on a preset edge range, the edge portion of the area to be detected is removed to determine a target detection area inside the area to be detected, wherein the target detection area includes a plurality of areas to be processed;

[0012] Each of the to-be-processed areas is identified from the target detection area, and based on the target operation type and the multiple to-be-processed areas, a defect detection result corresponding to the to-be-detected object is obtained, wherein the target operation type includes a defect area ratio operation and a defect density operation.

[0013] Optionally, obtaining the image to be detected of the object to be detected includes:

[0014] Preprocessing the initial image to obtain a preprocessed image;

[0015] Performing filtering on the preprocessed image to obtain a filtered image;

[0016] The filtered image is normalized to obtain the image to be detected.

[0017] Optionally, the preprocessing of the initial image includes:

[0018] The initial image is scaled.

[0019] Optionally, the filtering the pre-processed image includes:

[0020] Performing a first filtering process on the preprocessed image based on a first preset standard deviation to obtain a first smoothed image;

[0021] Performing a second filtering process on the preprocessed image based on a second preset standard deviation to obtain a second smoothed image;

[0022] The difference between the corresponding pixel points of the first smoothed image and the second smoothed image is calculated, and the filtered image is obtained by performing a difference operation on each corresponding pixel point one by one.

[0023] Optionally, the normalizing the filtered image includes:

[0024] The grayscale value of each pixel in the filtered image is mapped to a preset grayscale screening range.

[0025] Optionally, the grayscale value of each pixel in the area to be detected is less than the first preset grayscale threshold.

[0026] Optionally, after removing the edge portion of the to-be-detected area based on a preset edge range and determining the target detection area inside the to-be-detected area, the method further includes:

[0027] The target detection area is segmented based on a second preset grayscale threshold to determine a defect area.

[0028] Optionally, the grayscale value of each pixel in the defect area is less than the second preset grayscale threshold.

[0029] Optionally, the second preset grayscale threshold is smaller than the first preset grayscale threshold.

[0030] Optionally, before identifying each of the to-be-processed areas from the target detection area, the method further includes:

[0031] The target detection area is divided into a plurality of to-be-processed areas of equal size.

[0032] A second aspect of the present application provides a defect detection device, comprising:

[0033] An image acquisition module, used to acquire an image of an object to be detected;

[0034] A first image segmentation module, used to segment the image to be detected based on a first preset grayscale threshold to determine a region to be detected;

[0035] An edge processing module, used to remove the edge portion of the to-be-detected area based on a preset edge range, and determine a target detection area inside the to-be-detected area, wherein the target detection area includes a plurality of to-be-processed areas;

[0036] The defect analysis module is used to identify each of the to-be-processed areas from the target detection area, and obtain defect detection results corresponding to the to-be-detected object based on a target operation type and the multiple to-be-processed areas, wherein the target operation type includes a defect area ratio operation and a defect density operation.

[0037] Optionally, the image acquisition module includes:

[0038] A scale scaling unit, used for performing scale scaling processing on the initial image to obtain a preprocessed image;

[0039] A filtering unit, used for filtering the pre-processed image to obtain a filtered image;

[0040] The grayscale normalization unit is used to map the grayscale value of each pixel in the filtered image to a preset grayscale screening range to obtain the image to be detected.

[0041] Optionally, the filtering unit includes:

[0042] A first filtering subunit, configured to perform a first filtering process on the preprocessed image based on a first preset standard deviation to obtain a first smoothed image;

[0043] A second filtering subunit, configured to perform a second filtering process on the preprocessed image based on a second preset standard deviation to obtain a second smoothed image;

[0044] The difference calculation subunit is used to calculate the difference between the corresponding pixel points of the first smoothed image and the second smoothed image, and obtain the filtered image by performing difference operation on each corresponding pixel point one by one.

[0045] Optionally, the defect analysis module includes:

[0046] The area identification unit is used to respectively identify each of the to-be-processed areas from the target detection area.

[0047] Optionally, the defect analysis module further includes:

[0048] The array processing unit is used to obtain defect detection results corresponding to the object to be detected based on a target operation type and the multiple areas to be processed, wherein the target operation type includes a defect area ratio operation and a defect density operation.

[0049] Optionally, the defect detection device further includes:

[0050] The second image segmentation module is used to segment the target detection area based on a second preset grayscale threshold to determine the defect area.

[0051] Optionally, the defect detection device further includes:

[0052] The area division module divides the target detection area into a plurality of to-be-processed areas of equal size.

[0053] According to a third aspect of the present application, a storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the defect detection method described in any one of the above items is implemented.

[0054] In a fourth aspect of the present application, a computer device is provided, comprising a storage medium, a processor, and a computer program stored on the storage medium and executable on the processor, wherein the processor implements any of the above-described defect detection methods when executing the computer program.

[0055] A fifth aspect of the present application provides a detection device, comprising any one of the defect detection devices described above.

[0056] By means of the above technical solution, the present application has at least the following beneficial effects:

[0057] The defect detection method provided in the embodiment of the present application can preliminarily screen out the range where defects may exist, reduce interference from irrelevant areas, and improve the pertinence of subsequent detection by acquiring the image to be detected of the object to be detected and segmenting it based on the first preset grayscale threshold to determine the area to be detected. The target detection area is determined by removing the edge portion of the area to be detected. Considering that the edge portion is easily affected by external factors and may produce inaccurate results, focusing on the internal area can make the detection more stable and reliable, thereby improving the accuracy of the overall detection. By further subdividing the target detection area into multiple areas to be processed and using target operation types such as defect area ratio calculation and defect density calculation for analysis, the defect situation can be comprehensively evaluated from different angles, and it can be more accurately determined whether the object to be detected has defects and the severity and distribution of the defects. BRIEF DESCRIPTION OF THE DRAWINGS

[0058] Figure 1 A schematic flow chart of a defect detection method according to an optional embodiment of the present application;

[0059] Figure 2 A schematic diagram of a preprocessed image of an object to be detected according to an optional embodiment of the present application;

[0060] Figure 3 A schematic diagram of an image to be detected of an object to be detected in an optional embodiment of the present application;

[0061] Figure 4 for Figure 3 A partial enlarged view of the image to be detected is shown;

[0062] Figure 5 A schematic diagram of a detection area of ​​an object to be detected and a target detection area in an optional embodiment of the present application;

[0063] Figure 6 A schematic diagram of multiple areas to be processed of an object to be detected in an optional embodiment of the present application;

[0064] Figure 7 This is a schematic structural diagram of a defect detection device according to an optional embodiment of the present application. DETAILED DESCRIPTION

[0065] The exemplary embodiments of the present application will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present application are shown in the accompanying drawings, it should be understood that the present application can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided in order to enable a more thorough understanding of the present application and to fully convey the scope of the present application to those skilled in the art.

[0066] See the attached drawings in the specification Figure 1As shown, the embodiment of the present application provides a defect detection method, including:

[0067] Step S101: Acquire an image of an object to be detected.

[0068] The defect detection method provided in the embodiment of the present application can be applied to fields such as industrial appearance defect detection, and can be specifically applied to machine vision technology. When performing appearance defect detection, first, an image to be detected corresponding to the object to be detected can be obtained. Here, the object to be detected refers to the appearance of an object that needs to be tested for surface defects. Specifically, an image acquisition device such as a camera, a scanner, or a camera can be used to capture the appearance of the object to be detected to obtain a corresponding image to be detected.

[0069] It should be noted that the image to be detected can be an image directly acquired by an image acquisition device such as a camera, a scanner, or a webcam, or can be an image formed by processing an initial image obtained by these image acquisition devices.

[0070] In order to eliminate external interference and enable the image to be detected to accurately reflect the image information of the characteristics of the object to be detected, the following will use the image to be detected formed by processing the initial image obtained by an image acquisition device (such as a camera, scanner, camera, etc.) as an example for explanation.

[0071] Step S101 includes:

[0072] Step S1011: preprocess the initial image to obtain a preprocessed image.

[0073] In this embodiment, the initial image is an unprocessed image directly acquired by the image acquisition device. Preprocessing is a series of operations performed on the initial image to improve image quality, enhance useful information, remove noise and interference, etc., so that it is more suitable for subsequent analysis and processing. Among them, the preprocessing operation includes but is not limited to image denoising, image enhancement, and image correction.

[0074] Here, the initial image is preprocessed, including: scaling the initial image. It is understandable that the initial image collected by the image acquisition device on site usually has a high resolution, but there are also many extremely small noise points. By scaling, these noise points can be effectively removed, while retaining the main information of the initial image, and will not affect the appearance defects of the initial image, and can also improve the efficiency of subsequent processing. In specific application scenarios, a suitable scaling ratio can be selected according to specific needs, such as reducing the size of the initial image to 50% or 25% of the original. In the selection of scaling method, bilinear interpolation or bicubic interpolation method can be used to ensure the quality of the scaled image. The scaled preprocessed image can be found in the attached figure of the specification. Figure 2 .

[0075] Step S1012: Filter the preprocessed image to obtain a filtered image.

[0076] In this embodiment, the pre-processed image is an image after a series of operations such as resizing the initial image, but some residual noise or interference may still exist. Filtering is to apply a specific algorithm to the pre-processed image to further remove noise, enhance specific features of the image, or smooth the image. Among them, filtering includes but is not limited to differential filtering, mean filtering, and median filtering.

[0077] Here, the preprocessed image is filtered, and the specific process is as follows: First, the preprocessed image is filtered for the first time according to the first preset standard deviation, and the first smoothed image can be obtained through this step. Then, the preprocessed image is filtered for the second time according to the second preset standard deviation, so that the second smoothed image can be obtained. Finally, the difference between the corresponding pixels of the first smoothed image and the second smoothed image is calculated, and the filtered image is obtained by performing such a difference operation on each corresponding pixel one by one. Specifically, the initial image can be filtered using a Gaussian difference filter. This method can effectively enhance the edge information of the image, highlight the edge features of the appearance defects, and make the appearance defects more prominent, so as to facilitate subsequent detection and segmentation operations. The Gaussian difference filter is an edge detection operator, and its working principle is to first perform Gaussian filtering of two different scales (i.e., standard deviations are σ1 and σ2) on the initial image, and then calculate their difference, so as to approximately achieve the effect of the Laplace-Gaussian filter.

[0078] Furthermore, the Difference of Gaussians (DoG) filter is obtained by subtracting two Gaussian filters with different standard deviations, namely:

[0079] DoG(x,y)=G(x,y,σ1)-G(x,y,σ2)

[0080] Among them, G(x, y, σ1) and G(x, y, σ2) are two-dimensional Gaussian functions with standard deviations σ1 and σ2 respectively. The formula of the two-dimensional Gaussian function is:

[0081]

[0082] Where (x, y) is the pixel coordinate in the image, and σ is the standard deviation of the Gaussian function, which controls the smoothness of the Gaussian filter. The larger the standard deviation, the larger the range of the filter and the smoother the image.

[0083] In the embodiment of the present application, a Gaussian difference filter is used to perform a smoothing operation on the initial image, and the operation is mainly achieved by performing two sets of Gaussian filtering under different standard deviation settings on the initial image. Specifically, the initial image is filtered using Gaussian filters with a standard deviation of the first preset standard deviation (denoted as σ1) and a second preset standard deviation (denoted as σ2). First, the initial image is input into a Gaussian filter with a standard deviation of σ1. According to the algorithm principle of Gaussian filtering, this filter will perform a specific weighted operation on each pixel in the image and its surrounding pixels according to the value of σ1. After this series of operations, it can effectively smooth out some noise in the image and some relatively subtle texture information, and then obtain a first smoothed image. Then, the initial image is sent to a Gaussian filter with a standard deviation of σ2. The algorithm logic of Gaussian filtering is also followed, but this time the image pixels are weighted based on the value of σ2 to obtain a second smoothed image. Finally, for the obtained first smoothed image and the second smoothed image, the final filtered image is obtained by calculating the difference between their corresponding pixels one by one. That is to say, for each pixel position in the image, the pixel value of the first smoothed image at that position is subtracted from the pixel value of the second smoothed image at the corresponding position. The new pixel matrix formed after the difference calculation of all these pixels is the filtered image successfully obtained through this Gaussian difference filter processing.

[0084] In a specific application scenario, the first preset standard deviation (σ1) and the second preset standard deviation (σ2) are 2 and 4 respectively. The smaller first preset standard deviation (σ1) can retain more details of the preprocessed image, while the larger second preset standard deviation (σ2) can smooth out the noise in the preprocessed image. It can be understood that using two Gaussian filters of different scales to smooth the preprocessed image and then calculating the difference between the first smoothed image and the second smoothed image can highlight the edge and detail information in the image, making the defect area more obvious in the filtered image obtained after filtering, which is convenient for subsequent detection.

[0085] Step S1013: normalize the filtered image to obtain an image to be detected.

[0086] In this embodiment, the filtered image is an image obtained after a specific filtering process is performed on the pre-processed image. In order to facilitate subsequent processing and analysis and make data between different regions of the same image comparable, the filtered image is normalized. The normalization process includes but is not limited to pixel value range adjustment, contrast adjustment, and data standardization.

[0087] Here, the filtered image is normalized, including: mapping the grayscale value of each pixel in the filtered image to a preset grayscale screening range. In the image, each pixel has a grayscale value, which represents the brightness or color depth of the pixel. Mapping the grayscale value of each pixel in the filtered image to the preset grayscale screening range means adjusting the grayscale value of each pixel in the filtered image to within the preset grayscale screening range.

[0088] In a specific application scenario, the preset grayscale screening range is set to [0, 255]. By linearly stretching or scaling the grayscale value of the filtered image, the negative values ​​or values ​​that may have originally appeared or exceeded the range of [0, 255] can be adjusted to fit the standard grayscale display range [0, 255]. The image to be detected after such processing can be correctly displayed in a conventional 8-bit grayscale image format, that is, the value of each pixel is between 0 and 255. In this way, not only the contrast of the image to be detected is enhanced, but also the influence of factors such as lighting on the image to be detected can be eliminated.

[0089] Further, in the embodiment of the present application, the normalization process complies with the formula:

[0090] I norm =[(I-min(I)) / (max(I)-min(I))]*255

[0091] Where I is the grayscale value of the pixel of the filtered image before normalization, I norm is the grayscale value of the pixel of the image to be detected after normalization, min(I) and max(I) are the minimum grayscale value and maximum grayscale value of the pixel of the filtered image before normalization.

[0092] The grayscale value range of the pixel point [min(I), max(I)] is linearly mapped to the range of [0, 1] (through the part (I-min(I)) / (max(I)-min(I))), and then expanded to the range of [0, 255] (multiplied by 255). In this embodiment, the image to be detected after normalization processing and the local enlarged image of the image to be detected are respectively shown in the accompanying drawings of the specification Figure 3 and the accompanying drawings Figure 4 .

[0093] Step S201: segmenting the image to be detected based on a first preset grayscale threshold to determine the area to be detected.

[0094] In this embodiment, the image to be detected is an image obtained after a series of processing, and is used to detect whether there are specific features or defects therein. The first preset grayscale threshold is a grayscale value determined in advance. When the image to be detected is segmented, the grayscale value of each pixel in the image to be detected is compared with the first preset grayscale threshold. If the grayscale value of the pixel is greater than or equal to the first preset grayscale threshold, the pixel is excluded from the area to be detected; if the grayscale value of the pixel is less than the first preset grayscale threshold, it is determined that the pixel belongs to the area to be detected.

[0095] In a specific application scenario, the first preset grayscale threshold is set to 20. By comparing the grayscale value of each pixel in the image to be detected with the threshold, the area to be detected and the area not to be detected can be effectively divided. Figure 5 , the area to be detected is the contour area of ​​the object to be detected. When the gray value of a pixel is less than 20, the pixel is determined to belong to the contour area of ​​the object to be detected. The contour area of ​​the object to be detected contains the specific features or defects of interest. For these pixels determined to belong to the contour area of ​​the object to be detected, further analysis and processing can be performed. For example, the area, shape and other features of the contour area of ​​the object to be detected can be counted to more accurately determine whether there are defects and the severity of the defects. At the same time, a certain degree of monitoring can also be performed for pixels excluded from the contour area of ​​the object to be detected. Although these pixels do not belong to the contour area of ​​the object to be detected under the current judgment criteria, their changes may also provide a reference for the analysis of the overall image. For example, if the pixels outside the contour area of ​​the object to be detected show an abnormal change trend, it may mean that there are external interference factors in the image acquisition process, and the acquisition equipment or environment needs to be checked and adjusted. In addition, in practical applications, the first preset gray threshold can be dynamically adjusted according to different detection requirements and image characteristics. If it is found that the currently set first preset grayscale threshold cannot accurately divide the area to be inspected, a more appropriate first preset grayscale threshold can be re-determined through experiments and analysis to improve the accuracy and reliability of defect detection.

[0096] Step S301: removing the edge portion of the area to be detected based on a preset edge range, and determining a target detection area inside the area to be detected, wherein the target detection area includes a plurality of areas to be processed.

[0097] In this embodiment, the area to be detected is an area that may contain specific features or defects determined through the previous steps (for example, based on the first gray threshold segmentation operation). The preset edge range is a preset distance or range value, which is usually determined based on the actual application scenario and past experience. Its purpose is to remove the inaccuracy or interference that may exist at the edge of the area to be detected. The target detection area is obtained by removing the edge of the area to be detected. This is done to be able to focus more on the core part inside the area to be detected for further analysis. This is because the edge of the area to be detected is very likely to be greatly affected by external factors (such as Gaussian difference filtering used in the image preprocessing process), while the target detection area inside the area to be detected is relatively more stable and reliable. The target detection area may include multiple areas to be processed, and these areas to be processed may be areas that may be used for defect detection in the future.

[0098] In a specific application scenario, the size of the area to be detected is 1700mm×800mm, and the preset margin range is: upper margin margin_up=100mm, lower margin margin_down=120mm, left margin margin_left=0mm, right margin margin_right=40mm. The size of the target detection area thus extracted is 1500mm×600mm. For details, please refer to the attached figure of the specification. Figure 5 By extracting the target detection area inside the area to be detected, external interference can be eliminated, focusing on detecting the appearance defects inside the area to be detected, and improving the accuracy of the detection results.

[0099] Step S401: Identify each area to be processed from the target detection area, and obtain defect detection results corresponding to the object to be detected based on the target operation type and the multiple areas to be processed. The target operation type includes defect area ratio operation and defect density operation.

[0100] In this embodiment, the target detection area is the internal area obtained after removing the edge portion of the area to be detected, which is relatively stable and reliable, and contains multiple areas to be processed. Each area to be processed is identified from the target detection area, the purpose of which is to clearly distinguish these different local areas so that each area to be processed can be analyzed in depth separately. The target operation type includes defect area ratio operation and defect density operation. Among them, the defect area ratio operation refers to calculating the ratio between the area of ​​the defective part of the area to be processed and the area of ​​the entire area to be processed. This ratio can reflect the relative size of the defect in the area. For example, if the area of ​​a to-be-processed area is 100 square millimeters, and the area of ​​the defective part is 20 square millimeters, then the defect area ratio is 20%. The defect density operation is used to calculate the number of defects per unit area. For example, in a to-be-processed area of ​​a certain size, there are 5 defects according to statistics, and the area of ​​the area is 10 square millimeters, then the defect density is 0.5 defects per square millimeter. By performing these target operation types of calculations on multiple areas to be processed respectively, and taking into account the specific conditions of each area to be processed, the defect detection results corresponding to the object to be detected can be finally obtained. This result can clearly indicate whether the object to be inspected has defects, the severity of the defects, and the distribution of the defects, thereby providing a strong basis for subsequent decision-making and processing. In addition, the target inspection area is divided into multiple areas to be processed, and different screening processes can be performed on the multiple areas to be processed. For example, defects in the edge area may be caused by factors such as lighting, which will have certain defects. We can use statistical analysis methods to eliminate these interference factors, improve the accuracy of detection, and reduce over-inspection.

[0101] In specific application scenarios, dividing the target detection area into multiple processed areas of equal size can better capture the detailed features of each processed area.

[0102] The values ​​of the side lengths M and N of the area to be processed can be flexibly adjusted according to specific positioning requirements, and this embodiment does not limit this. Specifically, taking this experimental case as an example, refer to the attached drawings of the specification. Figure 6 As shown, the target detection area is divided into 6*3 areas to be processed.

[0103] In the embodiment of the present application, after "removing the edge portion of the area to be detected based on a preset edge range" in step S301, the defect detection method further includes: segmenting the target detection area based on a second preset grayscale threshold to determine the defect area.

[0104] In this embodiment, the target detection area is an internal area that is relatively stable and contains multiple areas to be processed, which is determined after a series of previous processes. The second preset grayscale threshold is another grayscale value set in advance. The determination of this threshold is usually also set according to actual detection needs, image characteristics and experience. When the target detection area is segmented, the grayscale value of each pixel in the target detection area is compared with the second preset grayscale threshold. If the grayscale value of the pixel is greater than or equal to the second preset grayscale threshold, the pixel is excluded from the defect area; if the grayscale value of the pixel is less than the second preset grayscale threshold, it is determined that the pixel belongs to the defect area. In this way, a clear defect area can be further divided from the target detection area, so as to more accurately locate and analyze the defective part in the object to be detected, and provide a more specific target area for subsequent defect evaluation and processing.

[0105] In a specific application scenario, the second preset grayscale threshold is set to 10, see the attached figure of the specification Figure 6 , by comparing the grayscale value of each pixel in the target detection area with this threshold, the defect area and the non-defect area can be effectively divided. When the grayscale value of a pixel is less than 10, the pixel is judged to belong to the defect area. This area is the object of our focus and may contain specific defects of the object to be detected. For these pixels determined as defect areas, further detailed analysis and evaluation can be performed. For example, the area, shape, depth and other characteristics of the defect area can be measured to more accurately judge the severity of the defect and the impact on product performance. At the same time, for the pixels excluded from the defect area, a certain degree of monitoring can also be performed. Although these pixels do not belong to the defect area under the current judgment standard, their changes may also provide a reference for the analysis of the overall image. For example, if the pixels in the non-defect area show an abnormal change trend, it may mean that there are external interference factors in the detection process, and the detection equipment or environment needs to be checked and adjusted. In addition, in practical applications, the second preset grayscale threshold can be dynamically adjusted according to different detection requirements and image characteristics. If it is found that the currently set threshold cannot accurately divide the defect area, a more appropriate second preset grayscale threshold can be re-determined through experiments and analysis to improve the accuracy and reliability of defect detection.

[0106] In the embodiment of the present application, the second preset grayscale threshold is smaller than the first preset grayscale threshold.

[0107] In this embodiment, the first preset grayscale threshold is used to segment the image to be detected to determine the area to be detected, and the second preset grayscale threshold is used to further determine the defect area in the target detection area. Generally, the first preset grayscale threshold is high in order to more broadly determine a larger range that may contain specific features or defects, that is, the area to be detected, in the initial stage. The determination of this larger range can help exclude some obviously irrelevant areas and provide a basis for subsequent more detailed analysis. The second preset grayscale threshold is smaller because in the target detection area, the real defective parts need to be screened out more strictly. A smaller threshold can make the detection more sensitive, ensuring that only those pixels with lower grayscale values ​​(or those that meet a specific relationship with a smaller threshold according to specific judgment rules) are determined as defective areas, thereby improving the accuracy and precision of defect detection.

[0108] In the embodiment of the present application, before "respectively identifying each to-be-processed area from the target detection area" in step S401, the defect detection method further includes: dividing the target detection area into a plurality of to-be-processed areas.

[0109] In this embodiment, the target detection area is an internal area that is relatively stable and may contain defects after a series of processing. The target detection area is divided to obtain multiple areas to be processed, which mainly has the following purposes and functions: From the analysis point of view, dividing multiple areas to be processed can subdivide the target detection area, making the analysis of the target detection area more detailed and comprehensive. Each area to be processed can be observed and processed separately, so that possible local defects can be detected more accurately. For example, if the target detection area is large as a whole, direct defect analysis may ignore some small-scale defects. After dividing it into multiple small areas to be processed, each small area can be inspected more finely to improve the sensitivity of defect detection. From the operation point of view, multiple areas to be processed can facilitate specific operation operations. For example, in the subsequent defect detection process, target operation types such as defect area ratio operation and defect density operation can be calculated for each area to be processed. In this way, the defect conditions of different local areas can be understood more accurately, and the results of multiple areas to be processed can be combined to obtain more comprehensive defect detection results. It can be understood that in actual operation, the division method can be selected according to specific needs. The target detection area can be divided into multiple processing areas of equal size by uniform division, which is convenient for standardized processing and analysis. Non-uniform division can also be performed according to specific characteristics or rules, such as the shape of the target detection area, the location distribution of possible defects, etc., to better adapt to different detection scenarios.

[0110] The defect detection method provided in the embodiment of the present application can preliminarily screen out the range where defects may exist, reduce interference from irrelevant areas, and improve the pertinence of subsequent detection by acquiring the image to be detected of the object to be detected and segmenting it based on a first preset grayscale threshold to determine the area to be detected. The target detection area is determined by removing the edge portion of the area to be detected. Considering that the edge portion is easily affected by external factors and may produce inaccurate results, focusing on the internal area can make the detection more stable and reliable, thereby improving the accuracy of the overall detection. By further subdividing the target detection area into multiple areas to be processed and using target operation types such as defect area ratio calculation and defect density calculation for analysis, the defect situation can be comprehensively evaluated from different angles, and it can be more accurately determined whether the object to be detected has defects and the severity and distribution of the defects.

[0111] Furthermore, the defect detection method provided in the embodiment of the present application gradually narrows the detection range through a series of targeted steps, from the overall image to the area to be detected, then to the target detection area and the area to be processed, thereby reducing unnecessary calculations and improving the efficiency of detection. At the same time, the defect detection method has a clear detection process and adjustable parameter settings, so that parameters can be quickly optimized and adjusted in practical applications, shortening the detection time and improving production efficiency.

[0112] As a drawing of the specification Figure 1 The specific implementation of the defect detection method shown in the figure, the embodiment of the present application provides a defect detection device, see the accompanying drawings of the specification Figure 7 As shown, the defect detection device includes:

[0113] An image acquisition module, used to acquire an image of an object to be detected;

[0114] A first image segmentation module, used to segment the image to be detected based on a first preset grayscale threshold value to determine the area to be detected;

[0115] An edge processing module is used to remove the edge portion of the area to be detected based on a preset edge range, and determine a target detection area inside the area to be detected, where the target detection area includes multiple areas to be processed;

[0116] The defect analysis module is used to identify each area to be processed from the target detection area, and obtain defect detection results corresponding to the object to be detected based on the target operation type and multiple areas to be processed. The target operation type includes defect area ratio operation and defect density operation.

[0117] Furthermore, the image acquisition module includes:

[0118] A scale scaling unit, used for performing scale scaling processing on the initial image to obtain a preprocessed image;

[0119] A filtering unit, used for filtering the preprocessed image to obtain a filtered image;

[0120] The grayscale normalization unit is used to map the grayscale value of each pixel in the filtered image to a preset grayscale screening range to obtain the image to be detected.

[0121] Furthermore, the filtering unit comprises:

[0122] A first filtering subunit, configured to perform a first filtering process on the preprocessed image based on a first preset standard deviation to obtain a first smoothed image;

[0123] A second filtering subunit, configured to perform a second filtering process on the preprocessed image based on a second preset standard deviation to obtain a second smoothed image;

[0124] The difference calculation subunit is used to calculate the difference between the first smoothed image and the second smoothed image, so as to obtain a filtered image.

[0125] Furthermore, the defect analysis module includes:

[0126] The region identification unit is used to identify each to-be-processed region from the target detection region.

[0127] Furthermore, the defect analysis module also includes:

[0128] The array processing unit is used to obtain defect detection results corresponding to the object to be detected based on the target operation type and multiple areas to be processed. The target operation type includes defect area ratio operation and defect density operation.

[0129] Furthermore, the defect detection device further comprises:

[0130] The second image segmentation module is used to segment the target detection area based on a second preset grayscale threshold to determine the defect area.

[0131] Furthermore, the defect detection device further comprises:

[0132] The area division module divides the target detection area into multiple areas to be processed.

[0133] It should be noted that for other corresponding descriptions of the functional units involved in the defect detection device provided in the embodiment of the present application, please refer to the accompanying drawings of the specification. Figure 1 The corresponding description of the defect detection method shown will not be repeated here.

[0134] Based on the above description Figure 1 The defect detection method shown in the figure, accordingly, the embodiment of the present application also provides a storage medium on which a computer program is stored, and when the computer program is executed by the processor, the above-mentioned specification drawings are implemented Figure 1 Defect detection method shown.

[0135] Based on this understanding, the technical solution of the present application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, USB flash drive, mobile hard disk, etc.), including a number of instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to execute the methods of various implementation scenarios of the present application.

[0136] Based on the above description Figure 1 The defect detection method shown in the figure and the specification drawings Figure 7 In order to achieve the above-mentioned purpose, the embodiment of the present application also provides a computer device, which can be a personal computer, a server, a network device, etc. The computer device includes a storage medium and a processor; the storage medium is used to store a computer program; the processor is used to execute the computer program to implement the above-mentioned specification drawings Figure 1 Defect detection method shown.

[0137] Furthermore, the computer device may also include a user interface, a network interface, a camera, a radio frequency (RF) circuit, a sensor, an audio circuit, a WI-FI module, etc. The user interface may include a display screen (Display), an input unit such as a keyboard (Keyboard), etc., and the optional user interface may also include a USB interface, a card reader interface, etc. The network interface may optionally include a standard wired interface, a wireless interface (such as a Bluetooth interface, a WI-FI interface), etc.

[0138] Those skilled in the art will appreciate that the computer device structure provided in the embodiment of the present application does not constitute a limitation on the computer device, and may include more or fewer components, or a combination of certain components, or different component arrangements.

[0139] The storage medium may also include an operating system and a network communication module. The operating system is a program that manages and saves the hardware and software resources of the computer device, and supports the operation of information processing programs and other software and / or programs. The network communication module is used to realize communication between the components inside the storage medium, and communication with other hardware and software in the physical device.

[0140] Through the description of the above implementation methods, those skilled in the art can clearly understand that the present application can be implemented by means of software plus a necessary general hardware platform, or by hardware.

[0141] An embodiment of the present application also provides a detection device, including the defect detection device as described above. Other corresponding descriptions of the functional units involved in the detection device can correspond to the description of the defect detection device mentioned above, and will not be repeated here.

[0142] The above disclosure only discloses several specific implementation scenarios of the present application. However, the present application is not limited thereto, and any changes that can be conceived by technicians in this field should fall within the scope of protection of the present application.

Claims

1. A defect detection method, characterized in that: include: Acquire an image of the object to be detected; Segment the image to be detected based on a first preset grayscale threshold to determine an area to be detected; Based on a preset edge range, the edge portion of the area to be detected is removed to determine a target detection area inside the area to be detected, wherein the target detection area includes a plurality of areas to be processed; Each of the to-be-processed areas is identified from the target detection area, and based on the target operation type and the multiple to-be-processed areas, a defect detection result corresponding to the to-be-detected object is obtained, wherein the target operation type includes a defect area ratio operation and a defect density operation.

2. The defect detection method according to claim 1, characterized in that: The step of obtaining the image of the object to be detected comprises: Preprocessing the initial image to obtain a preprocessed image; Performing filtering on the preprocessed image to obtain a filtered image; The filtered image is normalized to obtain the image to be detected.

3. The defect detection method according to claim 2, characterized in that: The preprocessing of the initial image comprises: The initial image is scaled.

4. The defect detection method according to claim 2, characterized in that: The filtering process of the pre-processed image comprises: Performing a first filtering process on the preprocessed image based on a first preset standard deviation to obtain a first smoothed image; Performing a second filtering process on the preprocessed image based on a second preset standard deviation to obtain a second smoothed image; The difference between the corresponding pixel points of the first smoothed image and the second smoothed image is calculated, and the filtered image is obtained by performing a difference operation on each corresponding pixel point one by one.

5. The defect detection method according to claim 2, characterized in that: The normalizing process of the filtered image comprises: The grayscale value of each pixel in the filtered image is mapped to a preset grayscale screening range.

6. The defect detection method according to claim 1, characterized in that: The grayscale value of each pixel in the area to be detected is less than the first preset grayscale threshold.

7. A defect detection device, characterized in that: include: An image acquisition module, used to acquire an image of an object to be detected; A first image segmentation module, used to segment the image to be detected based on a first preset grayscale threshold to determine a region to be detected; An edge processing module, used to remove the edge portion of the to-be-detected area based on a preset edge range, and determine a target detection area inside the to-be-detected area, wherein the target detection area includes a plurality of to-be-processed areas; The defect analysis module is used to identify each of the to-be-processed areas from the target detection area, and obtain defect detection results corresponding to the to-be-detected object based on a target operation type and the multiple to-be-processed areas, wherein the target operation type includes a defect area ratio operation and a defect density operation.

8. A storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the defect detection method according to any one of claims 1 to 6 is implemented.

9. A computer device comprising a storage medium, a processor, and a computer program stored in the storage medium and executable on the processor, characterized in that: When the processor executes the computer program, the defect detection method according to any one of claims 1 to 6 is implemented.

10. A detection device, characterized in that: Comprising the defect detection device as described in claim 7.