Plate brush lug quality detection method and system based on image recognition
By calculating and optimizing the high threshold and low threshold in the canny algorithm, the problem of low accuracy in extracting edge lines in the surface defect area of the polar ear is solved, achieving higher edge information retention and detection accuracy.
Patent Information
- Application Number
- CN202510156726.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-13
- Publication Date
- 2025-04-11
- Estimated Expiration
- 2045-02-13
AI Technical Summary
In the prior art, when extracting edge lines of the surface defect area of the polar ear using the canny algorithm, artificially setting high thresholds leads to low accuracy of the detection result.
By calculating the high threshold and low threshold, the high threshold and low threshold are optimized using objective functions and genetic algorithms to improve the accuracy of retention and extraction of edge information.
It improves the accuracy of high thresholds, reduces the loss of edge information, and enhances the accuracy of extracting edge lines, thereby improving the accuracy of the quality detection of the pole brush ears.
Smart Images

Figure CN119648693B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of electronic digital data processing, and in particular to a method and system for detecting the quality of a plate brush lug based on image recognition. Background Art
[0002] The plate is an important component of the battery and plays an important role in the performance of the battery. During the production and cutting of the plate, burrs, scratches and oxide layers will appear on the plate. In order to improve the welding quality, the plate needs to be brushed before welding to remove impurities and expose the metal lead for subsequent welding and other processes. In order to improve product quality and reduce the defective rate, the plate brushing ears need to be tested for quality before the welding process.
[0003] A Chinese patent document with announcement number CN106504246B discloses an image processing method for tunnel crack detection, comprising the following steps: reading in an original tunnel image and converting it into a double type; preprocessing the image, performing two parallel operations of canny operator detection and threshold segmentation after Gaussian filtering: after canny operator detection, parallel areas of approximately equal length and areas contained in horizontal and vertical straight lines in the image are removed; after threshold segmentation, a series of processes such as dilation operation, small area removal, hole filling and wider area removal are performed, and the results are combined with the canny edge detection results to obtain the effective area.
[0004] When detecting defects on the surface of the tab, because there is a significant difference in the material composition of the surface defective part and the surrounding normal tabs, the defect edge in the image is reflected as a sudden change in pixel value. Therefore, the Canny algorithm can be used to extract the defective area on the surface of the tab. However, when using the Canny operator to detect the edge of the defective part, since the Canny operator artificially sets a high threshold to determine the edge line, setting the high threshold too high will cause some edge information to be lost, and setting the high threshold too low will cause inaccurate contours. Summary of the invention
[0005] The present invention proposes a plate brush ear quality detection method and system based on image recognition, so as to solve the problem in the prior art that when using the Canny algorithm to extract the edge line of the defective area, a high threshold is artificially set, resulting in low accuracy of the detection result; to this end, the present invention provides solutions in the following two aspects.
[0006] In the first aspect, the present invention provides a method for detecting the quality of a plate brush lug based on image recognition, comprising the following steps:
[0007] Obtain the grayscale image of the plate brush ear, calculate the high threshold in the Canny algorithm, and use the Canny algorithm to extract the edge line of the defective part in the grayscale image;
[0008] The grayscale image is input into the neural network to perform quality inspection on the defective parts surrounded by the edge lines;
[0009] The calculation method of the high threshold is:
[0010] Calculate the gradient value and gradient direction of the pixel points in the grayscale image, and standardize the gradient direction to obtain the standard gradient direction;
[0011] Set a first parameter, and take pixel points whose gradient values are greater than the first parameter as strong boundary points;
[0012] In the neighborhood of any strong boundary point, if there is no strong boundary point along the standard gradient direction, it indicates that the strong boundary point is unique; if there is a strong boundary point along the normal direction of the standard gradient direction, and the standard gradient directions of the two strong boundary points are the same, it indicates that the boundary point is continuous;
[0013] The strong boundary points with uniqueness and continuity are regarded as effective strong boundary points;
[0014] Construct the objective function with a high threshold: , The coordinates are The effective strong boundary point of Indicates the number of effective strong boundary points;
[0015] Calculate the optimal solution of the first parameter when the objective function is at its maximum value, and use the optimal solution as the high threshold.
[0016] The effect is that by setting the objective function and solving the objective function to obtain a high threshold, the accuracy of the high threshold is improved, so that the edge lines of defective parts in the grayscale image can be accurately extracted to facilitate the detection of the quality of the plate brush ears, thereby further improving the accuracy of detecting the quality of the plate brush ears.
[0017] Preferably, the method for normalizing the gradient direction to obtain the standard gradient direction is:
[0018] Map the gradient direction of the pixel point to polar coordinates, construct multiple rays with the origin of the polar coordinate system as the center, and the angles between two adjacent rays are the same;
[0019] Calculate the angle between the gradient direction and each ray, and take the ray direction with the smallest angle as the gradient direction of the corresponding pixel.
[0020] The effect is that the gradient direction of the pixel points is standardized, which makes it easier to select effective strong boundary points and improves the accuracy of the obtained sub-edge lines.
[0021] Preferably, the detection method further comprises:
[0022] Connect the effective strong boundary points to obtain multiple sub-edge lines, and use the connecting line to connect two adjacent sub-edge lines;
[0023] Set a second parameter, take the pixel points whose gradient value is greater than the second parameter and less than the first parameter as weak boundary points, calculate the Euclidean distance between the weak boundary point and the connecting line, and when the Euclidean distance is greater than a preset distance threshold, the corresponding weak boundary point is an invalid weak boundary point; otherwise, it is a valid weak boundary point;
[0024] Construct the objective function with a low threshold: ; represents the total number of weak boundary points, Indicates the number of invalid weak boundary points;
[0025] The genetic algorithm is used to calculate the optimal solution of the second parameter when the low threshold objective function takes the minimum value, and the optimal solution is used as the low threshold in the canny algorithm.
[0026] The effect is that by setting the objective function and solving the objective function to obtain a low threshold, the accuracy of the low threshold is improved, the accuracy of the fitting connection line is improved, and a better edge line of the defect area can be obtained.
[0027] Preferably, connecting two adjacent sub-edge lines using a connecting line includes:
[0028] The matching degree between two adjacent sub-edge lines is calculated, and when the matching degree between the two sub-edge lines is greater than a preset matching degree threshold, the sub-edge lines are connected using a connecting line.
[0029] Preferably, the expression of matching degree is: ;
[0030] in, Sub-edge line and sub-margin line The matching degree between Sub-edge line Endpoints and subedges The Euclidean distance between endpoints, Sub-edge line The mean gray value of the pixels in Sub-edge line The mean gray value of the pixels in the image.
[0031] The effect is that by calculating the matching degree between two sub-edge lines, it is determined whether the two sub-edge lines belong to the edge line of the same defective part, thereby improving the accuracy of extracting the edge line of the defective part.
[0032] Preferably, after connecting two adjacent sub-edge lines with a connecting line, the method further includes:
[0033] The weights of the effective weak boundary points are calculated, and the connecting lines are updated according to the weights of the effective weak boundary points to obtain the optimal connecting lines.
[0034] The effect is that by calculating the weights of the boundary points, the connecting lines obtained by the preliminary fitting are updated according to the weights to obtain the optimal connecting lines.
[0035] Preferably, a genetic algorithm is used to calculate the optimal solution of the first parameter when the objective function is at a maximum value.
[0036] Secondly, the plate brush ear quality detection system based on image recognition includes:
[0037] processor;
[0038] A memory stores computer instructions for detecting the quality of the plate brush ears based on image recognition. When the computer instructions are executed by the processor, the system executes the method for detecting the quality of the plate brush ears based on image recognition.
[0039] The beneficial effects of the present invention are:
[0040] 1. The solution of the present invention obtains a high threshold value through calculation, thereby improving the accuracy of the high threshold value, retaining edge information to the greatest extent, reducing the phenomenon of edge information loss, improving the accuracy of edge line extraction, and further improving the accuracy of plate brush ear quality detection.
[0041] 2. The scheme of the present invention obtains the low threshold by calculation, thereby improving the accuracy of the low threshold, facilitating the search for effective weak boundary points, and further improving the accuracy of the connecting line obtained by fitting between the sub-edge lines, facilitating the detection of the quality of the plate brush ears. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] By reading the following detailed description with reference to the accompanying drawings, the above and other objects, features and advantages of the exemplary embodiments of the present invention will become readily understood. In the accompanying drawings, several embodiments of the present invention are shown in an exemplary and non-limiting manner, and the same or corresponding reference numerals represent the same or corresponding parts, wherein:
[0043] Figure 1 The flowchart of the step of the plate brush lug quality detection method based on image recognition in this embodiment is schematically shown;
[0044] Figure 2 The structural block diagram of the plate brush lug quality detection system based on image recognition in this embodiment is schematically shown. DETAILED DESCRIPTION
[0045] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0046] Specifically, Figure 1 As shown, the plate brush lug quality detection method based on image recognition in this embodiment includes the following steps:
[0047] S1. Obtain a grayscale image of the plate brush ear, and calculate the gradient value and gradient direction of the pixel points in the grayscale image.
[0048] The image of the plate brush lug is obtained, and the image is grayed by weighted graying method to obtain the gray image of the lug surface, and the gray image is smoothed by Gaussian filter to remove noise. The gradient value of each pixel in the smoothed gray image is calculated by Sobel operator to obtain the gradient value and gradient direction of each pixel in the gray image.
[0049] S2. Normalize the gradient direction to obtain the standard gradient direction.
[0050] The gradient direction of the pixel point is mapped to polar coordinates, and multiple rays are constructed with the origin of the polar coordinate system as the center. The angle between two adjacent rays is the same; the angle between the gradient direction and each ray is calculated, and the ray direction with the smallest angle is taken as the gradient direction of the corresponding pixel point.
[0051] For example, eight rays are constructed with the origin of the polar coordinate system as the center, and the angles of the rays are , , ,0, , , , , map the gradient direction of the pixel point to the polar coordinate system, calculate the angle between the gradient direction and the ray, and take the ray direction with the smallest angle as the gradient direction of the corresponding pixel point. For example, the gradient direction of one pixel point is , whose gradient direction and angle are The ray angle is the smallest, so the standard gradient direction of the pixel is recorded as .
[0052] S3. Calculate the high threshold in the canny algorithm.
[0053] S31. Set a first parameter, and take pixel points whose gradient values are greater than the first parameter as strong boundary points. In the eight neighborhoods of any strong boundary point, if there is no strong boundary point along the standard gradient direction, it indicates that the strong boundary point is unique. If there is a strong boundary point along the normal direction of the standard gradient direction, and the standard gradient directions of the two strong boundary points are the same, it indicates that the boundary point is continuous. The strong boundary point with uniqueness and continuity is taken as a valid strong boundary point.
[0054] When extracting the edge line of the defective part, the edge line is composed of strong boundary points. Therefore, the ideal edge line should be unique. In other words, there should be no other lines composed of strong boundary points inside or outside the ideal edge line. In addition, since the edge line is composed of multiple adjacent strong boundary points, the adjacent strong boundary points should have the same standard gradient direction, and one pixel point should be located in the normal direction of the gradient direction of another adjacent pixel point. By judging the continuity and uniqueness of the pixel points, the effective strong boundary points are screened out.
[0055] S32. Construct a high threshold objective function: , The coordinates are The effective strong boundary point of Indicates the number of effective strong boundary points; uses genetic algorithm or particle swarm algorithm to calculate the optimal solution of the first parameter when the objective function is the maximum value, and uses the optimal solution as the high threshold.
[0056] In the objective function It can be understood as the total number of effective strong boundary points. Different values of the first parameter correspond to different total numbers of effective boundary points. When the objective function is calculated by genetic algorithm or particle swarm algorithm to take the maximum value, the optimal solution of the corresponding first parameter is the high threshold. It can be understood that when the objective function takes the maximum value, the corresponding effective strong boundary points are the largest, the longer the generated edge line is, and the higher the accuracy of the extracted edge line is.
[0057] S4. Calculate the low threshold in the canny algorithm.
[0058] S41, connecting the effective strong boundary points to obtain a plurality of sub-edge lines, and preliminarily fitting the pixel points between the endpoints of two adjacent sub-edge lines to obtain a connecting line.
[0059] After obtaining the effective strong boundary points, the effective strong boundary points form multiple sub-edge lines, and the matching degree between two adjacent sub-edge lines is calculated. When the matching degree of the two sub-edge lines is greater than the preset matching degree threshold, the pixel points between the endpoints of the two sub-edge lines are preliminarily fitted to obtain a connecting line. The expression of matching degree is: ;in, Sub-edge line and sub-margin line The matching degree between Sub-edge line Endpoints and subedges The Euclidean distance between endpoints, Sub-edge line The mean gray value of the pixels in Sub-edge line The mean gray value of the pixels in the image.
[0060] When extracting the edge line of the defective part, the edge line should be a closed curve. There are unconnected sub-edge lines. Therefore, it is necessary to connect the multiple sub-edge lines using the connection line obtained by fitting to obtain a closed edge line. When connecting, it is necessary to calculate the matching degree of the two sub-edge lines. The greater the matching degree, the more similar the two sub-edge lines are, and the greater the probability that they belong to the closed edge line of the same defective part. When the endpoints of the two sub-edge lines are close, it means that the probability that the two sub-edge lines belong to the closed edge line of the same part is greater; the grayscale values of the pixels of the same closed edge line should be similar. Therefore, when the absolute value of the grayscale value difference between the two edge lines is smaller, the matching degree is greater.
[0061] S42, setting a second parameter, taking pixel points whose gradient values are greater than the second parameter and less than the first parameter as weak boundary points, and calculating the Euclidean distance between the weak boundary points and the connecting line.
[0062] When the Euclidean distance between the weak boundary point and the connecting line is greater than the preset distance threshold, it indicates that the corresponding weak boundary point does not belong to the same defective part closed edge line. The probability is greater, and the corresponding weak boundary point is regarded as an invalid weak boundary point; otherwise, it is a valid weak boundary point, and the probability that the valid weak boundary point belongs to the pixel point of the defective part edge line is greater.
[0063] S43. Construct a low threshold objective function.
[0064] Objective function for low threshold: ; represents the total number of weak boundary points, Indicates the number of invalid weak boundary points; It represents the number of invalid weak boundary points. It can be understood that different values of the second parameter will lead to different proportions of invalid weak boundary points. In other words, one value corresponds to a function value. When the objective function takes the minimum value, it indicates that the fewer the number of invalid weak boundary points, the more the number of valid weak boundary points, and the more conducive it is to fit the valid weak boundary points to obtain the edge line. The genetic algorithm is used to calculate the optimal solution of the second parameter when the low threshold objective function takes the minimum value, and the optimal solution is used as the low threshold in the canny algorithm.
[0065] S5. Use the Canny algorithm to extract the edge lines of the defective parts in the grayscale image.
[0066] After determining the low threshold, the corresponding effective weak boundary points are also determined, and then the weight of each effective weak boundary point is calculated. The effective weak boundary points are fitted according to their weights to obtain the optimal connecting line, which together with the sub-edge line constitutes a closed edge line of the defective part.
[0067] The expression of the weight of the effective weak boundary point is:
[0068]
[0069] in, The coordinates are The weight of the effective weak boundary point, The coordinates are The gradient value of the effective weak boundary point, The coordinates are The distance between the effective weak boundary point and the connecting line obtained by preliminary fitting, Represents the normalization function.
[0070] The larger the weight of the effective weak boundary point, the more important the corresponding effective weak boundary point is, the greater the probability that it is a pixel point on the edge line of the defective part, and the closer the distance between the corresponding effective weak boundary point and the connecting line is. Therefore, the effective weak boundary point is weightedly fitted according to the weight of the effective weak boundary point to obtain the optimal connecting line to realize the update of the connecting line. The fitting method adopts the least squares method or the nonlinear least squares method, which is the existing technology, and the specific steps are not repeated here.
[0071] S6. Input the grayscale image into the neural network to perform quality inspection on the defective parts surrounded by the edge lines.
[0072] After the above steps, the edge lines of the defective parts in the grayscale image are extracted to obtain the defective area. The grayscale image is input into the convolutional neural network, and the convolutional neural network is used to further detect the defective area.
[0073] The high threshold and the low threshold are obtained by calculation, which improves the accuracy of the high threshold and the low threshold, retains the edge information to the greatest extent, reduces the phenomenon of edge information loss, improves the accuracy of edge line extraction, and further improves the accuracy of plate brush ear quality detection.
[0074] like Figure 2 As shown, the present invention also discloses a plate brush ear quality detection system based on image recognition, including a processor and a memory, the memory stores computer program instructions, and when the computer program instructions are executed by the processor, the plate brush ear quality detection method based on image recognition according to the present invention is implemented.
[0075] The above system also includes other components well known to those skilled in the art, such as a communication bus and a communication interface, and their configuration and functions are known in the art, so they will not be described in detail here.
[0076] In the present invention, the aforementioned memory may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, apparatus or device. For example, a computer-readable storage medium may be any appropriate magnetic storage medium or magneto-optical storage medium, such as a resistive random access memory RRAM (Resistive Random Access Memory), a dynamic random access memory DRAM (Dynamic Random Access Memory), a static random access memory SRAM (Static Random Access Memory), an enhanced dynamic random access memory EDRAM (Enhanced Dynamic Random Access Memory), a high bandwidth memory HBM (High Bandwidth Memory), a hybrid memory cube HMC (Hybrid Memory Cube), etc., or any other medium that can be used to store the required information and can be accessed by an application, a module or both. Any such computer storage medium may be part of a device or accessible or connectable to a device.
[0077] In the description of this specification, “plurality” means at least two, such as two, three or more, etc., unless otherwise clearly and specifically defined.
[0078] Although this specification has shown and described a number of embodiments of the present invention, it will be apparent to those skilled in the art that such embodiments are provided by way of example only. Those skilled in the art will conceive of many modifications, changes and alternatives without departing from the ideas and spirit of the present invention. It should be understood that in the practice of the present invention, various alternatives to the embodiments of the present invention described herein may be employed.
Claims
1. A plate brush lug quality detection method based on image recognition, characterized in that: Includes steps: Obtain the grayscale image of the plate brush ear, calculate the high threshold in the Canny algorithm, and use the Canny algorithm to extract the edge line of the defective part in the grayscale image; The grayscale image is input into the neural network to perform quality inspection on the defective parts surrounded by the edge lines; The calculation method of the high threshold is: Calculate the gradient value and gradient direction of the pixel points in the grayscale image; The gradient direction is normalized to obtain the standard gradient direction. The method is as follows: the gradient direction of the pixel point is mapped to polar coordinates, and multiple rays are constructed with the origin of the polar coordinate system as the center, and the angles between two adjacent rays are the same; the angle between the gradient direction and each ray is calculated, and the ray direction with the smallest angle is used as the gradient direction of the corresponding pixel point; Set a first parameter, and take pixel points whose gradient values are greater than the first parameter as strong boundary points; In the neighborhood of any strong boundary point, if there is no strong boundary point along the standard gradient direction, it indicates that the strong boundary point is unique; if there is a strong boundary point along the normal direction of the standard gradient direction, and the standard gradient directions of the two strong boundary points are the same, it indicates that the boundary point is continuous; The strong boundary points with uniqueness and continuity are regarded as effective strong boundary points; Construct the objective function with a high threshold: , The coordinates are The effective strong boundary point of Indicates the number of effective strong boundary points; Calculate the optimal solution of the first parameter when the objective function is at its maximum value, and use the optimal solution as the high threshold.
2. The plate brush lug quality detection method based on image recognition according to claim 1 is characterized in that: Testing methods also include: Connect the effective strong boundary points to obtain multiple sub-edge lines, and use the connecting line to connect two adjacent sub-edge lines; Set a second parameter, take the pixel points whose gradient value is greater than the second parameter and less than the first parameter as weak boundary points, calculate the Euclidean distance between the weak boundary point and the connecting line, and when the Euclidean distance is greater than a preset distance threshold, the corresponding weak boundary point is an invalid weak boundary point; otherwise, it is a valid weak boundary point; Construct the objective function with a low threshold: ; represents the total number of weak boundary points, Indicates the number of invalid weak boundary points; The genetic algorithm is used to calculate the optimal solution of the second parameter when the low threshold objective function takes the minimum value, and the optimal solution is used as the low threshold in the canny algorithm.
3. The plate brush lug quality detection method based on image recognition according to claim 2 is characterized in that: Connecting two adjacent sub-edge lines using a connecting line includes: The matching degree between two adjacent sub-edge lines is calculated, and when the matching degree between the two sub-edge lines is greater than a preset matching degree threshold, the sub-edge lines are connected using a connecting line.
4. The method for detecting the quality of the plate brush lug based on image recognition according to claim 3 is characterized in that: The expression of matching degree is: ; in, Sub-edge line and sub-margin line The matching degree between Sub-edge line Endpoints and subedges The Euclidean distance between endpoints, Sub-edge line The mean gray value of the pixels in Sub-edge line The mean gray value of the pixels in the image.
5. The method for detecting the quality of the plate brush lug based on image recognition according to claim 2, characterized in that: After connecting two adjacent sub-edge lines using a connecting line, the method further includes: The weights of the effective weak boundary points are calculated, and the connecting lines are updated according to the weights of the effective weak boundary points to obtain the optimal connecting lines.
6. The method for detecting the quality of the plate brush lug based on image recognition according to claim 1, characterized in that: The genetic algorithm is used to calculate the optimal solution of the first parameter when the objective function is maximized.
7. The plate brush lug quality detection system based on image recognition is characterized by: include: processor; A memory storing computer instructions for plate brush lug quality detection based on image recognition. When the computer instructions are executed by the processor, the system executes the plate brush lug quality detection method based on image recognition according to any one of claims 1 to 6.
Citation Information
Patent Citations
Image processing methods for tunnel crack detection
CN106504246B
Battery accessory quality detection method and system based on machine vision
CN119027422A
Ultrasound image enhancement and speckle mitigation method
US20070065009A1