Package packaging detection method and system based on image processing
By smoothing the packaging image and building gradient edge point sets, combined with local curvature and color analysis, the identification problems of complex structural features and local subtle defects are solved, and high-precision packaging defect detection is achieved.
Patent Information
- Application Number
- CN202510397551.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-01
- Publication Date
- 2025-07-22
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
In the prior art, the recognition sensitivity of complex structural features and local subtle defects is insufficient, resulting in the loss of edge detail information, making it difficult to achieve accurate and effective judgment of edge continuity, especially in the case of small structural abnormalities or color differences, the recognition accuracy and stability are low.
By smoothing the packaging image, the gradient intensity is calculated and non-maximum suppression screening is performed, the gradient edge point set is obtained, the disconnected edges are connected to form the edge contour point set, the local curvature is calculated to identify key geometric feature points, the edge geometric topology is constructed, and the color channel value of the edge area is analyzed. The packaging defect judgment information is generated based on topological deviation evaluation.
It improves sensitivity to micro topological abnormalities, improves the accuracy and reliability of packaging defect detection, reduces the probability of missed and missed detection, and enhances the quality control capability in the production process.
Smart Images

Figure SMS_1 
Figure SMS_2 
Figure SMS_3
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image processing, and particularly to a packaging and encapsulation detection method and system based on image processing. Background Art
[0002] The technical field of image processing is a comprehensive technology for analyzing, enhancing, restoring, compressing, and recognizing images by a computer, usually involving steps such as digital image acquisition, preprocessing (such as image denoising, enhancement, edge detection, etc.), feature extraction, target recognition and classification, image segmentation, and pattern recognition.
[0003] In the prior art, the recognition sensitivity for complex structural features and local subtle defects is insufficient, which easily leads to the loss of edge detail information and makes it difficult to achieve accurate and effective edge continuity judgment; when encountering the situation of minute structural anomalies or defects with insignificant color differences, it usually shows low recognition accuracy and stability, and it is difficult to distinguish qualified products from defective products. Therefore, improvements are needed. Summary of the Invention
[0004] The purpose of the present invention is to solve the drawbacks existing in the prior art, and to propose a packaging and encapsulation detection method and system based on image processing.
[0005] To achieve the above purpose, the present invention adopts the following technical solution. The packaging and encapsulation detection method based on image processing includes the following steps:
[0006] Obtain the packaging and encapsulation image to be detected, smooth the packaging and encapsulation image, calculate the gradient intensity of the smoothed image at each pixel point, perform non-maximum suppression to screen potential edge points, and obtain a gradient edge point set; based on the gradient edge point set, determine strong and weak edges and connect the disconnected edges to establish a sealed edge contour point set;
[0007] Based on the sealed edge contour point set, calculate the local curvature of each point position, identify the changing point positions, and obtain a set of key geometric feature points of the sealed edge; based on the set of key geometric feature points of the sealed edge and the sealed edge contour point set, connect edge points to fit straight line segments and arc segments, and construct a sealed edge geometric topology structure with straight line segments, arc segments, and corner points as nodes and adjacency relationships as edges;
[0008] For the packaging sealed edge area of the packaging and encapsulation image, extract the color channel values of the pixels, calculate the kurtosis value within the packaging sealed edge area, and obtain a set of sealed edge color statistical moments;
[0009] Based on the edge sealing geometric topology, compare the corresponding topological attributes of connectivity, closed loops, and branch point attributes with the standard packaging edge sealing template, determine the disconnection and abnormal branch situations in the figure, obtain the evaluation result of the edge sealing topological structure deviation, and based on the evaluation result of the edge sealing topological structure deviation and the edge sealing color statistical moment set, compare the deviation degree of the kurtosis value from the corresponding kurtosis value range of the standard sample to generate the packaging defect determination information.
[0010] Preferably, the steps for obtaining the gradient edge point set are as follows:
[0011] Obtain the packaging and encapsulation image to be detected, perform pixel smoothing on the image to generate a smoothed packaging and encapsulation image;
[0012] Based on the smoothed packaging and encapsulation image, calculate the gradient intensity of each pixel point, and the calculation formula is:
[0013]
[0014] where Q is the gradient intensity, A x represents the gray gradient change of adjacent pixels in the horizontal direction, A y represents the gray gradient change of adjacent pixels in the vertical direction, B x represents the second-order gradient in the horizontal direction, B y represents the second-order gradient in the vertical direction;
[0015] Based on the gradient intensity, apply non-maximum suppression to screen edge points to form a gradient edge point set.
[0016] Preferably, the steps for obtaining the edge sealing contour point set are as follows:
[0017] Based on the gradient edge point set, classify the edge points to generate a hierarchical edge point classification result;
[0018] For the hierarchical edge point classification result, calculate the Euclidean distance and angle from each point to the center of the adjacent point set, and calculate the local connection strength of the edge points. The calculation formula is:
[0019]
[0020] where L is the local connection strength of the edge point, ck is the number of adjacent points around the edge point, P i represents the coordinate of the i-th edge point, C is the geometric center of the adjacent point set, σ is the standard deviation of the edge point coordinates, and θ i is the angle of point P i relative to C;
[0021] Apply the local connection strength to optimize the connection between edge points, adjust the disconnected edges, form a continuous edge sealing contour, and form an edge sealing contour point set.
[0022] Preferably, the steps for obtaining the set of key geometric feature points of the edge sealing are as follows:
[0023] Based on the set of edge-sealing contour points, calculate the curvature for each point position. Based on the coordinates of each point and its directly adjacent points, calculate the local curvature value of each point to obtain a curvature data set;
[0024] Based on the curvature data set, calculate the curvature sensitivity and change frequency of each point. The calculation formulas are:
[0025]
[0026] and
[0027]
[0028] where S represents the curvature sensitivity of the i-th edge-sealing contour point, F represents the change frequency of the i-th edge-sealing contour point, κ i represents the local curvature value of the i-th edge-sealing contour point, κ avg represents the average value of the local curvature values of the three edge-sealing contour points i-1, i, and i+1, represents the average curvature value of all points in the entire set of edge-sealing contour points, κ j represents the local curvature value of the j-th edge-sealing contour point, max(κ) represents the maximum local curvature value among the three points centered on the i-th point, and Δx represents the average Euclidean distance between adjacent points in the set of edge-sealing contour points;
[0029] Combining the curvature sensitivity and change frequency, identify the change points, and aggregate the change points to form a set of key geometric feature points of the edge sealing.
[0030] Preferably, the steps for obtaining the edge-sealing geometric topology are as follows:
[0031] Based on the set of key geometric feature points of the edge sealing and the set of edge-sealing contour points, traverse all the key geometric feature points of the edge sealing, determine their relative positions in the set of edge-sealing contour points, and divide different regions according to the distribution characteristics of the points. Calculate the connectivity between points in each region to generate a preliminary connection relationship of the edge-sealing points;
[0032] According to the preliminary connection relationship of the edge-sealing points, classify the edge points, judge the geometric relationship between adjacent points, screen the point sets that can be fitted by straight lines or arcs, merge the point sets that meet the straight-line fitting conditions into straight-line segments, merge the point sets that meet the arc-fitting conditions into arc segments, and mark the node attributes of the straight-line segments, arc segments, and corner points to form edge-sealing structural units;
[0033] Based on the edge-sealing structure unit, the straight line segments, arc segments, and corner points are topologically connected according to the adjacency relationship to form an edge-sealing geometric topology structure.
[0034] Preferably, the steps for obtaining the edge-sealing color statistical moment set are as follows:
[0035] Extract the pixel values of the RGB color channels from the edge-sealing area of the packaging and encapsulation image, and form independent data sets for each color channel respectively;
[0036] For the independent data sets, calculate the kurtosis value, and the calculation formula is:
[0037]
[0038] where K′ is the kurtosis value, n is the number of data points, x t is the color value of the pixel of the nth data point, is the average value of the color values, s is the standard deviation, and m is the median of the color values;
[0039] Integrate the kurtosis values calculated for each color channel, construct an edge-sealing color statistical moment set, and obtain the edge-sealing color statistical moment set.
[0040] Preferably, the steps for obtaining the evaluation result of the edge-sealing topology structure deviation are as follows:
[0041] Extract the connectivity relationship between nodes, the number of closed paths, and the number of branches of each corner point from the edge-sealing geometric topology structure, and construct an edge-sealing graph structure by traversing the node set and the edge set to form a standardized topological feature group;
[0042] Based on the standardized topological feature group, combined with the number of edge-sealing contour edges, the number of closed loops, the number of abnormal branches, the out-degree of corner points, and the structural direction angle, calculate the topological structure deviation amount, and the calculation formula is:
[0043]
[0044] where D is the topological structure deviation amount, a is the number of edges in the edge-sealing graph, a s is the number of edges in the template edge-sealing graph, b is the number of closed paths, b s is the number of standard closed paths, c is the number of abnormal branches, c s is the number of branches of the template, φ is the structural direction angle between nodes, φ s is the template structural direction angle, gk is the average out-degree of corner points, gk s is the average out-degree of template corner points;
[0045] Set a threshold range for structural complexity according to the topological structure deviation amount, determine the deviation of the edge-sealing geometric topological structure, identify whether there are abnormalities, and obtain the evaluation result of the edge-sealing topological structure deviation.
[0046] Preferably, the step of obtaining the packaging defect determination information is as follows:
[0047] Based on the edge-sealing topological structure deviation evaluation result and the edge-sealing color statistical moment set, perform item-by-item matching analysis of the two-dimensional attributes of structure and color, extract the coordinate correlation positions of the edge-sealing boundary structure feature points and color kurtosis, mark the topological structure identifiers corresponding to each point, and compare the topological position range, tolerance type and color channel kurtosis threshold of the topological structure identifier under the standard template to generate the combined deviation analysis result of the edge-sealing structure and color;
[0048] Based on the combined deviation analysis result of the edge-sealing structure and color, extract the structure anomaly type, color channel anomaly intensity and corresponding channel numbers to generate the packaging defect determination information.
[0049] The present invention provides a packaging and encapsulation detection system, including:
[0050] An image acquisition module, which receives the packaging and encapsulation image to be detected, stores it in the memory, and obtains the original image data;
[0051] An image preprocessing module, which performs smoothing processing on the original image data, calculates the gradient intensity of each pixel point, filters potential edge points, and generates a gradient edge point set;
[0052] An edge connection module, which identifies and connects the disconnected edges from the gradient edge point set, determines the strong and weak edges through gradient changes, constructs an edge-sealing contour, generates an edge-sealing contour point set, calculates the local curvature of each point, identifies key geometric feature points, and obtains an edge-sealing key geometric feature point set;
[0053] A geometric structure analysis module, which based on the edge-sealing key geometric feature point set and the edge-sealing contour point set, connects edge points to fit line segments and arc segments, establishes a geometric topological structure, and generates an edge-sealing geometric topological structure;
[0054] A defect detection and evaluation module, which on the basis of the edge-sealing geometric topological structure, extracts the pixel color channel values in the edge-sealing area, calculates the kurtosis value, compares it with the standard edge-sealing template, evaluates the disconnection and abnormal branch situations, and generates the packaging defect determination information in combination with the color statistical data.
[0055] Compared with the prior art, the advantages and positive effects of the present invention are as follows:
[0056] The present invention performs smoothing processing on the obtained packaging and encapsulation image to reduce the noise interference of the image and improve the accuracy of gradient intensity calculation; precisely extracts potential edge points by means of non-maximum suppression to form an accurate set of gradient edge points; determines strong and weak edges based on these gradient edge points and connects the disconnected edges to form a continuous and stable set of edge contour points; further extracts local curvature information based on this edge contour, locates geometric change points, and generates a set of key geometric feature points; subsequently, based on the geometric topology structure jointly constructed by the feature points and the edge contour points, establishes the topological relationship of the edge region, ensuring the high sensitivity of the detection method to minor topological anomalies; in addition, by analyzing the color channel values of the edge region of the packaging and calculating the kurtosis value, quantitatively evaluates the difference in color distribution, and realizes the sensitive perception of color anomalies; finally, comprehensively judges using the results of topological structure deviation and color statistical differences to accurately generate packaging defect determination information, improving the accuracy, reliability, and automation level of packaging defect detection, reducing the probability of missed and false detections of packaging defects, reducing manual intervention, and enhancing the overall quality control ability in the production process. BRIEF DESCRIPTION OF THE DRAWINGS
[0057] Figure 1 It is a schematic diagram of the steps of the present invention. DETAILED DESCRIPTION OF THE INVENTION
[0058] In order to make the objectives, technical solutions, and advantages of the present invention clearer, the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.
[0059] Please refer to Figure 1 , the present invention provides a technical solution, a packaging and encapsulation detection method based on image processing, including the following steps:
[0060] Obtain the packaging and encapsulation image to be detected, smooth the packaging and encapsulation image, calculate the gradient intensity of the smoothed image at each pixel point, perform non-maximum suppression to screen potential edge points, and obtain a set of gradient edge points; based on the set of gradient edge points, determine strong and weak edges and connect the disconnected edges to establish a set of edge contour points;
[0061] Based on the set of edge contour points, calculate the local curvature of each point, identify the changing points, and obtain a set of key geometric feature points of the edge; based on the set of key geometric feature points of the edge and the set of edge contour points, connect the edge points to fit straight line segments and arc segments, and use the straight line segments, arc segments, and corner points as nodes and the adjacency relationship as edges to construct an edge geometry topology structure;
[0062] For the packaging edge region of the packaging and encapsulation image, extract the color channel values of the pixels, calculate the kurtosis value within the packaging edge region, and obtain a set of edge color statistical moments;
[0063] Based on the edge - sealing geometric topology, compare the corresponding topological attributes of connectivity, closed - loop, and branch - point attributes with those of the standard packaging edge - sealing template, determine the disconnection and abnormal branch situations in the graph, obtain the evaluation result of the edge - sealing topological structure deviation, and based on the evaluation result of the edge - sealing topological structure deviation and the set of edge - sealing color statistical moments, compare the deviation degree of the kurtosis value from the corresponding kurtosis value range of the standard sample to generate the packaging defect determination information.
[0064] The steps for obtaining the gradient edge - point set are as follows:
[0065] Obtain the packaging and encapsulation image to be detected, perform pixel smoothing on the image to generate the smoothed packaging and encapsulation image;
[0066] Based on the smoothed packaging and encapsulation image, calculate the gradient intensity of each pixel point. The calculation formula is:
[0067]
[0068] where \(Q\) is the gradient intensity, \(A\) x represents the gray - level gradient change of adjacent pixels in the horizontal direction, \(A\) y represents the gray - level gradient change of adjacent pixels in the vertical direction, \(B\) x represents the second - order gradient in the horizontal direction, \(B\) y represents the second - order gradient in the vertical direction;
[0069] Based on the gradient intensity, apply non - maximum suppression to screen edge points to form a gradient edge - point set.
[0070] Specifically, based on the existing imaging scheme, the packaging and encapsulation images to be detected are collected. An industrial digital camera with a pixel resolution of 2448×2048 is used for shooting. 30 frames are continuously collected per second, and all image frames are stored in a specified image dataset in the acquisition software. This image dataset contains the color channel values and spatial coordinate information of each pixel. To maintain stable lighting during the shooting process and reduce external ambient light interference, a constant illuminance light source is set, and the shutter speed of the industrial camera is fixed at 1 / 60 second. When reading the image data after imaging, no multi-channel separation operation is performed. Pixel smoothing processing is directly applied to the obtained original color image. The Gaussian filtering algorithm with a two-dimensional convolution kernel size of 5×5 is applied, and the standard deviation is set to 1.2. This convolution kernel performs convolution operations row by row and column by column in the image matrix and matches the weight values according to the position of the current pixel inside the kernel. The weight values are obtained in a way that decreases sequentially from the center position to the edge position according to the characteristics of the image gray distribution, forming a specific Gaussian weight matrix. Subsequently, the result of the convolution calculation is used to replace the value of the original pixel to obtain the filtered smooth image data. After the Gaussian filtering is completed, the filtered image is subjected to a bilateral filter once according to the noise level during the imaging process. The bilateral filter radius is set to 3, and the standard deviations of color similarity and spatial distance are set to 15 and 5 respectively. These values are selected after measuring the actual noise distribution when statistically analyzing 1000 similar packaging and encapsulation images. By jointly calculating the similarity and distance information, pixels with a large difference in color and space from the current pixel are removed, maintaining the main texture features and reducing the random noise in the image. Finally, the smoothed packaging and encapsulation image is obtained.
[0071] Formula: The benefit of the formula is that it can integrate the information of the first-order gradient and the second-order gradient into the same expression. By performing the cubic processing on |A x | and |A y | and the power calculation of , the simultaneous quantification of the local gray change amplitude and the second-order change trend is realized, so as to more sensitively capture the details of complex edge regions;
[0072] To determine the Q threshold clearly, it is necessary to first statistically analyze 600 packaging images of the same category captured on the actual production line, calculate the Q value distribution of all pixels respectively, and obtain the average value and standard deviation. The Q threshold T is determined by the following calculation formula Q : Where represents the average value of all pixel Q values, σ Q represents the standard deviation of Q values, and λ is a multiple factor fixed at 2.1 after statistically analyzing multiple batches of samples. In the actual example, the of the collected samples is 22.35, σQ is 3.78. Substituting it into the formula gives T Q = 22.35 + 2.1×3.78 = 30.3038;
[0073] A x The steps to obtain the parameter are as follows: Traverse all pixels in the horizontal direction of the smoothed image, read the gray - level difference between the current pixel and the pixel on the right, and denote it as A x,i , store these differences in a list with the same length as the row width. After excluding the non - computable area in the right - most column of the image, a complete A x sequence is formed. Each A x,i is within [-255, 255]. The specific value comes from the subtraction operation on the original gray - level values. To obtain the overall distribution characteristics of A x , it is necessary to calculate the median, mean, and variance of A x and use them in subsequent analysis. This sequence of data can be quantized into a more manageable interval distribution by the following method: where min(A x ) and max(A x ) represent the minimum and maximum values of the entire A x sequence respectively. By performing linear normalization on A x , all values are mapped to the interval of 0, 100. In a specific calculation, min(A x ) = -45, max(A x ) = 60. When A x,i = 0, we can get
[0074] A y The steps to obtain the parameter are as follows: Traverse each column of pixels along the vertical direction, read the gray - level difference between the current pixel and the pixel below one by one, and denote it as A y,i . These differences are also distributed within [-255, 255]. To extract the distribution characteristics of A y in the whole image, it is necessary to perform statistics after calculating all A y,i to obtain the A y sequence, and map it to the 0, 100 interval through the same linear normalization method as A x for unified management when fusing the first - order gradient later. The normalization formula used is the same as that of A x,norm,i . In a set of measured data, min(A y ) = -50, max(A y ) = 58. When A y,i = -10, we can get
[0075] B x The steps for obtaining the parameter are as follows: Calculate the difference of the differences of adjacent pixels simultaneously within each row of pixels in the horizontal direction. Previously, sequence A has been obtained. x The same adjacent difference operation can be performed on this sequence to obtain sequence B. x Sequence B x,i represents A x,i+1 -A x,i , and the numerical range is smaller than that of A x , mainly distributed in the interval [-100, 100]. When specifically obtaining, store the B x data in a two-dimensional array corresponding to the number of image rows and perform calculations sequentially within each row. In order to obtain a reference value γ x measuring the overall distribution of B Bx , the following formula is used: Here, N is the number of all pixels for which B can be calculated. x,i In a calculation of an image with a size of 1200×800 at one time, the absolute average value γ x of B is measured to be 15.32. Subsequently, the second-order gradient threshold T Bx can be set according to γ Bx , for example, T B = 2×γ B = 30.64; Bx
[0076] B y The steps for obtaining the parameter are as follows: Perform an adjacent difference operation on sequence A in the vertical direction as well. y Sequence B y,i represents A y,i+1 -A y,i and is in the interval [-100, 100]. After obtaining all B y,i , perform statistics through the absolute average value . Here, M represents the number of valid pixel differences in B y . When performing this operation on images of the same type collected from the production line, γ By is approximately 14.97. Similar to B x , set the second-order gradient threshold through T B = 2×γ By and separately identify the abnormal positions in the vertical direction. For convenient subsequent calling, it is necessary to store B y and B x in the same coordinate system to ensure that the same pixel coordinates can be quickly matched during the overall calculation of Q in the future;
[0077] Calculation process:
[0078] Let A x = 12, A y = -20, Bx = 4, B y = -6 is substituted into the original formula, and first calculate |A x | 3 = |12| 3 = 1728, |A y | 3 = |-20| 3 = 8000, and then calculate Then At this time, adding the above results gives 1728 + 8000 + 374.40 = 10102.40, and finally perform the square root operation
[0079] This result indicates that for the current pixel position, considering the first-order gradient changes in the horizontal and vertical directions and the corresponding second-order gradient features, the value of Q has reached 100.51. This value combined with the previously set T Q for comparison can intuitively reflect the comprehensive intensity of the current pixel in the overall image gray-scale change, greater than T Q = 30.3038 is usually judged as a potential edge candidate point. Through this algorithm design of three-item information fusion, more accurate recognition of high-frequency textures and weak contrast regions can be achieved in the subsequent edge extraction stage.
[0080] Based on the Q value distribution obtained at all pixels previously and combined with the threshold T calculated previously Q , the non-maximum suppression method is used to make targeted judgments on all pixel positions. First, scan row by row and determine whether there is a Q value around the pixel that is larger than the current pixel. The specific method is to query the Q value at 8 pixel positions including up, down, left, right, and diagonals of the current pixel coordinate, record whether the Q at these positions exceeds the current pixel Q and mark it in a temporary sequence. In order to extract the point with the most obvious gradient intensity, during the recording stage, Q values lower than T Q are removed and the pixel coordinates exceeding this threshold are retained. If it is found that there is a pixel with a larger Q around a certain pixel, the current pixel Q is classified as a non-maximum value and removed from the output set. After the row scan is completed, switch to column scan for the same non-maximum suppression judgment. After the column scan is completed, the pixel coordinates output will be removed when both row and column judgments are established. The remaining pixel coordinates are checked and there are no neighbor Q values larger than them, so they can be confirmed as maximum value points and written into the edge point candidate list. Next, perform statistical distribution analysis on the Q of each pixel in this list again. In the statistical distribution analysis link, retrieve the pixel index in the list one by one and extract its Q value, calculate the total number and form a new list for subsequent use. For the points with too low Q values in the list, according to the previously obtained T QEliminate them. Finally, after the elimination is completed, the remaining coordinates and Q values are combined to form a gradient edge point set and applied to detect the edge structure of the packaging and encapsulation image later.
[0081] The steps for obtaining the edge sealing contour point set are as follows:
[0082] Based on the gradient edge point set, classify the edge points to generate a hierarchical edge point classification result;
[0083] For the hierarchical edge point classification result, calculate the Euclidean distance and angle from each point to the center of the adjacent point set, and calculate the local connection strength of the edge points. The calculation formula is:
[0084]
[0085] Among them, L is the local connection strength of the edge point, ck is the number of adjacent points around the edge point, P i represents the coordinate of the i-th edge point, C is the geometric center of the adjacent point set, σ is the standard deviation of the edge point coordinates, θ i is the point P i relative to the angle of C;
[0086] Apply the local connection strength to optimize the connection between edge points, adjust the disconnected edges, form a continuous edge sealing contour, and form an edge sealing contour point set.
[0087] Specifically, based on the gradient edge point set obtained previously, first read the coordinate information of each edge point. With reference to the previously sorted edge stratification criteria, perform label mapping on this coordinate information one by one. The edge stratification criteria use different gradient intensity ranges as classification lines. For example, the area with a gradient intensity between 30 and 60 is regarded as the first-level edge, the area with a gradient intensity between 60 and 90 is regarded as the second-level edge, and the area with a gradient intensity greater than 90 is regarded as the third-level edge. The values of the stratification criteria are obtained from the statistics performed on the same batch of images before. Among them, calculate the edge gradient intensity of 1000 images in the same batch to form a numerical sequence. After extracting the average value and standard deviation, determine the distribution interval of the corresponding level. In order to perform the classification operation, compare the gradient intensity of each edge point one by one to sort out which gradient range the current edge point is in, write the corresponding label into the additional attribute field of the point coordinates, and at the same time, in the record, correspond the row and column where the point is located to the label to form an index entry. After the classification is completed, continue to retrieve the set of edge point coordinates belonging to the same level, and perform geometric position clustering on these coordinate sets again. By comparing the Euclidean distance between the coordinates and setting a distance threshold, if the Euclidean distance from any point within the same level to other points does not exceed 15 pixels, it is regarded as adjacent, and all adjacent point sets are aggregated into the same group. If the distance is more than 15 pixels, it is assigned to another group. Through this grouping method, the point set of the same level is split into several subsets. After the classification operation is completed, record the row and column coordinates of the center point of each subset and the number of elements it contains within each subset. For the possible edge break points within the set, no additional processing is performed, and the original classification result is maintained for the subsequent connectivity analysis. These subsets form the classified result of the stratified edge points after being recorded.
[0088] Formula: The advantage of the formula is that it multiplies the distance attenuation factor and the angle factor and performs weighted superposition in the same summation expression, so as to take into account the tightness of the distribution of neighboring points and the direction consistency when calculating the local connection strength of edge points. Through this construction, the stability of local connection can be determined according to the spatial position and orientation information of adjacent edge points.
[0089] The steps to obtain the ck parameter are as follows: This parameter represents the number of adjacent points around the edge point. The general way to obtain it is to read the stratified edge set where the current point is located, and then determine all the points in an adjacent relationship with the current point in this set by setting an adjacent distance threshold or an adjacent direction threshold. The sum is the value of ck. For example, in a packaging image with a resolution of 1200×800, when setting the adjacent distance not greater than 10 pixels and the direction difference not exceeding 15 degrees for the center point (200, 150), the number of adjacent points ck = 12 may be obtained.
[0090] P iThe steps to obtain the parameter are as follows: This parameter represents the coordinates of the i-th edge point. By obtaining the positions of all edge points in the previous edge detection and hierarchical classification results, the row and column indices of the relevant points can be directly mapped to the specific (x, y) coordinates and denoted as P i , where i traverses within the interval of 1, ck. To facilitate subsequent calculations, it is also necessary to record P i the distance ‖P i -C‖ and the included angle θ i with the center point C. These quantities can all be directly obtained from coordinate subtraction and inverse trigonometric functions. If the current point is (200, 150) and a certain adjacent point P i is (207, 153), then in the horizontal direction, Δx = 7 can be obtained, and in the vertical direction, Δy = 3. In the Euclidean distance calculation
[0091] The steps to obtain the C parameter are as follows: This parameter represents the geometric center of the adjacent point set and can be calculated through the following formula in practical applications: where x i and y i are the coordinates of each adjacent point respectively, ck is the number of adjacent points, and (C x , C y ) is written into the variable C as the center coordinates of the overall adjacent point set. For example, when ck = 12 and the sum of the corresponding x i coordinates is 2460 and the sum of the y i coordinates is 1860, then C x = 2460 / 12 = 205, C y = 1860 / 12 = 155, and finally C = (205, 155).
[0092] The steps to obtain the σ parameter are as follows: This parameter represents the standard deviation of the edge point coordinates and is used to measure the degree of dispersion of adjacent points in spatial distribution. It can be obtained in the following way: σ x and σ y are calculated separately and then averaged or the larger one is selected as the overall σ value. In one acquisition, if the variance value of x i is close to the variance value of y i , then σ can be set as the average of the two. If in a certain calculation, σ x = 4.3 and σ y = 6.1, then σ = (4.3 + 6.1) / 2 = 5.2 can be obtained.
[0093] θ i The steps to obtain the parameter are as follows: This parameter represents the angle of point P i relative to the geometric center C and is usually obtained with reference to the horizontal direction using the arctangent function. The calculation formula is: By substituting Δx = x i - C x and Δy = y i - C y into the arctangent function, the direction angle of each adjacent point relative to C can be obtained. To be compatible with different quadrant ranges, a signed judgment method can be used in programming to obtain the correct quadrant. If (207, 153) is substituted into C = (205, 155), then Δx = 2 and Δy = - 2. Thus, θ i = arctan(-2 / 2) = arctan(-1) ≈ - 45°.
[0094] Calculation process:
[0095] Substitute ck = 12, ‖P i - C‖ = 7.62, σ = 5.2, θ i = - 45° into:
[0096]
[0097] Multiply these two to get 0.34 × 0.707 ≈ 0.24. If similar calculations are performed for all 12 adjacent points and the corresponding values are obtained, and then they are accumulated in ∑, the final value of L can be obtained. For example, if the sum of the values calculated for the remaining adjacent points according to the same process is 2.63, then L = 2.63.
[0098] This result indicates that the overall connection strength for the current central point (200, 150) and its 12 surrounding adjacent points is 2.63. When L is between 1.5 and 3.0, it can be determined that this point has an obvious aggregation trend in the adjacent distribution. When it exceeds 3.0, it means that the adjacent points have a higher concentration in the same direction. When it is less than 1.5, the adjacent points are less closely distributed. Subsequently, L can be compared with a pre - defined connection threshold to screen for fracture positions or unstable connection positions.
[0099] Apply the local connection strength values obtained previously. First, traverse all the point coordinates in each hierarchical edge subset, read the L values and coordinate information corresponding to these points, and then check the connection status between each other according to a certain distance determination rule. If the row and column differences between two points are within 10 pixels and their L values are both greater than 2.0, assign them to the same connected component and establish related entries in the record to indicate the connected relationship between these two points. If it is detected that the L value of a certain point is less than 1.5 and there are no other points satisfying the adjacency relationship, it is considered that the position where this point is located belongs to an edge fracture segment. The coordinates of this point need to be extracted and added to the fracture branch list. Subsequently, perform a step-by-step extension process for all the points in the fracture branch list, retrieve the pixel positions in 8 directions around the fracture point, and compare whether these surrounding pixels have been marked in other connected components or their L values have reached 2.0 or above. If a match is found, establish a new connection relationship for it; otherwise, retain it in the fracture branch and continue to check the next point. Gradually merge the adjacent points into the same complete connected structure through multiple scans. The remaining point coordinates in the fracture branch list may not meet the connection conditions and continue to exist independently. Finally, summarize the point coordinates of all connected components to form a continuous edge sealing contour set. After sorting this set according to row and column coordinates, the edge sealing contour point set can be obtained.
[0100] The steps to obtain the set of key geometric feature points for edge sealing are as follows:
[0101] Based on the edge sealing contour point set, calculate the curvature for each point position. Based on the coordinates of each point and its directly adjacent points, calculate the local curvature value of each point to obtain a curvature data set;
[0102] Based on the curvature data set, calculate the curvature sensitivity and change frequency of each point. The calculation formulas are:
[0103]
[0104] and
[0105]
[0106] where S represents the curvature sensitivity of the i-th edge sealing contour point, F represents the change frequency of the i-th edge sealing contour point, κ i represents the local curvature value of the i-th edge sealing contour point, κ avg represents the average value of the local curvature values of the three edge sealing contour points i - 1, i, and i + 1, represents the average curvature value of all points in the entire edge sealing contour point set, κ j represents the local curvature value of the j-th edge sealing contour point, max(κ) represents the maximum local curvature value among the three points centered on the i-th point, and Δx represents the average Euclidean distance between adjacent points in the edge sealing contour point set;
[0107] Identify change points by combining curvature sensitivity and change frequency, and aggregate the change points to form a set of key geometric feature points for edge sealing.
[0108] Specifically, based on the edge-sealing contour point set obtained previously, read the coordinates of each point and sequentially select the coordinates of the points directly adjacent to it one by one. Calculate the coordinate differences between the current point and the adjacent points in the horizontal and vertical directions. Obtain the curvature information of the current point by comparing the vector cross product and dot product of these differences. Then, sequentially number the curvature values of all points and map them using row and column indices. Conduct distance determination and angle analysis for the neighbor relationship of each point in a loop structure. Record the additional relative positions of the points with a distance less than or equal to 5 pixels, and further extend the local curvature of this point one grid forward and backward in the continuous position sequence. Extract adjacent data in the row and column coordinates by extending one grid forward and backward to avoid overly isolated or jumping curvature. Subsequently, perform vector calculations on the coordinate differences between each point and its neighbors to obtain local curvature values. Write these local curvature values into the same list and arrange them in coordinate order. After scanning all points, summarize the list, and statistically calculate the maximum, minimum, and average values of the curvature values in the list for subsequent possible judgment or grading processing. After completion of the statistics, obtain the curvature data set, which records the curvature values of all edge-sealing contour points and their corresponding relationships with adjacent points, facilitating more refined analysis of curvature changes in subsequent steps to obtain the curvature data set.
[0109] The benefit of the formula is that it measures the deviation degree between the curvature of the target point and the surrounding average curvature through S, and quantifies the strength of local curvature change combined with the spatial distance through F. S and F complement each other, enabling not only to focus on the difference between a single point and the local mean value in the same contour, but also to take into account the difference intensity in curvature between the point and its adjacent positions before and after.
[0110] κ i Steps for obtaining the parameter: κ i Represents the local curvature value of the i-th edge-sealing contour point. Set a fixed step size in the contour and measure the forward and backward offset distances of each point. Calculate the curvature according to the two-dimensional coordinates: where the area is the area of the triangle formed by this point and its two adjacent points on the plane, and the chord length refers to the distance of the base of the triangle between the adjacent two points, obtaining κ i Then record it in an array. For example, in a detection, the area of the triangle formed by the coordinates of a certain point and its two adjacent points is approximately 2.1, and the chord length is approximately 3.2, then
[0111] κ avg Steps for obtaining the parameter: κ avgRepresents the average of the local curvature values of the three edge - sealing contour points at positions \(i - 1\), \(i\), and \(i+1\). To obtain \(\kappa\) avg It is necessary to first read the curvature values of the adjacent points before and after the \(i\)-th point, and then divide the sum of the three by 3. For example, when \(\kappa\) i-1 = 0.55, \(\kappa\) i = 0.60, \(\kappa\) i+1 = 0.70, then
[0112] Steps for obtaining the parameter: Represents the average curvature of all points in the entire edge - sealing contour point set. When calculating, it is necessary to traverse all points and sum up their \(\kappa\) i and then divide by the number of points. For example, after uniformly measuring \(\kappa\) i for 1200 edge - sealing contour points, the sum \(T\) is obtained by successively adding these curvature values one by one, and then dividing by for equal division. If \(T = 684.0\), then
[0113] \(\kappa\) j Steps for obtaining the parameter: \(\kappa\) j Represents the local curvature value of the \(j\)-th edge - sealing contour point, where \(j\) takes the indices of \(i - 1\), \(i\), \(i + 1\), and is used to perform the sine mapping operation of local adjacent curvatures in the calculation of \(F\). To determine \(\kappa\) j it is necessary to read the curvatures at one position before and after the target point index \(i\). These curvature data have been stored in the steps for obtaining \(\kappa\) i above, and are managed in the form of a one - dimensional array or linked list. Just retrieve according to the index. For example, within the point index range 1..1200, when reading \(i = 100\), \(\kappa\) j includes \(\kappa\) 99 , \(\kappa\) 100 and \(\kappa\) 101 .
[0114] Steps for obtaining the \(max(\kappa)\) parameter: \(max(\kappa)\) represents the largest one among \(\kappa\) i-1 , \(\kappa\) i , \(\kappa\) i+1 and is used as a normalization factor in the numerator of the sine function of \(F\). The value - taking method is to compare these three values and select the largest one, denoted as \(max(\kappa)\). For example, when \(\kappa\) i-1 = 0.55, \(\kappa\) i = 0.66, \(\kappa\) i+1 = 0.70, then \(max(\kappa)=0.70\).
[0115] Steps for obtaining the \(\Delta x\) parameter: \(\Delta x\) represents the average Euclidean distance between adjacent points in the edge - sealing contour point set. By performing a full - contour scan on adjacent points \((x i,y i ) and (x i+1 ,y i+1 ) distance Perform pairwise calculations and accumulate them, then divide by the total number of adjacent points to obtain. To ensure the accuracy of Δx, it is necessary to count all possible edge point pairs during the detection process, eliminate abnormal points beyond the edge sealing range, and then calculate. For example, if 800 valid points are detected in a contour, there are 799 pairs of adjacent points. If the distances of each pair of adjacent points are summed to 1450.2 and then divided by 799, Δx = 1.815 is obtained.
[0116] Calculation process:
[0117] When κ i = 0.66, κ avg = 0.60, at this time, first calculate:
[0118] |κ i - κ avg | = |0.66 - 0.60| = 0.06;
[0119]
[0120] S = ln(1 + 0.109) = ln(1.109) ≈ 0.104;
[0121] If in the calculation of F, κ i-1 = 0.55, κ i = 0.66, κ i+1 = 0.70, max(κ) = 0.70 and Δx = 1.6, first calculate separately:
[0122]
[0123] The values are approximately {0.90, 0.97, 1.00}, and their sum is 2.87. Then divide by Δx = 1.6 to get:
[0124]
[0125] This result indicates that at the current i-th edge sealing contour point, the curvature sensitivity S ≈ 0.104 and the change frequency F ≈ 1.79. Among them, S can be used to measure the difference amplitude between the curvature of this point and the local mean value around it, and F is used to measure the fluctuation intensity of the curvature change before and after under a certain spatial step. When S exceeds 0.15, it means that the difference from the local is more obvious, and when F is greater than 1.5, it represents that the curvature changes significantly with space.
[0126] Combined with the curvature sensitivity and change frequency calculated previously, first, the edge contour points are scanned sequentially according to their order in the row and column coordinates. For each point, the S and F values of this point are read, and points belonging to a large curvature deviation or a large change amplitude are distinguished through a pre-determined threshold range. The selection of the threshold range is based on the S and F distribution of 1000 samples in statistical analysis. The mean values of all S and F and their standard deviations are extracted. The large deviation threshold is set as the mean value + 2 × standard deviation for comparison. When the S or F of a certain point exceeds this threshold, it is regarded as a change point and marked in the record. For the coordinate set of these marked change points, the adjacency judgment is continued. If the distance between adjacent change points is within 5 pixels, they are aggregated into the same change group, and an aggregation label is uniformly generated during the aggregation process to identify that there is a continuous curvature deviation or frequency jump between these change points. Based on this aggregation label, the subsequent merging scan is continued in the current contour point set. Through multiple rounds of scanning, the coordinates of points that are close to each other and belong to change points are integrated into a large-scale aggregation area. Statistics are carried out under the corresponding label of each aggregation area to form a set of change points with the same or similar curvature deformation characteristics. Finally, all change point sets are merged and stored. When storing, they are sorted according to the row and column coordinates, and the quantity and extreme value information of this change point set are noted. After completing this operation, the set of key geometric feature points of the edge can be obtained.
[0127] The steps to obtain the edge geometric topology structure are as follows:
[0128] Based on the set of key geometric feature points of the edge and the edge contour point set, all key geometric feature points of the edge are traversed to determine their relative positions in the edge contour point set, and different regions are divided according to the distribution characteristics of the points. The connectivity between points in each region is calculated to generate a preliminary edge point connection relationship.
[0129] According to the preliminary edge point connection relationship, the edge points are classified, the geometric relationship between adjacent points is judged, the point sets that can be fitted by a straight line or an arc are screened, the point sets that meet the straight line fitting conditions are merged into straight line segments, the point sets that meet the arc fitting conditions are merged into arc segments, and the node attributes of the straight line segments, arc segments, and corner points are marked to form edge structure units.
[0130] Based on the edge structure units, the straight line segments, arc segments, and corner points are topologically connected according to the adjacency relationship to form an edge geometric topology structure.
[0131] Specifically, based on the obtained set of key geometric feature points for edge sealing and the set of edge-sealing contour points, first read the coordinate indices of all key geometric feature points and correspond them one by one with the coordinates recorded in the edge-sealing contour point set. Mark the positions of the key geometric feature points as reference points in an index list. Subsequently, according to the distribution ranges of the points in the horizontal and vertical directions, divide the overall edge-sealing contour into several regions. The division of each region requires a pre-set distance threshold based on the survey results. For example, by sampling and measuring 300 similar edge-sealing images, calculate the average adjacent distance between key geometric feature points and set the threshold between 20 pixels and 50 pixels based on this. If the horizontal or vertical coordinate difference between two feature points does not exceed the set value according to this threshold, they are regarded as in the same region; otherwise, they are divided into adjacent regions. Then, read all the points in the edge-sealing contour that fall within the range of each region to form a regional point set and perform connectivity calculation based on the coordinate differences. The connectivity calculation can be carried out by comparing the row and column differences between any two points. If the absolute value of the row and column difference is less than 10 and the proximity determination is satisfied, give the interconnection identifier of the two in the record. Traverse all the points in each region and merge all the interconnection identifiers to obtain the connectivity grouping list within each region. Then, summarize these connectivity grouping records to obtain the preliminary edge-sealing point connection information. After completing the connectivity analysis, mark the region number to which each point belongs and the level of the connectivity relationship in the index information. Finally, summarize the connectivity records of all regions to generate the preliminary edge-sealing point connection relationship.
[0132] According to the preliminary edge-sealing point connection relationship obtained previously, read the edge point coordinates in each connectivity grouping and determine the geometric relationship between adjacent points. First, perform a least-squares principle-based straight-line fitting calculation for any three points in each connectivity grouping to obtain a predicted straight line and evaluate the deviation of the points from the predicted straight line during the calculation process. Record the points with a deviation exceeding 3 pixels in the error set. Then, judge whether the connectivity grouping can be regarded as a straight line segment as a whole according to the proportion of the number of points in the error set and the distribution characteristics. If the proportion of the number of points in the error set is less than 10%, mark this grouping as a straight line segment and write the start and end point coordinates and length data of the straight line segment in the record. If the proportion of the number of points in the error set is greater than or equal to 10%, continue with the arc fitting analysis. Perform a point-by-point detection of the grouping points through a pre-set arc or elliptical arc evaluation method. If the average arc radius and deviation degree obtained after substituting all points into the arc fitting function are within the range of past experience, for example, the arc radius is between 30 pixels and 120 pixels and the deviation degree does not exceed 4 pixels as statistically obtained from 200 similar edge-sealing images, mark this grouping as an arc segment, and mark the individual points with too large curvature in the grouping as corner points. After completing the attribute marking of the straight line segment, arc segment, and corner points, write the corresponding structure information and number for each grouping in the record to form an edge-sealing structure unit.
[0133] Based on the previously determined edge-sealing structure units, first read all the marked straight line segments, arc segments, and corner points in the connectivity relationship, sort their starting points, ending points, and corner point coordinates in index order, and then search for the connection positions between adjacent structure units. During the search, traverse the end coordinates of each structure unit and find the starting coordinates of other structure units in the overall record whose distance from this coordinate does not exceed 5 pixels. To accurately judge the connection relationship, calculate the row and column differences for each potential connection point respectively. If the row and column differences are between 3 and 5 pixels, consider them as adjacent relationships and establish topological edge records for the two in the index list. At the same time, write the connection point coordinates into the connection list for subsequent counting of the out-degree of each structure unit and the corresponding number of corner points. After traversing all the structure units, merge and summarize the straight line segments, arc segments, and corner points with established topological edge records, and append the associated connectivity attributes to the record. If it is found during the search that a certain corner point satisfies the connection conditions with two or more structure units, write the corner point index into the connection fields of the corresponding multiple units, so as to show its geometric characteristics of multi-directional connection in subsequent statistics. Finally, after all the structure units have completed the compilation of connection information, output the summary result according to the adjacency relationship to form the edge-sealing geometric topology structure.
[0134] The steps for obtaining the set of edge-sealing color statistical moments are as follows:
[0135] Extract the pixel values of the RGB color channels from the edge-sealing area of the packaging and encapsulation image, and form independent data sets for each color channel respectively;
[0136] For the independent data sets, calculate the kurtosis value, and the calculation formula is:
[0137]
[0138] where K′ is the kurtosis value, n is the number of data points, x t is the color value of the nth data point pixel, is the average value of the color values, s is the standard deviation, and m is the median of the color values;
[0139] Integrate the kurtosis values calculated for each color channel to construct the set of edge-sealing color statistical moments, and obtain the set of edge-sealing color statistical moments.
[0140] Specifically, extract the pixel values of the RGB color channels from the edge area of the packaging and encapsulation image. First, read each pixel coordinate in the image and determine the edge area to which it belongs. Pixels not within the edge area range are not included in subsequent statistics. Then, classify and summarize all pixels within the edge area according to the data of the R, G, and B channels respectively to form three independent data sets. Read the corresponding pixel color values in each data set and organize them in the order of pixel coordinates. Obtain the numerical distribution of each pixel under the R, G, and B channels through a single scan process. To ensure the consistency of sampling, a reference pixel interval threshold is set. For example, when the difference in pixel row and column coordinates is between 5 and 10, it is further added to the statistical set. These thresholds are comprehensively set based on the average value and standard deviation obtained from measuring 2000 similar types of packaging and encapsulation images in the past. The average value of the row and column difference is about 7, and the standard deviation is about 1.5. Accordingly, a threshold range with a fluctuation of about 1.5 is determined to ensure that a sufficient number of pixels are read at the same spatial density level to support kurtosis calculation. After pixel sampling, perform row and column index alignment operations on the three data sets respectively, sort out the total number of data points n and the color value sequence for each. Record the index of each data point under the row and column coordinates and the color value of the pixel. At the same time, in order to calculate the median m later, all color values need to be sorted, and then the index position of the median is extracted after sorting. If n is odd, directly select the th color value as m. If n is even, select the th and th color values and take their average as m. During the statistical process, outliers that deviate from the effective range can be excluded. For example, pixels whose RGB values are not between 0 and 255 or are significantly affected by noise are excluded. After exclusion, recalculate the size of the total number n and apply it together in subsequent processing. Finally, after obtaining the three independent data sets, prepare the calculation results of the average value and standard deviation for each data set and the obtained median m to obtain the data sets corresponding to the three channels.
[0141] Formula: The benefit of the formula is that it introduces two key factors. One is to divide by s 4 to measure the degree of dispersion in the area near and far from the average value. The other is to introduce the tan(…) function in the second half, normalize the sum of the cubes of the distances from the median and embed it into the evaluation of the overall kurtosis. In this way, while retaining the perception of the tail thickness by the traditional kurtosis, it also takes into account the characteristics of the data distribution at the median;
[0142] Steps for obtaining the n parameter: n represents the number of data points, which here refers to the number of pixels belonging to a certain color channel in the edge-sealing area. When obtaining it, the previously extracted color value sequence will be statistically analyzed and the final quantity will be recorded. If noise pixels or invalid pixels are excluded, it is necessary to ensure that n is updated after the statistics to match the actual valid pixel data participating in the calculation. For example, 4200 pixels are detected in the R channel for preliminary sampling. After excluding 30 invalid data points, then n = 4170.
[0143] x t Steps for obtaining the parameter: x t represents the color value of the nth data point pixel. To obtain x t it is necessary to scan the previously extracted R or G or B channel data set according to the row and column indices and sequentially read the color values of each pixel. After the scanning is completed, these color values will be placed in an array in order for subsequent operations, and at the same time, outliers not within the range of 0 to 255 or data points that are significantly inconsistent with the actual camera range will be excluded. After completion, a sequence in one-to-one correspondence between the index and x t is obtained. For example, x 100 is the color value of the 100th valid pixel.
[0144] Steps for obtaining the parameter: represents the average value of the color values. The obtaining method is to sum all x t in the current data set and then divide by n. If there are n valid pixel values x1, x2,..., x n in the same channel, then In a single sample collection, for example, if the sum of 3000 valid pixel values in the G channel is 384000, then
[0145] Steps for obtaining the s parameter: s represents the standard deviation of the color values, which is used to measure the degree of dispersion of the color values around the average value. The calculation formula is After statistically analyzing the pixel data, for each x t the square of the difference from is calculated and then summed and divided by n, and finally the square root is taken to obtain s. For example, in the measurement of the R channel, if the sum of the squared differences for the sampled 3500 pixels is approximately 441500, then
[0146] Steps for obtaining the m parameter: m is the median of the color values, which is used to characterize the median position in the current data set. To obtain m, it is necessary to sort all x t If n is odd, directly select the value corresponding to the position If n is even, take and The average color value of the position. For example, in the B channel, if n = 4200, then Read the color values at the 2100th and 2101st positions after sorting and take the average to get m. If the color values at these two positions are 118 and 119 respectively, then m = (118 + 119) / 2 = 118.5.
[0147] Calculation process:
[0148] For example, in a certain calculation in the R channel, first get n = 4000, s = 10.5, m = 123, and then take out all x t Substitute into Assume the result is 2.80×10 7 , substitute into s 4 =(10.5) 4 = 10.5×10.5×10.5×10.5≈12276.56. At this time:
[0149]
[0150] Then calculate
[0151] Assume it is 1.44×10 7 , divide it by n·s 3 = 4000×(10.5) 3 = 4000×1157.625 = 4630500, and the result is approximately 3.11. Therefore, there is:
[0152] tan(3.11)≈ -0.041;
[0153] (The reason why tan(3.11) is negative is that 3.11 is approximately equal to 178.2°, which corresponds to the negative-positive alternating area in the radian range. It should be noted that the angle is around π). After multiplying with the previous 2280.99, first execute (1 + tan(3.11))≈0.959. Thus, comprehensively obtain: K ′ = 2280.99×0.959≈2188.40.
[0154] The result shows that the kurtosis value of the current sample under the R channel is approximately 2188.40, indicating that both the outlier degree and deviation degree of the color distribution in the sample have relatively high numerical manifestations. This is of great reference significance for screening the effective color range of this channel in the follow-up. If the kurtosis value needs to be compared in the future, it can be compared with the set threshold. For example, referring to the kurtosis distribution of the R channel of 300 previously measured images of the same type, the median kurtosis is in the range of approximately 1800 to 2200. The value of 2188.40 indicates that the current distribution is still at a relatively high but acceptable kurtosis range. If it exceeds 2200, it is considered to have an obvious peak tendency. If it is lower than 1800, it is considered to have an overly smooth distribution.
[0155] Integrate the kurtosis values measured separately for the three channels. First, extract the previously calculated kurtosis values for the R channel, G channel, and B channel respectively and record them. Then, when summarizing, compare them according to the corresponding edge-sealing area index. If the number of pixels n in some channels is insufficient or the kurtosis value far exceeds the predetermined standard, the abnormal distribution of this part can be noted in the list. List all the kurtosis information in the form of channel grouping and append the threshold judgment process of the kurtosis value to the record. Compare the kurtosis value of each channel with the mean interval of the kurtosis distribution obtained based on statistics before. If it is higher or lower than this interval, it is regarded as a suspicious distribution. If it is within the interval, it remains in the normal state. Subsequently, sort the kurtosis values of each channel centrally and mark the corresponding edge-sealing area numbers, so as to be able to distinguish the color kurtosis characteristics of different edge-sealing areas during output. Finally, form an edge-sealing color statistical moment set and write it into the data structure used in the subsequent analysis stage.
[0156] The steps to obtain the evaluation result of the edge-sealing topological structure deviation are as follows:
[0157] Extract the connectivity between nodes, the number of closed paths, and the number of branches at each corner point from the edge-sealing geometric topology structure. Construct an edge-sealing graph structure by traversing the node set and edge set to form a standardized topological feature group;
[0158] Based on the standardized topological feature group, combined with the number of edge-sealing contour edges, the number of closed loops, the number of abnormal branches, the out-degree of corner points, and the structural direction angle, calculate the topological structure deviation amount. The calculation formula is:
[0159]
[0160] Among them, D is the topological structure deviation amount, a is the number of edges in the edge-sealing graph, a s is the number of edges in the template edge-sealing graph, b is the number of closed paths, b s is the number of standard closed paths, c is the number of abnormal branches, c s is the number of branches of the template, φ is the structural direction angle between nodes, φ s is the template structural direction angle, gk is the average out-degree of corner points, gk sis the average out-degree of the template corner points;
[0161] According to the topological structure deviation amount, set the range of the structure complexity threshold, determine the deviation of the edge-sealing geometric topology structure, identify whether there is an abnormality, and obtain the evaluation result of the edge-sealing topology structure deviation.
[0162] Specifically, extract the connectivity relationship between nodes, the number of closed paths, and the number of branches of each corner point from the edge-sealing geometric topology structure. First, read the coordinate information of nodes and edges item by item according to the node table and edge table already established in the data record. Then, retrieve the index of each node one by one and confirm the number of connections between it and other nodes in the record. Record these connection times as the connectivity degree and write them into the intermediate data list. Then, judge whether any two edges form a closed loop. If some edges form a closed loop with the same or different edges at the head and tail nodes, add the number of the closed loop to the record and count the number of its edges. Store the node indexes forming the loop and the corresponding total number of edges for each closed loop. By scanning all nodes and all edges, find out how many closed paths can be retrieved and calculate how many nodes these paths contain. If two paths share a node, mark this node. The purpose of marking is to distinguish the reused nodes or edges during subsequent statistics. On the other hand, the statistics of the corner points and their number of branches can be identified by querying the corner point attributes recorded in the node table. For any node marked as a corner point, add 1 to the count of the number of branches. If this corner point is connected to multiple edges at the same time, increase the out-degree count. Repeat traversing the entire node table to completely record the number of closed paths and the number of branches of each corner point. After the traversal, summarize the connectivity between nodes, the number of closed paths, and the number of branches of all corner points in the intermediate data table, providing sufficient information for the next step of constructing the edge-sealing graph structure. Subsequently, based on this information, construct the edge-sealing graph structure. During the construction process, pair all interconnected edges according to the node indexes and write them into the graph structure entries, and separately identify any path forming a closed loop to indicate that this path has the closed property. Store the number of branches of the corner points in the additional attribute field to generate the standardized topological feature group.
[0163] Formula: The advantage of the formula is that it combines the number of edges, the number of closed paths, the number of abnormal branches, the structural direction angle between the corner points, and the average out-degree in the edge-sealing graph into the same calculation framework. By performing difference and multiplication operations on multiple spatial topological features, it can effectively measure the overall deviation degree between the current edge-sealing geometric topology structure and the template;
[0164] a and a s The steps for obtaining the parameters are as follows: a is the number of edges in the edge-sealing graph, a s is the number of edges in the template edge-sealing graph. When obtaining it, the constructed edge-sealing graph structure can be directly read in the previous steps, and a can be obtained by comparing the total value of the number of edges in the node table and the edge table. And a sRecord of the number of edges from the edges of the edge-sealing template. For example, in a production inspection, if it is known that the edge-sealing diagram of the template has 50 edges, then a s = 50. After traversing the current edge-sealing diagram, it is found that there are 48 edges in total, then a = 48;
[0165] b and b s The steps to obtain the parameter are: b is the number of closed paths, b s is the number of standard closed paths. The reading method is to check all the closed-loop statistics marked during the construction of the edge-sealing diagram structure. If 4 closed loops are detected in a certain edge-sealing diagram, then b = 4. If 5 are recorded in the template edge-sealing diagram, then b s = 5.
[0166] c and c s The steps to obtain the parameter are: c represents the number of abnormal branches, c s represents the number of template branches. The determination method is to confirm the redundant branches that do not conform to the design or expectation during the previous node traversal. If a certain node should originally have an out-degree of 2 but an out-degree of 3 or more appears during the detection, the extra branches can be regarded as abnormal branches. After counting all nodes and then accumulating the results, c is obtained. The c in the template diagram s is determined according to the number of branches allowed in the standard design. For example, when the template stipulates that 2 redundant connection points can appear, c s = 2. If the actual detection result is 3, then c = 3;
[0167] φ and φ s The steps to obtain the parameter are: φ represents the structural direction angle between nodes, which is obtained by calculating the directions of adjacent straight line segments or arc segments during detection. Usually, after calculating the direction vectors of the edges corresponding to the out-degree of each node, the direction value represented by the node is obtained using the plane vector angle formula, and then the overall structural direction angle φ is obtained after averaging or screening all nodes. φ s comes from the direction record of the template edge-sealing diagram. For example, in the standard edge-sealing style, the average direction vector angle between multiple key points is statistically obtained to obtain φ s , if it is measured that φ = 105°, φ s = 90°, it means there is a 15-degree difference between the two;
[0168] gk and gk s The steps to obtain the parameter are: gk represents the average out-degree of corner points, gk s represents the average out-degree of template corner points. When calculating, first select the node list marked as corner points from the node table, and then count the number of connections between these corner points and other nodes one by one, and average these numbers to obtain gk. The template value gk sIt comes from the existing corner point out-degree statistics or theoretical design values in the edge-sealing template. For example, after statistics, the average out-degree of 20 corner points in the current edge-sealing graph is 2.2, and the average out-degree value of the template is 2.0. Then gk = 2.2, gk s = 2.0;
[0169] Calculation process:
[0170] Substitute the example values: a = 48, a s = 50, b = 4, b s = 5, c = 3, c s = 2, φ = 105°, φ s = 90°, gk = 2.2, gk s = 2.0;
[0171] First, calculate the differences item by item:
[0172] (a - a s ) = 48 - 50 = -2, (b - b s ) = 4 - 5 = -1, (c - c s ) = 3 - 2 = 1;
[0173]
[0174] (gk - gk s ) = 2.2 - 2.0 = 0.2;
[0175] Substitute the above values respectively:
[0176] (a - a s ) 2 +(b - b s ) 2 +(c - c s ) 2 = (-2) 2 + (-1) 2 + 1 2 = 4 + 1 + 1 = 6;
[0177]
[0178] Then take the square root:
[0179] The result shows that the topological structure deviation amount D between the current edge-sealing geometric topology and the template is approximately 2.45. If the allowable range for the deviation amount is set from 1.5 to 3.0, it means it is still within the predetermined standard. If it exceeds 3.0, it is considered that the topological structure seriously deviates.
[0180] According to the topological structure deviation obtained previously, first read the D value of the current edge-sealing geometric topology structure in the record, and then compare it with the set range of structure complexity thresholds. This threshold range can be obtained by summarizing several intervals after performing deviation measurements on 100 typical edge-sealing graph samples. For example, if the mean value of D in the measurement samples is 2.3 and the standard deviation is about 0.5, then the normal deviation interval is determined to be 1.5 to 3.3. When comparing the current D value, if it falls within the interval, it remains in the normal state. If it is less than 1.5, it indicates a high degree of structural simplification. If it is greater than 3.3, it indicates a large structural deviation. After completing this comparison, write the corresponding determination result into a mark in the index list. Subsequently, retrieve all the graph structures that are out of range and output the record of their node numbers, the number of edges, and the deviation degree. Finally, summarize these results to obtain the edge-sealing topological structure deviation evaluation result.
[0181] The steps to obtain the encapsulation defect determination information are as follows:
[0182] Based on the edge-sealing topological structure deviation evaluation result and the edge-sealing color statistical moment set, perform item-by-item matching analysis of the structural and color two-dimensional attributes, extract the coordinate correlation positions of the edge-sealing boundary structure feature points and the color kurtosis, mark the topological structure identifiers corresponding to each point, and compare the topological position range, tolerance type, and color channel kurtosis threshold of the topological structure identifier under the standard template to generate the edge-sealing structure and color combined deviation analysis result;
[0183] Based on the edge-sealing structure and color combined deviation analysis result, extract the structural anomaly type, the color channel anomaly intensity, and the corresponding channel number to generate the encapsulation defect determination information.
[0184] Specifically, based on the edge banding topology structure deviation evaluation results and the edge banding color statistical moment set, first read all the topological position identifiers and the corresponding deviation amount information recorded in the deviation evaluation results, and summarize the kurtosis values of each channel in the edge banding color statistical moment set. Then, perform point-by-point matching according to the index order to retrieve the correlation between the edge banding boundary structure feature points in terms of topological structure identifiers and color kurtosis distributions. To achieve this matching process, it is necessary to first find the coordinates of the feature points in the list and read their node numbers or corner markers in the topological structure record, and then compare the coordinates with the edge banding color statistical moment set. If the row and column coordinate differences between the two are within 3 to 5 pixels, it is considered that the feature point spatially corresponds to this kurtosis value. Group all the matching entries that meet the conditions according to the feature point index, and register the successfully matched feature points, topological identifiers, and color kurtosis into a new analysis list. Subsequently, perform item-by-item comparison of the topological identifier range and color threshold in combination with the corresponding records of the standard template. The topological identifier range can be obtained in advance by measuring the key geometric positions of the template, and the color threshold can be determined through statistical analysis of multi-batch test data. For example, when measuring the kurtosis of 500 images of the same type of edge banding area, the average kurtosis is extracted to be about 2400 and the standard deviation is calculated to be about 300, so 2100 to 2700 is selected as the preset threshold range. Then, during the point-by-point comparison process, if the color kurtosis of a certain feature point is below 2100 or exceeds 2700, it is regarded as a suspicious distribution. If the coordinate difference between the topological identifier and the template is greater than 5 pixels or exceeds the error of two adjacent sides, it is regarded as a deviation in the topological range. Each time a deviation is detected, it is written into the deviation comparison result and the specific position and the channel number to which it belongs are recorded. Through such a comparison process, parallel analysis of the structure and color dimensions is realized, and finally the combined deviation analysis result of the edge banding structure and color is obtained.
[0185] Based on the combined deviation analysis results of the edge-sealing structure and color, first find all the entries marked as suspicious distributions in the list that has been compared, and read the characteristic point coordinates and the corresponding channel numbers in these entries. Then, perform grading according to the topological structure and the kurtosis difference degree of the color recorded respectively. To more intuitively display the degree of abnormality, the method of introducing intensity scores can be used during the comparison. For example, when the deviation in the structural direction exceeds 10 degrees or the out-degree of the corner points increases by more than 1, it is recorded as the structural abnormality level 2. If only a small number of edge number differences occur, it is recorded as the structural abnormality level 1. In the color channel, if the kurtosis value deviates from the preset threshold range of 2100 to 2700, it can be quantified as the color abnormality level according to the deviation amplitude and the corresponding value is recorded. When both of these two levels are greater than 0, the combined abnormal category is obtained. Then, list the abnormal entries uniformly in combination with the channel numbers, read each abnormal type and append the specific color channel number to the back of this abnormal type to identify whether it is the R channel, the G channel, or the B channel that has a deviation intensity. If there are multiple channel numbers, it means that the kurtosis distributions of multiple channels all fall within the abnormal range. At this time, write down the channel numbers and the corresponding abnormal intensities in one go in the record. Through such itemized screening, the encapsulation defect determination information can be obtained. In the defect determination information, list in detail the sources and index positions of each structural abnormality and color channel abnormality, which is convenient for subsequent further statistics or more detailed processing.
[0186] The above is only the preferred embodiment of the present invention, and it does not limit the present invention in other forms. Any person skilled in the art may use the technical content disclosed above to make changes or modifications into equivalent embodiments with equivalent changes and apply them to other fields. However, as long as it does not depart from the technical solution content of the present invention, any simple modification, equivalent change, and modification made to the above embodiments based on the technical essence of the present invention still fall within the protection scope of the technical solution of the present invention.
Claims
1. A packaging and encapsulation detection method based on image processing, characterized in that, Including the following steps: Obtain the packaging and encapsulation image to be detected, smooth the packaging and encapsulation image, calculate the gradient intensity of the smoothed image at each pixel point, perform non-maximum suppression to screen potential edge points, and obtain a set of gradient edge points; Based on the set of gradient edge points, determine strong and weak edges and connect the disconnected edges to establish a set of edge contour points; Based on the set of edge contour points, calculate the local curvature of each point position, identify the changing point positions, and obtain a set of key geometric feature points of the edge; Based on the set of key geometric feature points of the edge and the set of edge contour points, connect the edge points to fit straight line segments and arc segments, and use the straight line segments, arc segments, and corner points as nodes and the adjacency relationship as edges to construct an edge geometric topology structure; For the packaging edge area of the packaging and encapsulation image, extract the color channel values of the pixels, calculate the kurtosis value within the packaging edge area, and obtain a set of edge color statistical moments; Based on the edge geometric topology structure, compare the corresponding topological attributes of connectivity, closed loop, and branch point attributes with the standard packaging edge template, determine the disconnection and abnormal branch situations in the graph, obtain the edge topology structure deviation evaluation result, and based on the edge topology structure deviation evaluation result and the set of edge color statistical moments, compare the deviation degree of the kurtosis value from the corresponding kurtosis value range of the standard sample to generate packaging defect determination information.
2. The method for detecting packaging and encapsulation based on image processing according to claim 1, wherein The steps for obtaining the set of gradient edge points are as follows: Obtain the packaging and encapsulation image to be detected, perform pixel smoothing on the image, and generate a smoothed packaging and encapsulation image; Based on the smoothed packaging and encapsulation image, calculate the gradient intensity of each pixel point, and the calculation formula is: where Q is the gradient strength, A x represents the gray-scale gradient change of adjacent pixels in the horizontal direction, A y represents the gray-scale gradient change of adjacent pixels in the vertical direction, B x represents the second-order gradient in the horizontal direction, B y represents the second-order gradient in the vertical direction; Based on the gradient intensity, apply non-maximum suppression for edge point screening to form a set of gradient edge points.
3. The packaging and encapsulation detection method based on image processing according to claim 1, wherein, The steps for obtaining the set of edge contour points are as follows: Based on the set of gradient edge points, classify the edge points to generate a hierarchical edge point classification result; For the hierarchical edge point classification result, calculate the Euclidean distance and angle from each point to the center of the adjacent point set, calculate the local connection strength of the edge points, and the calculation formula is: Among them, L is the local connection strength of the edge point, ck is the number of adjacent points around the edge point, P i represents the coordinates of the i-th edge point, C is the geometric center of the adjacent point set, σ is the standard deviation of the edge point coordinates, θ i is the point P i with respect to the angle of C; Apply the local connection strength to optimize the connection between edge points, adjust the disconnected edges, form a continuous edge contour, and form a set of edge contour points.
4. The packaging and encapsulation detection method based on image processing according to claim 1, wherein The steps for obtaining the set of key geometric feature points of the edge are as follows: Based on the set of edge contour points, calculate the curvature for each point position, calculate the local curvature value of each point based on the coordinates of each point and its directly adjacent points, and obtain a curvature data set; Based on the curvature data set, calculate the curvature sensitivity and change frequency of each point, and the calculation formulas are: and Among them, S represents the curvature sensitivity of the i-th edge contour point, F represents the change frequency of the i-th edge contour point, κ i represents the local curvature value of the i-th edge contour point, κ avg represents the average value of the local curvature values of the three edge contour points i-1, i, and i+1, represents the average curvature value of all points in the entire edge contour point set, κ j represents the local curvature value of the j-th edge contour point, max(κ) represents the maximum value of the local curvature values among the three points centered on the i-th point, and Δx represents the average value of the Euclidean distances between adjacent points in the edge contour point set; Combining the curvature sensitivity and change frequency, identify the changing points, and aggregate the changing points to form a set of key geometric feature points of the edge.
5. The packaging and encapsulation detection method based on image processing according to claim 1, wherein The steps for obtaining the edge geometric topology structure are as follows: Based on the set of key geometric feature points of the edge and the set of edge contour points, traverse all the key geometric feature points of the edge, determine their relative positions in the set of edge contour points, divide different regions according to the distribution characteristics of the points, calculate the connectivity between points in each region, and generate a preliminary edge point connection relationship; Classify the edge points according to the preliminary edge - point connection relationship, judge the geometric relationship between adjacent points, filter out the point sets that can be fitted by straight lines or arcs, merge the point sets that meet the straight - line fitting conditions into straight - line segments, merge the point sets that meet the arc - fitting conditions into arc - line segments, and mark the node attributes of the straight - line segments, arc - line segments and corner points to form an edge - sealing structure unit; Based on the edge - sealing structure unit, topologically connect the straight - line segments, arc - line segments and corner points according to the adjacency relationship to form an edge - sealing geometric topology structure.
6. The packaging and encapsulation detection method based on image processing according to claim 1, characterized in that, The steps for obtaining the edge - sealing color statistical moment set are as follows: Extract the pixel values of the RGB color channels from the edge - sealing area of the packaging and encapsulation image, and form independent data sets for each color channel respectively; For the independent data sets, calculate the kurtosis value, and the calculation formula is: where K′ is the kurtosis value, n is the number of data points, x t is the color value of the nth data point pixel, is the average value of the color values, s is the standard deviation, and m is the median of the color values; Integrate the kurtosis values calculated for each color channel, construct an edge - sealing color statistical moment set, and obtain the edge - sealing color statistical moment set.
7. The packaging and encapsulation detection method based on image processing according to claim 1, characterized in that The steps for obtaining the evaluation result of the edge - sealing topology structure deviation are as follows: Extract the connectivity relationship between nodes, the number of closed paths and the number of branches of each corner point from the edge - sealing geometric topology structure, construct an edge - sealing graph structure by traversing the node set and the edge set, and form a standardized topological feature group; Based on the standardized topological feature group, combined with the number of edge - sealing contour edges, the number of closed loops, the number of abnormal branches, the out - degree of corner points and the structural direction included angle, calculate the topological structure deviation amount, and the calculation formula is: Among them, D is the topological structure deviation, a is the number of edges in the edge sealing diagram, a s is the number of edges in the template edge sealing diagram, b is the number of closed paths, b s is the number of standard closed paths, c is the number of abnormal branches, c s is the number of branches of the template, φ is the structural direction angle between nodes, φ s is the template structural direction angle, gk is the average out-degree of corner points, gk s is the average out-degree of template corner points; According to the topological structure deviation amount, set the range of the structure complexity threshold, conduct deviation determination on the edge - sealing geometric topology structure, identify whether there are abnormalities, and obtain the evaluation result of the edge - sealing topology structure deviation.
8. The packaging and encapsulation detection method based on image processing according to claim 1, characterized in that The steps for obtaining the packaging defect determination information are as follows: Based on the evaluation result of the edge - sealing topology structure deviation and the edge - sealing color statistical moment set, conduct item - by - item matching analysis of the structural and color two - dimensional attributes, extract the coordinate correlation positions of the edge - sealing boundary structure feature points and the color kurtosis, mark the topological structure identifiers corresponding to each point, and compare the topological position range, tolerance type and color - channel kurtosis threshold of the topological structure identifiers under the standard template to generate a combined deviation analysis result of the edge - sealing structure and color; Based on the combined deviation analysis result of the edge - sealing structure and color, extract the structural abnormality type, the abnormal intensity of the color channel and the corresponding channel number to generate packaging defect determination information.
9. The packaging and encapsulation detection system of the packaging and encapsulation detection method based on image processing according to any one of claims 1-8, characterized in that, Including: An image acquisition module, which receives the packaging and encapsulation image to be detected, stores it in the memory, and obtains the original image data; An image pre - processing module, which performs smoothing processing on the original image data, calculates the gradient intensity of each pixel point, filters out potential edge points, and generates a gradient edge - point set; An edge connection module, which identifies and connects the disconnected edges from the gradient edge - point set, determines the strong and weak edges through the gradient change, constructs an edge - sealing contour, generates an edge - sealing contour point set, calculates the local curvature of each point, identifies key geometric feature points, and obtains an edge - sealing key geometric feature point set; A geometric structure analysis module, which based on the edge - sealing key geometric feature point set and the edge - sealing contour point set, connects the edge points to fit straight - line segments and arc - line segments, establishes a geometric topology structure, and generates an edge - sealing geometric topology structure; The defect detection and evaluation module extracts the pixel color channel values in the edge-sealing area based on the edge-sealing geometric topology structure, calculates the kurtosis value, compares it with the standard edge-sealing template, evaluates the disconnection and abnormal branch conditions, and generates encapsulation defect determination information in combination with the color statistical data.
Citation Information
Cited By
Edge sealing control method, device and equipment for gypsum plaster board and medium
CN120791966A