Detection method and device, detection equipment and computer readable storage medium
By acquiring low-grayscale and high-grayscale images of lithium battery separators and combining them with preset thresholds and pixel correspondences, the detection difficulties caused by overexposure of white defects in lithium battery separators are solved, and accurate classification of tears, pinholes, bright spots and missing coatings is achieved.
Patent Information
- Application Number
- CN202211720681.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-30
- Publication Date
- 2025-11-28
- Estimated Expiration
- 2042-12-30
AI Technical Summary
In the process of coating lithium battery separators, defects such as tears, pinholes, bright spots and missing coatings are difficult to classify accurately. Existing imaging methods lead to overexposure of defects, which affects the detection accuracy.
By acquiring low-grayscale and high-grayscale images, and utilizing preset thresholds and pixel correspondences, defect areas can be accurately identified and classified.
It enables fine classification of white defects in lithium battery separators, improving the accuracy and reliability of detection.
Smart Images

Figure CN116228662B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of detection, and more particularly to a detection method, a detection device, a detection equipment and a computer readable storage medium. BACKGROUND
[0002] In the coating scene of lithium battery separators, white defects generally include tearing, pinholes, bright spots (or scratches) and missing coating, and the severity of these defects on the separator is different. Tearing and pinholes are very harmful to the separator, so it is necessary to classify white defects in detail. At present, when imaging white defects, the above defects may be overexposed, making it difficult to accurately classify white defects. SUMMARY
[0003] The present application provides a detection method, a detection device, a detection equipment and a computer readable storage medium.
[0004] The detection method of the present application embodiment includes obtaining a low gray image and a high gray image of the measured object, the gray value of all pixels of the low gray image is less than a preset gray value, and the pixels of the low gray image and the high gray image are one-to-one corresponding; detecting the high gray image to obtain a first defect area; determining a second defect area of the low gray image according to the first defect area; determining the defect type of each second defect area according to the gray value of the second defect area and the preset threshold value.
[0005] The detection device of the present application embodiment includes an acquisition module, a detection module, a first determination module and a second determination module. The acquisition module is used to obtain a low gray image and a high gray image of the measured object, the gray value of all pixels of the low gray image is less than a preset gray value, and the pixels of the low gray image and the high gray image are one-to-one corresponding; the detection module is used to detect the high gray image to obtain a first defect area; the first determination module is used to determine a second defect area of the low gray image according to the first defect area; the second determination module is used to determine the defect type of each second defect area according to the gray value of the second defect area and the preset threshold value.
[0006] The detection equipment of the present application embodiment includes a processor, which is used to obtain a low gray image and a high gray image of the measured object, the gray value of all pixels of the low gray image is less than a preset gray value, and the pixels of the low gray image and the high gray image are one-to-one corresponding; detecting the high gray image to obtain a first defect area; determining a second defect area of the low gray image according to the first defect area; determining the defect type of each second defect area according to the gray value of the second defect area and the preset threshold value.
[0007] The computer readable storage medium of the embodiments of the present application comprises a computer program which, when executed by a processor, causes the processor to execute the detection method. The detection method comprises obtaining a low gray scale image and a high gray scale image of a test piece, all pixels of the low gray scale image having a gray scale value less than a preset gray scale value, the pixels of the low gray scale image and the high gray scale image corresponding one by one; detecting the high gray scale image to obtain a first defect region; determining a second defect region of the low gray scale image according to the first defect region; and determining a defect type of each of the second defect regions according to a gray scale value of the second defect region and a preset threshold value.
[0008] The detection method, the detection device, the detection equipment and the computer readable storage medium of the embodiments of the present application can more accurately determine the first defect region in the high gray scale image by simultaneously obtaining the low gray scale image and the high gray scale image, and since the pixels of the low gray scale image and the high gray scale image correspond one by one (for example, using the same light source to irradiate the test piece at different light intensities, and using the same camera to capture the test piece to obtain the low gray scale image and the high gray scale image), the second defect region corresponding to the first defect region in the low gray scale image can be accurately determined according to the first defect region in the high gray scale image. At this time, since all pixels in the low gray scale image are not overexposed, and the gray scales of different defects are different under the condition of not overexposed, the second defect region can be classified according to the preset threshold value, so as to obtain the defect type of the second defect region.
[0009] Additional aspects and advantages of the embodiments of the present application will be in part apparent and in part pointed out hereinafter in the description of the embodiments of the present application. BRIEF DESCRIPTION OF DRAWINGS
[0010] The above and / or additional aspects and advantages of the present application will become apparent and be readily appreciated from the following description of the embodiments of the present application, taken in conjunction with the accompanying drawings.
[0011] Figure 1 is a flowchart of the detection method of some embodiments of the present application;
[0012] Figure 2 is a structural schematic diagram of the detection equipment of some embodiments of the present application;
[0013] Figure 3 is a flowchart of the detection method of some embodiments of the present application;
[0014] Figure 4 is a flowchart of the detection method of some embodiments of the present application;
[0015] Figure 5 is a flowchart of a detection method according to some embodiments of the present application;
[0016] Figure 6 is a flowchart of a detection method according to some embodiments of the present application;
[0017] Figure 7 is a flowchart of a detection method according to some embodiments of the present application;
[0018] Figure 8 is a flowchart of a detection method according to some embodiments of the present application;
[0019] Figure 9 is a block diagram of a detection device according to some embodiments of the present application;
[0020] Figure 10 is a connection state diagram of a non-volatile computer readable storage medium and a processor according to some embodiments of the present application. DETAILED DESCRIPTION
[0021] Embodiments of the present application are described in detail below with reference to the attached drawing figures, wherein the same or like designations indicate the same or like elements or features that are common throughout the figures and / or like functional elements. The embodiments described below are merely optional and are merely used to explain the embodiments of the present application and cannot be understood as limiting the embodiments of the present application.
[0022] Referring to Figure 1 and Figure 2 , the embodiments of the present application provide a detection method, comprising:
[0023] Step 011: obtaining a low gray image and a high gray image of the test piece 200, all pixels of the low gray image are not overexposed, and the pixels of the low gray image and the high gray image are one-to-one corresponding;
[0024] Specifically, when detecting defects of the test piece 200, the detection device 100 generally irradiates the test piece 200 (the test piece 200 can be a lithium battery separator) through the light source 20, then photographs the image of the test piece 200 through the camera 30, and controls the gray scale of the image of the test piece 200 by controlling the luminous intensity of the light source 20. In this way, the low gray image and the high gray image of the test piece 200 can be obtained, all pixels of the low gray image are not overexposed, and the defect area in the high gray image is generally overexposed. It can be understood that overexposure of the defect can make the characteristics of the defect more obvious, so as to accurately detect the area where the defect is located. Since the low gray image and the high gray image are obtained by the same camera 30 photographing the same test piece 200, the pixels of the two are one-to-one corresponding.
[0025] Step 012: detecting the high gray image to obtain a first defect region;
[0026] Specifically, after obtaining the high gray image, the first defect region in the high gray image can be detected, for example, the defect pixels in the high gray image can be detected by a predetermined threshold (e.g., the predetermined threshold is 255, that is, the overexposed pixels are defect pixels), and then the adjacent defect pixels are connected to obtain the first defect region. Compared with directly detecting the defect region in the low gray image, since the gray value in the low gray image is low, the characteristics of the defect are not as obvious as the non-defect pixels, and the detection accuracy of detecting the first defect region through the high gray image is obviously higher.
[0027] Of course, the predetermined threshold can also be 200, 220, 230, 240, etc., which can be determined according to the light emitting intensity of the light source 20 when obtaining the high gray image and the type of defects existing in the to-be-detected member 200.
[0028] Alternatively, the type of defect of the first defect region can be directly determined through the high gray image, for example, the predetermined threshold can be multiple, such as the predetermined threshold including a first predetermined threshold (e.g., 255) and a second predetermined threshold (e.g., 200), the first predetermined threshold is greater than the second predetermined threshold, when the average gray value of the first defect region is greater than the first predetermined threshold, it can be determined that the type of defect of the first defect region is a hole, in the case that the average gray value of the first defect region is less than or equal to the first predetermined threshold and greater than the second predetermined threshold, it can be determined that the type of defect of the first defect region is a bright spot / scratch, and when the average gray value of the first defect region is less than the second predetermined threshold, it can be determined that the type of defect of the first defect region is a missing coating.
[0029] The present application takes the detection of white defects as an example for illustration, and the white defects generally include four types of tearing, pinhole, bright spot (or scratch) and missing coating. Among them, tearing and pinhole are generally caused by the presence of sharp hard objects on the material film contact, which can be considered as the same type of defect hole. The bright spot or scratch refers to: (1) the base film extraction is not good, there are high transparent points, and the corresponding part is missing coating; (2) the film is scratched and the base film is damaged but not pierced or penetrated; (3) the foreign matter existing on the roller generally causes periodic bright spots and other reasons to cause white defects between pinholes and missing coating, which damage the base film; (4) the oil drops on the diaphragm form bright spot defects. The missing coating refers to the fact that the material film in some areas is not coated due to base film problems or the presence of foreign matter in the slurry or scraper problems in the coating process.
[0030] According to the reasons for the above defects, the size relationship of the gray values of different defects in the high gray image and the low gray image can be determined. Generally, the hole > the bright spot / scratch > the missed coating. Since the hole, the bright spot (or the scratch) and the missed coating can all be overexposed in the high gray image, the gray values of different defects can be the same due to overexposure in the high gray image, and different defects cannot be distinguished by the gray values, but only the first defect area can be detected by the predetermined threshold value.
[0031] Step 013: determining the second defect area of the low gray image according to the first defect area;
[0032] Specifically, after the first defect area in the high gray image is determined, the second defect area corresponding to the first defect area in the low gray image can be found according to the one-to-one correspondence between the high gray image and the low gray image. For example, the second defect area with the same image coordinates can be found in the low gray image according to the image coordinates of the first defect area. In this way, the first defect area is accurately detected by the high gray image, and then the second defect area corresponding to the first defect area in the low gray image is found according to the one-to-one correspondence between the high gray image and the low gray image, thereby ensuring the detection accuracy of the second defect area in the low gray image.
[0033] Step 014: determining the defect type of each second defect area according to the gray value of the second defect area and the preset threshold value.
[0034] Specifically, after the second defect area in the low gray image is determined, the defect type of the second defect area can be determined by comparing the gray value of the second defect area with the preset threshold value.
[0035] Taking the detection of white defects as an example, the preset threshold value can include a first preset threshold value and a second preset threshold value, both of which are empirical values. By comparing the size relationship between the average gray value of the second defect area and the first preset threshold value and the second preset threshold value, the defect type of the second defect area can be determined. For example, the average gray value of the hole is generally greater than the average gray value of the bright spot or the scratch, and the average gray value of the bright spot or the scratch is generally greater than the average gray value threshold of the missed coating. Therefore, in the case that the average gray value of the second defect area is greater than the first preset threshold value, the defect type of the second defect area can be determined as a hole defect, in the case that the average gray value of the second defect area is between the second preset threshold value and the first preset threshold value, the defect type of the second defect area can be determined as a bright spot or scratch defect, and in the case that the average gray value of the second defect area is less than the second preset threshold value, the defect type of the second defect area can be determined as a missed coating defect.
[0036] The detection method of the embodiments of the present application can more accurately determine the first defect region in the high gray scale image by detecting the high gray scale image since the defects in the high gray scale image are generally overexposed. Since the pixels of the low gray scale image and the high gray scale image are one-to-one corresponding (for example, the same light source 20 is used to irradiate the test piece 200 at different light intensities, and the same camera 30 is used to capture the test piece 200 to obtain the low gray scale image and the high gray scale image), the second defect region corresponding to the first defect region in the low gray scale image can be accurately determined according to the first defect region in the high gray scale image. At this time, since all the pixels in the low gray scale image are not overexposed, the gray scales of different defects are different under the condition of not overexposed. Therefore, the second defect region can be classified according to the preset threshold value, so as to obtain the defect type of the second defect region.
[0037] Referring to Figure 2 and Figure 3 In some embodiments, the defect type includes a hole defect, a bright spot or scratch defect, and a missing coating defect, the preset threshold value includes a first preset threshold value and a second preset threshold value, the first preset threshold value is greater than the second preset threshold value, and step 014: determining the defect type of each second defect region according to the gray scale value of the second defect region and the preset threshold value, includes:
[0038] Step 0141: determining the defect type of each second defect region according to the gray scale value of the second defect region, the area of the second defect region, and the preset threshold value.
[0039] Specifically, the area of the second defect region will affect the gray scale value of the second defect region. Therefore, when classifying defects, the area of the second defect region also needs to be considered, so as to more accurately determine the defect type of the second defect region.
[0040] For different area ranges of the second defect region, a preset threshold value corresponding to each area range needs to be set in advance. For example, for the second defect region with an area in a first area range (for example, greater than 64 pixels), the change of the gray scale value is basically not affected by the area. The same preset threshold value can be set for the second defect region in the first area range. Since the low gray scale image is not overexposed, the gray scale of different defects in the low gray scale image has a specific gray scale range. Therefore, the classification of different defects can be realized by the preset threshold value corresponding to the first area range.
[0041] For white defects, there are three different gray scale ranges, namely holes, bright spots / scratches and missing coating, and the gray scale value ranges of the three types of defects decrease in turn, such as the preset threshold value including a first preset threshold value and a second threshold value, the gray scale value range of the hole is greater than the first preset threshold value, the gray scale value range of the bright spot / scratch is [the second preset threshold value, the first preset threshold value], and the gray scale value range of the missing coating is less than the second preset threshold value.
[0042] If the area of the second defect region is located in the first area range and the average gray scale value of the second defect region is greater than the first preset threshold value, it is determined that the defect type of the second defect region is a hole defect; if the area of the second defect region is located in the first area range, the average gray scale value of the second defect region is less than the first preset threshold value and greater than the second preset threshold value, it is determined that the defect type of the second defect region is a bright spot or scratch defect; if the area of the second defect region is located in the first area range and the average gray scale value of the second defect region is less than the second preset threshold value, it is determined that the defect type of the second defect region is a missing coating defect.
[0043] Please refer to Figure 4 In some embodiments, step 0141: determining the defect type of each second defect region according to the gray scale value of the second defect region, the area of the second defect region and the preset threshold value, comprises:
[0044] Step 01411: obtaining a target area range matching the area of the second defect region, the target area range being any one of a plurality of second area ranges, and the maximum value of the second area range being less than the minimum value of the first area range;
[0045] Step 01412: obtaining a target preset threshold value matching the target area range, the target preset threshold value being one of a plurality of preset threshold values, the target preset threshold value including a first target preset threshold value and a second target preset threshold value, the first target preset threshold value being greater than the second target preset threshold value;
[0046] Step 01413: in the case where the difference between the average gray scale value of the second defect region and the preset background gray scale value is greater than the first target preset threshold value, determining that the defect type of the second defect region is a hole defect;
[0047] Step 01414: in the case where the difference between the average gray scale value of the second defect region and the background gray scale value is less than the first target preset threshold value and greater than the second target preset threshold value, determining that the defect type of the second defect region is a bright spot or scratch defect;
[0048] Step 01415: in the case where the difference between the average gray scale value of the second defect region and the background gray scale value is less than the second target preset threshold value, determining that the defect type of the second defect region is a missing coating defect.
[0049] Specifically, for the second defect area with a small area (e.g., less than 64 pixels), the area has a greater impact, and therefore, the area range less than 64 pixels needs to be divided into multiple groups. For each area range, considering the impact of the area on the gray value of the second defect area, a corresponding preset threshold needs to be set for each area range. The preset threshold is an empirical value, and the preset threshold includes a first preset threshold and a second preset threshold. As shown in the following table:
[0050]
[0051] wherein P1 to P9 are different first preset thresholds, and Q1 to Q9 are different second preset thresholds.
[0052] In the classification of the second defect area, first, the target area range in which the area of the second defect area is located is selected according to the area of the second defect area, so as to obtain the first preset threshold and the second preset threshold corresponding to the target area range, that is, to obtain the target area range matching the area of the second defect area. Then, the target preset threshold corresponding to the target area range is obtained. For example, if the area of the second defect area is 10, the target area range is (8, 12], the first target preset threshold corresponding to the target area range is P2, and the second target preset threshold is Q2.
[0053] At this time, the classification of the second defect area can be realized by the first target preset threshold P2 and the second target preset threshold Q2.
[0054] Since the area of the second defect area is small, the second defect area contains fewer pixels, which leads to a lower accuracy of the classification by judging the size relationship between the mean gray value of the second defect area and the preset threshold. Therefore, the classification of the second defect area can be realized by judging the relationship between the contrast (e.g., the difference between the mean gray value of the second defect area and the preset background gray value) of the mean gray value of the second defect area and the preset background gray value and the target preset threshold.
[0055] Optionally, the background gray value can be determined according to the mean pixel value of multiple frames of defect-free low gray images before the camera 30 acquires the current low gray image.
[0056] The classification process is as follows: in the case that the difference between the average gray value of the second defect area and the preset background gray value is greater than a first target preset threshold, the defect type of the second defect area is determined to be a hole defect; in the case that the difference between the average gray value of the second defect area and the background gray value is less than the first target preset threshold and greater than a second target preset threshold, the defect type of the second defect area is determined to be a bright spot or scratch defect; and in the case that the difference between the average gray value of the second defect area and the background gray value is less than the second target preset threshold, the defect type of the second defect area is determined to be a missing coating defect.
[0057] Optionally, the difference between the average gray value of the second defect area and the preset background gray value can be calculated by the difference between the average gray value of all pixels in the second defect area and the preset background gray value.
[0058] Optionally, the difference between the average gray value of the second defect area and the preset background gray value can be obtained by the difference between the average gray value of a target pixel in the second defect area and the preset background gray value, wherein the target pixel is a pixel in the second defect area whose gray value is in a preset ranking, and the preset ranking is determined according to the target area range. For example, first, the pixels in the second defect area are sorted according to the gray value from large to small, and then the preset ranking is determined according to the target area range corresponding to the second defect area, such as the target area range being located in (0, 8], the preset ranking being 1, i.e., the target pixel being the pixel with the largest gray value in the second defect area, such as the target area range being located in (8, 16], the preset ranking being [1, 2], i.e., the target pixel including the two pixels with the first and second largest gray values in the second defect area, such as the target area range being located in (16, 36], the preset ranking being [1, 3], i.e., the target pixel including the three pixels with the first, second and third largest gray values in the second defect area, such as the target area range being located in (36, 64], the preset ranking being [1, 4], i.e., the target pixel including the four pixels with the first, second, third and fourth largest gray values in the second defect area.
[0059] Please refer to Figure 5 In some embodiments, step 014: determining the defect type of each second defect area according to the gray value of the second defect area and the preset threshold, comprises:
[0060] Step 0142: determining the defect type of each second defect area according to the gray value of the second defect area, the area of the second defect area, the effective width of the second defect area and the preset threshold.
[0061] Specifically, in addition to considering the influence of the area of the second defect region on the gray value of the second defect region, the influence of the effective width of the second defect region on the gray value of the second defect region is also considered, wherein the effective width of the second defect region is the smaller one of the maximum row width and the maximum column width of the second defect region, the row width of each row of the second defect region in the low gray image is obtained to obtain the maximum row width, and then the row width of each column of the second defect region in the low gray image is obtained to obtain the maximum column width, and the smaller one of the maximum row width and the maximum column width is taken as the effective width of the second defect region.
[0062] It can be understood that the smaller the effective width of the second defect region is, the lower the overall gray value of the second defect region is, and vice versa, so the preset threshold is different for different effective widths. For the second defect region with a larger effective width (such as the effective width being in the first width range) and a larger area (such as the area being in the first area range), the gray value is less affected by the effective width, and only the preset threshold corresponding to the first width range needs to be set.
[0063] Therefore, in the case that the area of the second defect region is in the first area range (such as the first area range being greater than 64 pixels), the effective width of the second defect region is in the first width range (such as the first width range being greater than 6 pixels), and the average gray value of the second defect region is greater than the first preset threshold, the defect type of the second defect region is determined to be a hole defect, and the effective width of the second defect region is the smaller one of the maximum row width and the maximum column width of the second defect region; in the case that the area of the second defect region is in the first area range, the effective width of the second defect region is in the first width range, the average gray value of the second defect region is less than the first preset threshold and greater than the second preset threshold, the defect type of the second defect region is determined to be a bright spot or a scratch defect; in the case that the area of the second defect region is in the first area range, the effective width of the second defect region is in the first width range, and the average gray value of the second defect region is less than the second preset threshold, the defect type of the second defect region is determined to be a missing coating defect.
[0064] Please refer to Figure 6 In some embodiments, the step 0142 of determining the defect type of each second defect region according to the gray value of the second defect region, the area of the second defect region, the effective width of the second defect region and the preset threshold comprises:
[0065] Step 01421: Obtain a target area range matching the area of the second defect region, and a target width range matching the effective width of the second defect region, the target area range being any one of a plurality of second area ranges, the target width range being any one of a plurality of second width ranges, a maximum value of the second area range being less than a minimum value of the second area range, a maximum value of the second width range being less than a minimum value of the first width range;
[0066] Step 01422: Obtain a target preset threshold matching both the target area range and the target width range, the target preset threshold being one of a plurality of preset thresholds, the target preset threshold including a first target preset threshold and a second target preset threshold, the first target preset threshold being greater than the second target preset threshold;
[0067] Step 01423: In a case where a difference between the average gray value of the second defect region and the preset background gray value is greater than the first target preset threshold, determine that the defect type of the second defect region is a hole defect;
[0068] Step 01424: In a case where the difference between the average gray value of the second defect region and the background gray value is less than the first target preset threshold and greater than the second target preset threshold, determine that the defect type of the second defect region is a bright spot or a scratch defect;
[0069] Step 01425: In a case where the difference between the average gray value of the second defect region and the background gray value is less than the second target preset threshold, determine that the defect type of the second defect region is a missing coating defect.
[0070] Specifically, for a second defect region with a small area and a small effective width (such as a second defect region with an area in the second area range and an effective width in the second width range), considering that both the area and the effective width of the second defect region will affect the gray value of the second defect region, a mapping relationship between the area and the effective width of the second defect region and the preset threshold can be established, that is, after the area and the effective width of the second defect region are determined, the corresponding preset threshold of the second defect region can be determined.
[0071] When classifying the second defect region, first, the target area range in which the area of the second defect region is located is selected according to the area of the second defect region, then the target width range in which the effective width of the second defect region is located is selected according to the effective width of the second defect region, and finally the target preset threshold matching both the target area range and the target width range can be found from the plurality of preset thresholds according to the target area range and the target width range.
[0072] At this time, the classification of the second defect region can be realized through the pixel value of the second defect region and the target preset threshold.
[0073] Since the area and effective width of the second defect region are small, the second defect region contains less pixels, which leads to low accuracy of the classification by judging the size relationship between the average gray value of the second defect region and the preset threshold value. Therefore, the classification of the second defect region can be realized by the pixel value of the second defect region, the preset background gray value and the target preset threshold value.
[0074] The classification process is as follows: in the case that the difference between the average gray value of the second defect region and the preset background gray value is greater than the first target preset threshold value, it is determined that the defect type of the second defect region is a hole defect; in the case that the difference between the average gray value of the second defect region and the background gray value is less than the first target preset threshold value and greater than the second target preset threshold value, it is determined that the defect type of the second defect region is a bright spot or scratch defect; in the case that the difference between the average gray value of the second defect region and the background gray value is less than the second target preset threshold value, it is determined that the defect type of the second defect region is a missing coating defect.
[0075] Referring to Figure 7 In some embodiments, before determining the defect type of the second defect region, the detection method further comprises:
[0076] Step 015: in the case that the area of the second defect region is in a third area range or the effective width of the second defect region is in a third width range, the gray value of the second defect region is normalized to a first preset range, and the background gray value is normalized to a second preset range, the third area range includes a plurality of second area ranges, the maximum value of the third width range is less than the minimum value of the first width range, and the first preset range and the second preset range are different.
[0077] Specifically, in the case that the area of the second defect region is small or the effective width is small (such as the area of the second defect region is in the second area range or the effective width of the second defect region is in the second width range), the accuracy of the average gray value of the second defect region will decrease, therefore, the gray value of the second defect region can be normalized to a first preset range (such as normalized to [0, 10]), and then the background gray value is normalized to a second preset range (such as [0, 25]), so as to reduce the influence of the area and effective width of the second defect region on the classification of the second defect region, and ensure the classification accuracy of the second defect region.
[0078] It can be understood that the preset threshold value at this time corresponds to the normalized gray value of the second defect region and the background gray value, which ensures the accuracy of the preset threshold value.
[0079] Referring to Figure 8 In some embodiments, the detection method further comprises:
[0080] Step 016: determining a compensation coefficient according to the position of the second defect region in the low gray image;
[0081] Step 017: adjusting the target preset threshold according to the compensation coefficient.
[0082] Specifically, due to the existence of distortion of the lens of the camera 30, according to the modulation transfer function (MTF) principle of the lens, the contrast (i.e. the difference between the mean gray value of the white defect and the background gray value) of the white defect of the same area at different positions will also have certain differences, therefore, the preset threshold can be adjusted according to the contrast at each position, so as to solve the problem of inaccurate preset threshold caused by lens distortion.
[0083] Among them, for the second defect region with larger effective width or area (such as the effective width located in the first width range and the area located in the first area range), since the number of pixels is large, it is basically not affected by distortion, and for the second defect region with smaller effective width and area (such as the effective width located in the second width range and the area located in the second area range), since the number of pixels is small, it is greatly affected by distortion, therefore, generally only the preset threshold corresponding to the second defect region with smaller effective width and area is adjusted. Of course, without considering the effective width and area of the second defect region, for all second defect regions, the compensation coefficient is determined according to the position of the second defect region in the low gray image, so as to adjust the preset threshold corresponding to the second defect region according to the compensation coefficient.
[0084] For the lens, generally the contrast of the central position is high and the contrast of the edge position is low, the contrast of different positions of the lens can be calibrated in advance. The gray value of the second defect region at the position with higher contrast is larger, and the preset threshold corresponding to the position is also larger, therefore, after determining the target preset threshold of the second defect region, the compensation coefficient can be determined according to the position of the second defect region in the low gray image, such as the compensation coefficient is located between [0, 1], the position of the second defect region is closer to the central region of the low gray image, and the compensation coefficient is closer to 1. After determining the compensation coefficient, the target preset threshold can be adjusted according to the compensation coefficient, such as multiplying the target preset threshold by the compensation coefficient to obtain the adjusted target preset threshold.
[0085] Subsequently, when classifying the second defect region, the classification can be performed according to the adjusted target preset threshold, so as to further improve the classification accuracy of the second defect region.
[0086] Please refer to Figure 9To facilitate better implementation of the detection method of the embodiments of the present application, the embodiments of the present application further provide a detection device 10. The detection device 10 can include an acquisition module 11, a detection module 12, a first determination module 13 and a second determination module 14. The acquisition module 11 is configured to acquire a low gray image and a high gray image of the workpiece 200, all pixels of the low gray image have a gray value less than a preset gray value, and the pixels of the low gray image and the high gray image are one-to-one corresponding; the detection module 12 is configured to detect the high gray image to obtain a first defect region; the first determination module 13 is configured to determine a second defect region of the low gray image according to the first defect region; and the second determination module 14 is configured to determine a defect type of each second defect region according to a gray value of the second defect region and a preset threshold value.
[0087] The detection module 12 is specifically configured to detect pixels greater than a predetermined threshold value in the high gray image as defect pixels, and obtain the first defect region according to the defect pixels.
[0088] The second determination module 14 is specifically configured to determine the defect type of each second defect region according to the gray value of the second defect region, an area of the second defect region and the preset threshold value.
[0089] The second determination module 14 is specifically further configured to determine that the defect type of the second defect region is a hole defect when the area of the second defect region is located in a first area range and the average of the gray values of the second defect region is greater than a first preset threshold value; determine that the defect type of the second defect region is a bright spot or scratch defect when the area of the second defect region is located in the first area range, the average of the gray values of the second defect region is less than the first preset threshold value and greater than a second preset threshold value; and determine that the defect type of the second defect region is a missing coating defect when the area of the second defect region is located in the first area range and the average of the gray values of the second defect region is less than the second preset threshold value.
[0090] The second determining module 14 is specifically further configured to acquire a target area range matching an area of the second defect region, the target area range being any one of a plurality of second area ranges, a maximum value of the second area range being less than a minimum value of the first area range; acquire a target preset threshold value matching the target area range, the target preset threshold value being one of a plurality of preset threshold values, the target preset threshold value including a first target preset threshold value and a second target preset threshold value, the first target preset threshold value being greater than the second target preset threshold value; in a case where a difference between the average gray value of the second defect region and the preset background gray value is greater than the first target preset threshold value, determine that a defect type of the second defect region is a hole defect; in a case where the difference between the average gray value of the second defect region and the background gray value is less than the first target preset threshold value and greater than the second target preset threshold value, determine that the defect type of the second defect region is a bright spot or scratch defect; and in a case where the difference between the average gray value of the second defect region and the background gray value is less than the second target preset threshold value, determine that the defect type of the second defect region is a missing coating defect.
[0091] The second determining module 14 is specifically further configured to determine the defect type of each second defect region according to the gray value of the second defect region, the area of the second defect region, the effective width of the second defect region, and the preset threshold value.
[0092] The second determining module 14 is specifically further configured to, in a case where the area of the second defect region is located in the first area range, the effective width of the second defect region is located in the first width range, and the average gray value of the second defect region is greater than the first preset threshold value, determine that the defect type of the second defect region is a hole defect, the effective width of the second defect region being a smaller one of a maximum row width and a maximum column width of the second defect region; in a case where the area of the second defect region is located in the first area range, the effective width of the second defect region is located in the first width range, the average gray value of the second defect region is less than the first preset threshold value and greater than the second preset threshold value, determine that the defect type of the second defect region is a bright spot or scratch defect; and in a case where the area of the second defect region is located in the first area range, the effective width of the second defect region is located in the first width range, and the average gray value of the second defect region is less than the second preset threshold value, determine that the defect type of the second defect region is a missing coating defect.
[0093] The second determining module 14 is specifically further configured to: acquire a target area range matched with the area of the second defect region, and a target width range matched with the effective width of the second defect region, the target area range being any one of a plurality of second area ranges, the target width range being any one of a plurality of second width ranges, a maximum value of the second area range being smaller than a minimum value of the second area range, a maximum value of the second width range being smaller than a minimum value of the first width range; acquire a target preset threshold matched with the target area range and the target width range, the target preset threshold being one of a plurality of preset thresholds, the target preset threshold including a first target preset threshold and a second target preset threshold, the first target preset threshold being greater than the second target preset threshold; in a case where a difference between the average gray value of the second defect region and the preset background gray value is greater than the first target preset threshold, determining that the defect type of the second defect region is a hole defect; in a case where the difference between the average gray value of the second defect region and the background gray value is smaller than the first target preset threshold and greater than the second target preset threshold, determining that the defect type of the second defect region is a bright spot or a scratch defect; in a case where the difference between the average gray value of the second defect region and the background gray value is smaller than the second target preset threshold, determining that the defect type of the second defect region is a missing coating defect.
[0094] The detection device 10 further includes a normalization module 15 configured to normalize the gray value of the second defect region to a first preset range and normalize the background gray value to a second preset range in a case where the area of the second defect region is located in a third area range or the effective width of the second defect region is located in a third width range, the third area range including a plurality of second area ranges, a maximum value of the third width range being smaller than a minimum value of the first width range.
[0095] The detection device 10 further includes a third determining module 16 and an adjustment module 17, the third determining module 16 being configured to determine a compensation coefficient according to the position of the second defect region in the low-gray image, and the adjustment module 17 being configured to adjust the target preset threshold according to the compensation coefficient.
[0096] Referring to Figure 10 The detection device 100 of the embodiment of the present application includes a processor 40. The processor 40 is configured to acquire a low-gray image and a high-gray image of a test piece 200, all pixels of the low-gray image being underexposed, the pixels of the low-gray image and the high-gray image corresponding one by one; detect the high-gray image to acquire a first defect region; determine a second defect region of the low-gray image according to the first defect region; and determine a defect type of each second defect region according to the gray value of the second defect region and a preset threshold.
[0097] The detection device 100 further includes a light source 20 and a camera 30, the light source 20 being configured to irradiate the test piece 200, and the camera 30 being configured to shoot the high-gray image and the low-gray image of the test piece 200.
[0098] Optionally, the processor 40 can also execute the detection method of any of the above-mentioned embodiments, which will not be described herein again for the sake of brevity.
[0099] Please refer to Figure 9 The embodiments of the present application also provide a computer readable storage medium 300, which stores a computer program 310. When the computer program 310 is executed by the processor 40, the steps of the detection method of any of the above-mentioned embodiments are implemented, which will not be described herein again for the sake of brevity.
[0100] In the description of the present specification, the description referring to the terms "certain embodiments", "in one example", "exemplarily" and the like means that the specific features, structures, materials or characteristics described in connection with the embodiments or examples are included in at least one embodiment or example of the present application. In the present specification, the illustrative description of the above-mentioned terms does not necessarily mean the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described can be combined in any one or more embodiments or examples in a suitable manner. In addition, the person skilled in the art can combine and combine the different embodiments or examples described in the present specification and the features of the different embodiments or examples without contradiction.
[0101] Any process or method descriptions in flow charts or described herein in other ways can be understood as representing code modules, segments, or portions of code that include one or more executable instructions for performing specific logic functions or steps in the process. The various embodiments of the application can include additional or fewer steps or processes, and the order of the steps or processes can be changed, including according to the function involved, without departing from the scope of the application.
[0102] Although the embodiments of the present application have been shown and described above, it can be understood that the above-mentioned embodiments are optional and cannot be understood as a limitation of the present application, and the person skilled in the art can make changes, modifications, replacements and variations to the above-mentioned embodiments within the scope of the present application.
Claims
1. A method of detection, characterized in that, The method comprises the following steps: obtaining a low gray image and a high gray image of a test object, all pixels of the low gray image are not overexposed, and the pixels of the low gray image and the high gray image are one-to-one corresponding; detecting the high gray image to obtain a first defect area; determining a second defect area of the low gray image according to the first defect area; determining a defect type of each second defect area according to a gray value of the second defect area, an area of the second defect area and a preset threshold value, comprising: in the case that the area of the second defect area is in a first area range and the average gray value of the second defect area is greater than a first preset threshold value, determining that the defect type of the second defect area is a hole defect; in the case that the area of the second defect area is in the first area range, the average gray value of the second defect area is less than the first preset threshold value and greater than a second preset threshold value, determining that the defect type of the second defect area is a bright spot or scratch defect; in the case that the area of the second defect area is in the first area range and the average gray value of the second defect area is less than the second preset threshold value, determining that the defect type of the second defect area is a missing coating defect.
2. The detection method according to claim 1, characterized in that, The detection of the high gray image to obtain a first defect area comprises: detecting pixels greater than a predetermined threshold value in the high gray image as defect pixels; obtaining the first defect area according to the defect pixels.
3. The method of claim 1, wherein The defect type comprises a hole defect, a bright spot or scratch defect and a missing coating defect, and the determination of the defect type of each second defect area according to the gray value of the second defect area, the area of the second defect area and the preset threshold value comprises: obtaining a target area range matching the area of the second defect area, the target area range being any one of a plurality of second area ranges, and the maximum value of the second area range being less than the minimum value of the first area range; obtaining a target preset threshold value matching the target area range, the target preset threshold value being one of a plurality of preset threshold values, the target preset threshold value comprising a first target preset threshold value and a second target preset threshold value, and the first target preset threshold value being greater than the second target preset threshold value; in the case that the difference between the average gray value of the second defect area and a preset background gray value is greater than the first target preset threshold value, determining that the defect type of the second defect area is a hole defect; in the case that the difference between the average gray value of the second defect area and the background gray value is less than the first target preset threshold value and greater than the second target preset threshold value, determining that the defect type of the second defect area is a bright spot or scratch defect; in the case that the difference between the average gray value of the second defect area and the background gray value is less than the second target preset threshold value, determining that the defect type of the second defect area is a missing coating defect.
4. The detection method according to claim 3, characterized in that, The difference between the average gray value of the second defect region and the preset background gray value is determined according to the difference between the average gray value of a target pixel in the second defect region and the preset background gray value, the target pixel being a pixel in the second defect region whose gray value is within a preset ranking, and the preset ranking being determined according to the target area range.
5. The method of claim 1, wherein, The defect type of each second defect region is determined according to the gray value of the second defect region, the area of the second defect region, and the preset threshold value, including: The defect type of each second defect region is determined according to the gray value of the second defect region, the area of the second defect region, the effective width of the second defect region, and the preset threshold value.
6. The detection method according to claim 5, characterized in that, The defect type of each second defect region is determined according to the gray value of the second defect region, the area of the second defect region, the effective width of the second defect region, and the preset threshold value. In a case where the area of the second defect region is within a first area range, the effective width of the second defect region is within a first width range, and the average gray value of the second defect region is greater than a first preset threshold value, the defect type of the second defect region is determined as a hole defect, the effective width of the second defect region being the smaller one of the maximum row width and the maximum column width of the second defect region; In a case where the area of the second defect region is within the first area range, the effective width of the second defect region is within the first width range, the average gray value of the second defect region is less than the first preset threshold value and greater than a second preset threshold value, the defect type of the second defect region is determined as a bright spot or scratch defect; In a case where the area of the second defect region is within the first area range, the effective width of the second defect region is within the first width range, and the average gray value of the second defect region is less than the second preset threshold value, the defect type of the second defect region is determined as a missing coating defect.
7. The detection method according to claim 6, characterized in that, The defect type of each second defect region is determined according to the gray value of the second defect region, the area of the second defect region, the effective width of the second defect region, and the preset threshold value, including: A target area range matching the area of the second defect region and a target width range matching the effective width of the second defect region are obtained, the target area range being any one of a plurality of second area ranges, the target width range being any one of a plurality of second width ranges, the maximum value of the second area range being less than the minimum value of the first area range, and the maximum value of the second width range being less than the minimum value of the first width range; A target preset threshold value matching both the target area range and the target width range is obtained, the target preset threshold value being one of a plurality of preset threshold values, the target preset threshold value including a first target preset threshold value and a second target preset threshold value, the first target preset threshold value being greater than the second target preset threshold value; in a case where a difference between the average value of the gray value of the second defect region and the preset background gray value is greater than the first target preset threshold value, determining that a defect type of the second defect region is a hole defect; in a case where the difference between the average value of the gray value of the second defect region and the background gray value is less than the first target preset threshold value and greater than the second target preset threshold value, determining that the defect type of the second defect region is a bright spot or scratch defect; in a case where the difference between the average value of the gray value of the second defect region and the background gray value is less than the second target preset threshold value, determining that the defect type of the second defect region is a missing coating defect.
8. The detection method according to claim 7, characterized in that, Before determining the defect type of the second defect region, the detection method further comprises: in a case where an area of the second defect region is located in a third area range or an effective width of the second defect region is located in a third width range, normalizing the gray value of the second defect region to a first preset range and normalizing the background gray value to a second preset range, the third area range comprising a plurality of the second area ranges, and a maximum value of the third width range being less than a minimum value of the first width range.
9. The detection method according to claim 4 or 8, characterized in that, Further comprising: determining a compensation coefficient according to a position of the second defect region in the low gray value image; adjusting the target preset threshold value according to the compensation coefficient.
10. A detection device for carrying out the detection method according to any one of claims 1 to 9, characterized in that comprising: an acquisition module, configured to acquire a low gray value image and a high gray value image of a test piece, all pixels of the low gray value image having a gray value less than a preset gray value, the pixels of the low gray value image and the high gray value image corresponding to each other one by one; a detection module, configured to detect the high gray value image to acquire a first defect region; a first determination module, configured to determine a second defect region of the low gray value image according to the first defect region; a second determination module, configured to determine a defect type of each of the second defect regions according to a gray value of the second defect region and a preset threshold value.
11. A detection device for carrying out the detection method according to any one of claims 1 to 9, characterized in that comprising a processor, configured to acquire a low gray value image and a high gray value image of a test piece, all pixels of the low gray value image being underexposed, the pixels of the low gray value image and the high gray value image corresponding to each other one by one; detecting the high gray value image to acquire a first defect region; determining a second defect region of the low gray value image according to the first defect region; determining a defect type of each of the second defect regions according to a gray value of the second defect region and a preset threshold value.
12. A nonvolatile computer readable storage medium containing a computer program, the computer program being executed by a processor to cause the processor to perform the detection method of any one of claims 1-9.
Citation Information
Patent Citations
Object defect category identification method and device, computer equipment and storage medium
CN112241699A
Defect detection method and related device
CN113902697A