Product quality control method and system based on machine vision

By calculating the grayscale gradient and multi-scale texture changes on the product surface and adjusting the position of boundary points, accurate classification of complex defects is achieved, solving the problem of limited detection sensitivity in existing technologies and improving the accuracy and stability of detection.

CN120997124AInactive Publication Date: 2025-11-21长春科技学院
View PDF 0 Cites 8 Cited by

Patent Information

Application Number
CN202510936885.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-07-08
Publication Date
2025-11-21
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

Existing machine vision-based product quality inspection methods are ill-suited to complex textures and subtle structural variations. Defect region screening is based on single-scale analysis, which limits detection sensitivity, leads to boundary positioning bias, and results in insufficient classification accuracy.

Method used

By calculating the grayscale gradient value of the product surface, extracting the grayscale gradient change rate, generating a multi-scale texture mutation point set, calculating the directional consistency mutation region, adjusting the boundary point position, and classifying defect types by combining gradient distribution patterns.

Benefits of technology

It improves the accuracy of identifying defective areas in products, enhances the ability to distinguish complex defects, reduces false detections and missed detections, and ensures the stability and adaptability of automated quality inspection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120997124A_ABST
    Figure CN120997124A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of quality detection, in particular to a product quality control method and system based on machine vision, and the method comprises the following steps: obtaining product surface image data, calculating the gray gradient value of each pixel, extracting the gray gradient change rate, recording the gradient amplitude and direction information, and generating product surface gradient data. According to the method, through pixel-level gray scale gradient calculation, the product local feature expression ability is improved, multi-scale gradient change trend analysis is combined, the accurate recognition ability of a product defect area is improved, through texture direction angle calculation and vector field construction, the direction change anomaly detection reliability is enhanced, and the direction change anomaly detection accuracy is improved based on the combination of a direction deviation accumulated value and an abrupt change threshold value. Effective identification of a structure sudden change area is ensured, adjustment is carried out for curvature continuity abnormal points, defect boundary fitting precision is optimized, defect area internal gradient distribution and boundary feature comparative analysis are carried out, accurate classification of defect types is realized, and stability and adaptability of automatic product quality detection are ensured.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of quality inspection technology, and in particular to a product quality control method and system based on machine vision. Background Technology

[0002] The field of quality inspection technology encompasses quality assessment, defect detection, dimensional measurement, and surface analysis for various products and materials. It is widely applied in manufacturing, electronics, automotive, food processing, and many other industries. Its core content involves utilizing physical principles such as optics, acoustics, radiation, and magnetism, along with computer processing technology, to evaluate product quality and ensure compliance with set standards. Traditional quality inspection methods primarily rely on manual visual inspection or mechanical measuring tools such as calipers, micrometers, and flaw detectors. However, these methods suffer from low efficiency, high subjectivity, and limited applicability. With the development of technologies such as computer vision, image processing, and pattern recognition, automated quality inspection technology based on machine vision is gradually becoming an important direction in this field, helping to improve inspection accuracy and efficiency.

[0003] Machine vision-based product quality control methods utilize computer vision technology to inspect and analyze a product's appearance, shape, color, size, and defects to determine if its quality meets set standards. Typically, industrial cameras or line scan cameras are used to acquire product images, and image preprocessing methods such as noise removal, grayscale transformation, and edge detection are applied to enhance target features. Subsequently, template matching or deep learning classifiers are used to identify product features, and feature vector calculations are used to analyze shape, size, or color deviations to determine if the product has defects or is unqualified. Furthermore, this method may combine optical character recognition technology to extract identification information or employ multispectral imaging to detect latent defects, thereby achieving comprehensive product quality inspection.

[0004] Current product quality inspection and control processes rely on fixed templates or rules for surface feature extraction, which struggles to adapt to complex textures and subtle structural variations, limiting detection sensitivity. Defect region selection is typically based on single-scale analysis, failing to handle gradient changes across different scales and easily leading to boundary localization errors. For identifying structural abrupt changes, existing methods largely depend on global statistical information, failing to fully utilize local directional consistency features, thus affecting the detection accuracy of abrupt change regions. During boundary fitting, the adjustment mechanism for curvature anomalies is relatively simplistic, resulting in defect boundary morphology deviations and impacting classification accuracy. Defect type differentiation relies on shape, size, or color features, failing to adequately consider gradient patterns and curvature change trends, resulting in insufficient generalization ability in complex defect identification and affecting the comprehensiveness of product quality assessment. Summary of the Invention

[0005] The purpose of this invention is to address the shortcomings of existing technologies by proposing a product quality control method based on machine vision.

[0006] To achieve the above objectives, the present invention adopts the following technical solution: a product quality control method based on machine vision, comprising the following steps:

[0007] S1: Acquire product surface image data, calculate grayscale gradient value of each pixel, extract grayscale gradient change rate, record gradient magnitude and direction information, and generate product surface gradient data.

[0008] S2: Based on the product surface gradient data, calculate the gradient change trend, statistically analyze the changes in the local gradient change rate, extract points with sudden increases in change rate, calculate the standard deviation change rate to screen out anomalies and mark potential defect areas, and generate a multi-scale texture mutation point set.

[0009] S3: Based on the multi-scale texture mutation point set, calculate the key texture direction angle of the region where the mutation point is located, calculate the direction deviation between pixels, filter the region where the cumulative direction deviation exceeds the direction consistency mutation threshold, and summarize to obtain the direction consistency mutation region.

[0010] S4: Based on the direction consistency mutation region, calculate the local curvature change of the boundary point of the mutation region, screen the boundary points with curvature continuity anomalies, adjust the position of the boundary points according to the local change trend, and generate the defect boundary curvature fitting result.

[0011] S5: Based on the curvature fitting results of the defect boundary, calculate the gradient distribution inside the defect region, classify the defect types according to the curvature change trend and gradient distribution pattern, and generate product defect classification data.

[0012] As a further aspect of the present invention, the product surface gradient data includes gradient amplitude, gradient direction, and local grayscale gradient change rate; the multi-scale texture mutation point set includes mutation point coordinates, scale change trend records, and gradient direction standard deviation change rate; the direction consistency mutation region includes cumulative direction deviation value, direction consistency mutation threshold exceeding region, and key texture direction of mutation region; the defect boundary curvature fitting result includes boundary point set, local curvature change analysis result, and boundary point position adjustment result; and the product defect classification data includes defect region gradient distribution record, boundary region gradient features, curvature change trend record, gradient distribution pattern, and defect type.

[0013] As a further aspect of the present invention, the specific steps for acquiring product surface image data, calculating the grayscale gradient value of each pixel, extracting the grayscale gradient change rate, recording gradient amplitude and direction information, and generating product surface gradient data are as follows:

[0014] S111: Acquire product surface image data captured by an industrial camera, calculate grayscale gradient value for each pixel of the image, extract grayscale gradient change rate in each direction based on the calculation method of grayscale value change rate between adjacent pixels, and construct pixel gradient change rate matrix.

[0015] S112: Based on the pixel gradient change rate matrix, calculate the gradient magnitude change of adjacent pixels within a set window range, accumulate the gradient magnitude in different directions, and combine the gradient direction of each pixel to obtain local gradient cumulative magnitude data.

[0016] S113: Based on the accumulated local gradient magnitude data, calculate the gradient direction offset of each pixel, and calculate the difference in gradient direction changes between adjacent pixels using the following formula:

[0017]

[0018] Calculate the pixel gradient offset distribution value g, and combine it with gradient direction information to generate product surface gradient data, where... This represents the gradient value of pixel i in the x-direction. This represents the gradient value of pixel i in the y-direction. This represents the gradient value of pixel i-1 in the x-direction. This represents the gradient value of pixel i+1 in the x-direction. This represents the gradient value of pixel i-1 in the y-direction. represents the gradient value of pixel i+1 in the y direction, and N represents the total number of pixels in the calculation area.

[0019] As a further aspect of the present invention, based on the product surface gradient data, the specific steps for calculating the gradient change trend, statistically analyzing the changes in the local gradient change rate, extracting points with sudden increases in the change rate, calculating the standard deviation change rate to screen outliers and mark potential defect areas, and generating a multi-scale texture abrupt change point set are as follows:

[0020] S211: Based on the product surface gradient data, calculate the gradient change trend under different scale windows, statistically analyze the local gradient change rate, extract the gradient change value corresponding to each scale, and obtain a multi-scale gradient change matrix.

[0021] S212: Based on the multi-scale gradient change matrix, calculate the gradient change rate with scale growth. For the change amplitude at each scale, extract the point of sudden increase in the change rate, using the formula:

[0022]

[0023] Calculate the gradient change rate V, determine the abrupt increase point, and generate a set of abrupt change rate points, where, S represents the gradient change at scale i.i This represents the size of scale i. S represents the gradient change at scale i-1. i-1 Represents the size of scale i-1. The average gradient change value represents all scales, n represents the total number of scales used in the calculation, and m represents the number of scales used in the standard deviation calculation.

[0024] S213: Based on the mutation rate point set, calculate the standard deviation change rate of the gradient direction in adjacent regions, compare it with the set change threshold, filter out abnormal points and mark potential defect regions to obtain a multi-scale texture mutation point set.

[0025] As a further aspect of the present invention, based on the multi-scale texture mutation point set, the key texture direction angle of the region where the mutation point is located is calculated, the direction deviation between pixels is calculated, regions where the cumulative direction deviation exceeds the direction consistency mutation threshold are filtered, and the direction consistency mutation regions are summarized as follows:

[0026] S311: Based on the multi-scale texture mutation point set, calculate the key texture direction angle of the region where the mutation point is located, calculate the gradient direction distribution for adjacent pixels, and establish regional texture direction angle data.

[0027] S312: Calculate the directional deviation between pixels based on the region texture direction angle data, and use the formula:

[0028]

[0029] Calculate the cumulative value of directional deviation D, where θ i θ represents the texture direction angle of pixel i, B represents the number of pixels within the calculation window, and θ j θ represents the texture direction angle of pixel j within the window, K represents the number of pixels involved in the standard deviation calculation, and θ k The texture direction angle representing pixel k. d represents the global average texture direction angle. k represents the distance between pixel k and the center point, and A represents the total number of pixels in the calculation area;

[0030] S313: Based on the cumulative value of the directional deviation, set a threshold for directional consistency mutation, compare the cumulative value of the directional deviation of each region, filter out regions that exceed the threshold, and summarize the regions with directional consistency mutation.

[0031] As a further aspect of the present invention, based on the directional consistency abrupt change region, the specific steps for calculating the local curvature change at the boundary points of the abrupt change region, screening for boundary points with curvature continuity anomalies, adjusting the boundary point positions according to the local change trend, and generating the defect boundary curvature fitting result are as follows:

[0032] S411: Based on the aforementioned direction consistency abrupt change region, extract the set of boundary points within the region, calculate the local curvature change value of each boundary point, filter out boundary points with curvature continuity anomalies, call the spatial coordinates and curvature change values ​​of the boundary points, calculate the curvature change gradient, and generate a set of boundary curvature anomaly points.

[0033] S412: Based on the set of boundary curvature anomalies, adjust the positions of the boundary points according to the local change trend, using the following formula:

[0034]

[0035] Calculate the mean curvature change ΔL at the adjusted boundary points, and combine this with the adjustment range of the boundary point positions to generate the amount of curvature change at the adjusted boundary points, where L... i,new L represents the curvature value at the i-th boundary point after adjustment. i,old X represents the curvature value of the i-th boundary point before adjustment, E represents the total number of abnormal boundary points, and X represents the curvature value of the i-th boundary point before adjustment. j,new X j,old Represents the X and Y coordinates of the j-th boundary point after adjustment and before adjustment. j,new Y j,old represents the Y-coordinate of the j-th boundary point after adjustment and before adjustment, and W represents the total number of boundary points adjusted.

[0036] S413: Based on the adjusted boundary point curvature change, calculate the overall fitting curvature according to the local change trend of the boundary points, and smooth the curvature value to obtain the defect boundary curvature fitting result.

[0037] As a further aspect of the present invention, based on the defect boundary curvature fitting result, the gradient distribution inside the defect region is calculated, and the defect type is classified according to the curvature change trend and gradient distribution pattern to generate product defect classification data. The specific steps are as follows:

[0038] S511: Based on the curvature fitting result of the defect boundary, calculate the gradient distribution inside the defect region, call the gradient value and spatial coordinate data, calculate the gradient direction difference of each region, filter local gradient abrupt change points, and obtain the gradient change distribution record inside the defect.

[0039] S512: Based on the gradient change distribution record inside the defect, calculate the gradient characteristic value of the boundary region, compare the numerical difference between the gradient inside the defect region and the boundary gradient, analyze the gradient distribution trend, determine the local gradient change pattern, and obtain the gradient change comparison result.

[0040] S513: Based on the gradient change comparison results, and according to the curvature change trend and gradient distribution pattern, classify the defect types, including cracks, dents, and scratches, and establish product defect classification data.

[0041] A product quality control system based on machine vision includes:

[0042] The quality inspection surface gradient extraction module acquires product surface image data, calculates the grayscale gradient value of each pixel, extracts the grayscale gradient change rate in each direction, records gradient magnitude and direction information, and generates product surface gradient data.

[0043] The quality inspection multi-scale mutation point analysis module calculates the gradient change trend and extracts points with sudden increases in the rate of change based on the product surface gradient data. It calculates the standard deviation change rate of the gradient direction in adjacent areas, compares it with the set standard deviation change threshold of the gradient direction, filters out abnormal points and marks potential defect areas, and generates a multi-scale texture mutation point set.

[0044] The quality inspection direction consistency analysis module calculates the key texture direction angle of the region where the mutation point is located based on the multi-scale texture mutation point set, calculates the direction deviation between pixels, sets the direction consistency mutation threshold, and filters out the direction consistency mutation region.

[0045] The quality inspection defect boundary curvature calculation module calculates the local curvature change of the boundary points of the abrupt change region based on the directional consistency change region, filters the boundary points with abnormal curvature continuity, calculates the directional gradient change rate of the boundary region, adjusts the position of the boundary points, and generates the defect boundary curvature fitting result.

[0046] The quality inspection defect classification and identification module calculates the gradient distribution inside the defect region based on the defect boundary curvature fitting result, compares it with the gradient characteristics of the boundary region, and classifies the defect type according to the curvature change trend and gradient distribution pattern to obtain product defect classification data.

[0047] Compared with the prior art, the advantages and positive effects of the present invention are as follows:

[0048] In this invention, pixel-level grayscale gradient calculation enhances the ability to express local product features and improves the perception accuracy of minor product defects. Combined with multi-scale gradient change trend analysis, and using joint screening of abrupt increase rate and gradient direction standard deviation change rate, the accuracy of defect region identification is improved. Through texture direction angle calculation and vector field construction, fine-grained analysis of regional texture structure is achieved, enhancing the reliability of direction change anomaly detection. Based on the cumulative value of direction deviation and combined with a consistency mutation threshold, effective identification of structural mutation regions is ensured, reducing the possibility of false detection and missed detection. Boundary point sets are extracted, local curvature changes are calculated, and adjustments are made for curvature continuity anomalies to optimize the fitting accuracy of defect boundaries. Comparative analysis of gradient distribution within defect regions and boundary features, combined with curvature change trends and gradient patterns, enables accurate classification of defect types, improves the distinguishability of complex defects, and ensures the stability and adaptability of automated product quality inspection. Attached Figure Description

[0049] Figure 1 This is a flowchart of the main steps of the present invention;

[0050] Figure 2 This is a flowchart of step S1 of the present invention;

[0051] Figure 3 This is a flowchart of step S2 of the present invention;

[0052] Figure 4 This is a flowchart of step S3 of the present invention;

[0053] Figure 5 This is a flowchart of step S4 of the present invention;

[0054] Figure 6 This is a flowchart of step S5 of the present invention. Detailed Implementation

[0055] To make the objectives, technical solutions, and advantages of this invention clearer, the 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 merely illustrative and not intended to limit the invention.

[0056] In the description of this invention, it should be understood that the terms "length," "width," "upper," "lower," "front," "rear," "left," "right," "vertical," "horizontal," "top," "bottom," "inner," and "outer," etc., indicating orientation or positional relationships, are based on the orientation or positional relationships shown in the accompanying drawings and are only for the convenience of describing the invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation, and therefore should not be construed as a limitation of the invention. Furthermore, in the description of this invention, "a plurality of" means two or more, unless otherwise explicitly specified.

[0057] Please see Figure 1 A product quality control method based on machine vision includes the following steps:

[0058] S1: Acquire product surface image data through an industrial camera, calculate the grayscale gradient value of each pixel, extract the grayscale gradient change rate in each direction for adjacent pixels within a set window range, record the gradient magnitude and direction information, and generate product surface gradient data.

[0059] S2: Based on the product surface gradient data, calculate the gradient change trend under different scale windows, statistically analyze the change of local gradient change rate with scale growth, extract points with sudden increase in change rate, calculate the standard deviation change rate of gradient direction in adjacent areas, compare with change threshold to screen out anomalies and mark potential defect areas, and generate a multi-scale texture mutation point set.

[0060] S3: Based on the multi-scale texture mutation point set, calculate the key texture direction angle of the region where the mutation point is located, construct the texture direction vector field in the region, calculate the direction deviation between pixels, set the direction consistency mutation threshold, filter the region where the cumulative direction deviation exceeds the direction consistency mutation threshold, and summarize to obtain the direction consistency mutation region.

[0061] S4: Based on the direction consistency mutation region, extract the set of boundary points of the mutation region, calculate the local curvature change of the boundary points, screen the boundary points with abnormal curvature continuity, adjust the position of the boundary points according to the local change trend, and generate the defect boundary curvature fitting result.

[0062] S5: Based on the curvature fitting results of the defect boundary, calculate the gradient distribution inside the defect region and compare it with the gradient characteristics of the boundary region. Based on the curvature change trend and gradient distribution pattern, classify the defect types, including cracks, dents and scratches, and generate product defect classification data.

[0063] Product surface gradient data includes gradient magnitude, gradient direction, and local grayscale gradient change rate; multi-scale texture mutation point set includes mutation point coordinates, scale change trend record, and gradient direction standard deviation change rate; directional consistency mutation region includes cumulative directional deviation value, directional consistency mutation threshold exceeding region, and key texture direction of mutation region; defect boundary curvature fitting results include boundary point set, local curvature change analysis results, and boundary point position adjustment results; product defect classification data includes defect area gradient distribution record, boundary area gradient characteristics, curvature change trend record, gradient distribution pattern, and defect type.

[0064] Please see Figure 2 Step S1 is as follows:

[0065] S111: Acquire product surface image data captured by an industrial camera, calculate grayscale gradient value for each pixel of the image, extract grayscale gradient change rate in each direction based on the calculation method of grayscale value change rate between adjacent pixels, and construct pixel gradient change rate matrix.

[0066] The process involves acquiring product surface image data from an industrial camera and processing each pixel. First, the grayscale value of each pixel is read and calculated using the image grayscale calculation formula I(x, y) = 0.299R + 0.587G + 0.114B, where R, G, and B are the red, green, and blue channel values ​​of the pixel, respectively. This formula ensures standardized grayscale conversion. Next, the grayscale difference between adjacent pixels is calculated, with a 3×3 pixel neighborhood as the window size. The grayscale gradient of each pixel can be calculated using the Sobel operator. and Calculate the gradients in the x and y directions, where G x and G y For Sobel kernels, such as

[0067]

[0068] Taking a 256×256 resolution image as an example, if the RGB value of a pixel (x, y) is (120, 130, 140), then the grayscale value is calculated as follows:

[0069] I(x, y)=0.299×120+0.587×130+0.114×140=127.6;

[0070] The gradient change rate of adjacent pixels is calculated using the Sobel operator. Assume that the gray value distribution of other pixels within the window is as shown in Table 1 below:

[0071] Table 1 Gray Value Distribution Table

[0072] x-1 x x+1 y-1 125 130 135 y 128 127.6 132 y+1 126 129 134

[0073] Calculate the gradient value:

[0074]

[0075] Calculate the gradient magnitude:

[0076]

[0077] This leads to the pixel gradient change rate matrix.

[0078] S112: Based on the pixel gradient change rate matrix, calculate the gradient magnitude change of adjacent pixels within a set window range, accumulate the gradient magnitude in different directions, and combine the gradient direction of each pixel to obtain local gradient cumulative magnitude data.

[0079] Based on the pixel gradient change rate matrix, pixel gradient values ​​within a selected window are calculated. The gradient magnitude of each pixel is weighted and accumulated with the gradient magnitudes of its neighboring pixels. A region-weighted sum is used to calculate the gradient change of neighboring pixels. Assuming the gradient of the pixel at the center of the window is 22.1, and the gradients of the eight neighboring pixels are 15.5, 14.8, 16.2, 18.0, 17.5, 16.8, 15.0, and 14.0 respectively, a mean-weighted sum is used for calculation.

[0080]

[0081] Analysis of surface texture changes of typical products shows that the local gradient values ​​of metal surfaces and smooth ceramic surfaces are generally below 10, while the gradient values ​​of areas with fine lines or small defects are mostly between 10 and 20. If the local gradient value is higher than 20, it usually means that there are obvious edges, deep texture features or surface defects on the surface. The calculation result 16 is in the range of 10-20, indicating that the local gradient change range of the central pixel of the window is relatively stable. Finally, the local gradient cumulative amplitude matrix is ​​obtained.

[0082] S113: Based on the local gradient cumulative magnitude data, calculate the gradient direction offset of each pixel, and calculate the difference in gradient direction changes between adjacent pixels using the following formula:

[0083]

[0084] Calculate the pixel gradient offset distribution value g, and combine it with gradient direction information to generate product surface gradient data, where... This represents the gradient value of pixel i in the x-direction. This represents the gradient value of pixel i in the y-direction. This represents the gradient value of pixel i-1 in the x-direction. This represents the gradient value of pixel i+1 in the x-direction. This represents the gradient value of pixel i-1 in the y-direction. represents the gradient value of pixel i+1 in the y direction, and N represents the total number of pixels in the calculation area;

[0085] Based on the local gradient cumulative magnitude matrix, the gradient direction offset of each pixel is calculated. Using the gradient direction information of neighboring pixels, the gradient direction change rate is calculated to improve the resolution of surface gradient changes. These values ​​are then substituted into the formula for calculation. A 3×3 window is selected, and the pixel x-direction gradient value... The gradient values ​​in the y-direction are [12, 14, 16, 18, 20]. Given [10, 11, 13, 15, 17], calculate the first set of data:

[0086]

[0087] | 12.5 - 5 | = 7.5;

[0088] The remaining four sets of data were calculated sequentially, yielding the following values: 6.5, 8.0, 9.2, and 7.8.

[0089] Final summation:

[0090] g=7.5+6.5+8.0+9.2+7.8=39.0;

[0091] In the analysis of the uniformity of product surface structure, the gradient direction variation of ceramic surfaces and small plastic products is usually no more than 20, while the gradient direction variation of machined parts and engraved metal surfaces is often between 20 and 50. If the calculated value is greater than 50, it indicates the presence of prominent surface variations, such as cracks, deep scratches, rough areas, and other defects. If the calculated value is less than 20, it indicates that the surface is relatively uniform with no obvious areas of variation. The calculation result of 39.0 indicates that there is some variation in the gradient in local areas, which may indicate surface structure changes or defects. This information can be used for further defect detection or feature analysis.

[0092] Please see Figure 3 Step S2 is as follows:

[0093] S211: Based on the product surface gradient data, calculate the gradient change trend under different scale windows, statistically analyze the local gradient change rate, extract the gradient change value corresponding to each scale, and obtain the multi-scale gradient change matrix.

[0094] Based on product surface gradient data, different scale windows were selected, and the gradient change trend of pixels in each region was calculated using 3×3, 5×5, and 7×7 matrices. For each pixel within a scale window, its gradient change rate was calculated. The gradient change rate matrix of each window was normalized to ensure the comparability of gradient change rates between different scale windows. In specific industrial inspection scenarios, such as metal surface inspection, the gradient change rate can be used to measure the degree of texture anomalies for scratches or pits of different sizes. In the 3×3 small scale window, the gradient fluctuation range for single pixel scale changes is between 0.05 and 0.2, while in the 7×7 large scale window, the overall gradient fluctuation is smaller, with a change range between 0.01 and 0.08. Combining the gradient fluctuation range of each window scale, gradient change data at different scales were extracted to establish a multi-scale gradient change matrix.

[0095] Table 2. Statistical table of gradient change rate for windows of different scales.

[0096] Window size Mean gradient rate of change Range of variation 3×3 0.12 0.05~0.2 5×5 0.08 0.03~0.15 7×7 0.05 0.01~0.08

[0097] As shown in Table 2, the gradient change rate of different window sizes has significant differences. The 3×3 window has the highest gradient change rate, while the 7×7 window has the lowest. Subsequent calculations will be based on this to extract mutation points and calculate standard deviations.

[0098] S212: Based on the multi-scale gradient change matrix, calculate the gradient change rate with scale growth. For the change amplitude at each scale, extract the point of sudden increase in the change rate, using the formula:

[0099]

[0100] Calculate the gradient change rate V, determine the abrupt increase point, and generate a set of abrupt change rate points, where, S represents the gradient change at scale i. i This represents the size of scale i. S represents the gradient change at scale i-1. i-1 Represents the size of scale i-1. The average gradient change value represents all scales, n represents the total number of scales used in the calculation, and m represents the number of scales used in the standard deviation calculation.

[0101] The multi-scale gradient change matrix is ​​called to calculate the gradient change rate with scale growth. First, the average gradient change rate within different scale windows is numerically differentiated to calculate the growth rate of gradient change between adjacent scales in order to extract the point of sudden increase in change rate. Assuming that when detecting a ceramic surface, the mean gradient change rates of three windows of 3×3, 5×5, and 7×7 are 0.12, 0.08, and 0.05 respectively, the change rate can be calculated by substituting them into the formula.

[0102] in, The scale intervals S2-S1=2, S3-S2=2, and the mean gradient rate of change is...

[0103] The calculation steps are as follows:

[0104]

[0105] Take the square root:

[0106]

[0107] final:

[0108] V=|-0.035|-0.01308=0.02192;

[0109] The mutation threshold is set at 0.02, based on the statistical distribution of gradient change rates on different material surfaces. This value is derived from experimental testing of multiple material surfaces. Specifically, considering the surface roughness characteristics of different materials, for smooth surfaces (such as glass and ceramics), the mutation threshold is generally set between 0.015 and 0.025, while for rougher surfaces (such as metals and composite materials), the mutation threshold is set between 0.02 and 0.035. Taking ceramic testing as an example, a mutation threshold of 0.02 is used for ceramic surface testing, mainly based on the calculation of the standard deviation of the sample data.

[0110] The average gradient change rates of the 10 groups of samples are as follows:

[0111] [0.12, 0.08, 0.06, 0.07, 0.09, 0.05, 0.11, 0.04, 0.10, 0.06];

[0112] Calculate its standard deviation:

[0113]

[0114] Using the standard deviation of 0.0254 as a reference, a mutation threshold of 0.02 was set to cover more than 80% of the sample data and avoid misjudgments. The results show that during multi-scale gradient changes, the mutation rate point value is 0.02192. In actual detection scenarios, this value exceeds the set mutation threshold (0.02), therefore, it can be determined that a mutation point exists in this area, and it is further marked as a suspected defect area, and the mutation rate point set is statistically obtained.

[0115] S213: Based on the mutation rate point set, calculate the standard deviation change rate of the gradient direction in adjacent regions, compare it with the set change threshold, filter out abnormal points and mark potential defect areas to obtain a multi-scale texture mutation point set.

[0116] Based on the mutation rate point set, the standard deviation change rate of the gradient direction in adjacent regions is calculated. A 3×3 window is used to statistically analyze the gradient direction changes in adjacent regions, and a change threshold of 0.015 is set. This is compared with the standard deviation change rate of each region to screen outliers and mark potential defect areas. For example, in the glass substrate inspection process, if the standard deviations of the gradient direction between adjacent windows are 0.02, 0.025, and 0.018, the change rate is calculated as follows:

[0117]

[0118] The threshold of 0.015 is based on the fact that in the surface inspection of glass substrates, the standard deviation of the gradient direction in different regions usually ranges from 0.01 to 0.03. The average standard deviation of 50 sets of sample data was calculated, and a reasonable threshold was set using the interquartile range method, as follows:

[0119] Q1 (first quartile) = 0.012;

[0120] Q3 (third quantile) = 0.022;

[0121] IQR (interquartile range) = Q3 - Q1 = 0.01;

[0122] The threshold value is set as follows: Q1 - 0.5 × IQR = 0.012 - 0.5 × 0.01 = 0.0007;

[0123] Table 3. Rate of change of standard deviation of gradient direction in adjacent regions

[0124] Area code <![CDATA[σ1]]> <![CDATA[σ2]]> <![CDATA[σ3]]> Calculate the rate of change First 0.02 0.025 0.018 0.53 Second 0.012 0.015 0.013 0.1 C 0.01 0.011 0.009 0.2

[0125] As shown in Table 2, the rate of change in region A (0.53) is much higher than the set threshold of 0.0007, and therefore it is marked as a suspected defect region. Regions B and C, on the other hand, are not considered outliers due to their lower rates of change. Further integration yields a multi-scale texture mutation point set.

[0126] Please see Figure 4 Step S3 is as follows:

[0127] S311: Based on a multi-scale texture mutation point set, calculate the key texture direction angle of the region where the mutation point is located, calculate the gradient direction distribution for adjacent pixels, and establish regional texture direction angle data.

[0128] Based on a multi-scale texture mutation point set, the regions where mutation points are located are first extracted, and their key texture direction angles are calculated. The direction angle of each mutation point is calculated from the average gradient direction of its surrounding pixels. In this process, a suitable window size needs to be selected, as the window size directly affects the accuracy of the calculation results. The window is set to 5×5 pixels, and the average gradient direction of each mutation point is calculated by sliding point by point. A texture direction distribution matrix of the local region is established in units of pixels. The average gradient direction within the region of each mutation point is calculated. The specific calculation method is as follows: select the gradient direction of all pixels within the window range, represent it in polar coordinates, and then calculate the weighted average of the directions. If the gradient directions within the region are concentrated within a certain angle range, the direction of the region is stable; otherwise, it may be a direction mutation point. For example, if the pixel gradient directions within a certain window are 30°, 32°, 31°, 45°, and 33°, the weighted average angle is 34.2°. Finally, the texture direction angle data of the region is obtained.

[0129] S312: Calculate the directional deviation between pixels based on the region texture direction angle data, and use the formula:

[0130]

[0131] Calculate the cumulative value of directional deviation D, where θ i θ represents the texture direction angle of pixel i, B represents the number of pixels within the calculation window, and θ j θ represents the texture direction angle of pixel j within the window, K represents the number of pixels involved in the standard deviation calculation, and θ k The texture direction angle representing pixel k. d represents the global average texture direction angle. k represents the distance between pixel k and the center point, and A represents the total number of pixels in the calculation area;

[0132] The region texture orientation angle data is called to further calculate the orientation deviation between pixels. For each pixel within the window, the difference between its orientation angle and that of its neighboring pixels is calculated. The cumulative orientation deviation of pixels within the window is calculated. If the orientation deviation exceeds a set value, it is considered a sudden change region.

[0133] Taking a window size Y=5 as an example, assuming the texture direction angles within the region are 30°, 32°, 31°, 45°, and 33°, the average direction angle is calculated as follows:

[0134]

[0135] Calculate the cumulative value of directional deviation:

[0136]

[0137] Assume the distance between each pixel is d k If the value is 1, then the calculation is as follows:

[0138]

[0139] The calculation yields:

[0140]

[0141] The final calculated cumulative directional deviation was 9.32°.

[0142] S313: Based on the cumulative value of orientation deviation, set a threshold for abrupt changes in orientation consistency, compare the cumulative values ​​of orientation deviation in each region, filter out regions that exceed the threshold, and summarize the regions with abrupt changes in orientation consistency.

[0143] Based on the cumulative value of orientation deviation, a threshold for abrupt changes in orientation consistency is set to filter out areas exceeding the threshold. This threshold can be set based on empirical data or by statistically analyzing the distribution of orientation deviation values ​​in a large number of normal areas, calculating the standard deviation as a benchmark, and setting the threshold as the mean plus twice the standard deviation. For example, assuming the mean orientation deviation of a normal area is 5° and the standard deviation is 2°, the threshold for abrupt changes is set to 5 + 2 × 2 = 9°. If the cumulative orientation deviation value D of a certain area...s =9.32, which exceeds the threshold range, so the region is determined to be a mutation region, and finally the directional consistency mutation regions are summarized.

[0144] Table 4: Cumulative Calculation Data Table of Direction Deviation

[0145] Pixel number Direction angle (°) Deviation value (°) <![CDATA[Calculate distance d k > Deviation normalized value 1 30 4.2 1 4.2 2 32 2.2 1 2.2 3 31 3.2 1 3.2 4 45 10.8 1 10.8 5 33 1.2 1 1.2

[0146] As shown in Table 4, the directional deviation calculation data of each pixel can be used to calculate the cumulative value of directional deviation and compare it with the set threshold to determine whether it belongs to a sudden change region.

[0147] Please see Figure 5 Step S4 is as follows:

[0148] S411: Based on the direction consistency mutation region, extract the set of boundary points in the region, calculate the local curvature change value of each boundary point, filter out the boundary points with curvature continuity anomalies, call the spatial coordinates and curvature change values ​​of the boundary points, calculate the curvature change gradient, and generate a set of boundary curvature anomaly points.

[0149] The extraction of regions with abrupt changes in orientation consistency is based on the gradient direction calculation of boundary points. First, the grayscale gradient of each pixel within the target region is calculated to obtain the orientation information of each pixel. Then, the horizontal gradient G is calculated using the Sobel operator. x and vertical gradient G y Using the formula θ=tan -1 (G y / G x The gradient direction angle is calculated, and a set of pixels in the region of abrupt change in direction is extracted. This region of abrupt change in gradient direction angle is used as the basis for subsequent boundary point calculations. Pixels with obvious abrupt changes in direction within this region are selected as candidate boundary points. The curvature calculation radius r is set to 3 pixels. Local curvature calculations are performed on the selected boundary points, and the curvature of each boundary point P is calculated. i Local curvature L i The calculation method is as follows:

[0150]

[0151] Where △ is the area of ​​the triangle formed by the two boundary points and the current point, and l is the chord length between the boundary points.

[0152] After the calculation is completed, the curvature continuity of all boundary points is detected. The curvature change threshold is set to 0.15. This value is set based on the statistical calculation of the standard boundary curvature variation range. The specific calculation method is as follows: In a typical set of boundary defect samples, 1000 boundary points are selected, and the curvature value change |L| at each point is calculated. i -L i-1Then, a distribution analysis of the curvature changes at all boundary points is performed, and the upper quartile of the curvature changes (i.e., the top 75% quantiles of all curvature changes) is set as the curvature abrupt change threshold. Calculations show that the change value corresponding to the top 75% quantiles is 0.14-0.16, therefore 0.15 is taken as the final threshold. If a boundary point P... i If the difference between the curvature of a point and the curvature of its adjacent boundary point is greater than 0.15, then the point is determined to be a curvature anomaly, forming a set of boundary curvature anomalies.

[0153] Table 5 lists the curvature values ​​and curvature changes at some boundary points:

[0154] Table 5 shows the curvature values ​​and curvature changes at some boundary points.

[0155] Boundary point numbering Position coordinates (X, Y) <![CDATA[Calculating curvature L i > Curvature variation at adjacent points 1 (50,60) 0.12 0.03 2 (52,63) 0.18 0.06 3 (55,67) 0.30 0.12 4 (58,70) 0.45 0.15

[0156] As shown in Table 5, the curvature change value of boundary point number 4 reached 0.15, which exceeded the threshold. Therefore, it was identified as a curvature anomaly and added to the boundary curvature anomaly point set.

[0157] S412: Based on the set of boundary curvature anomalies and the local trend of change, adjust the position of the boundary points using the following formula:

[0158]

[0159] Calculate the mean curvature change ΔL at the adjusted boundary points, and combine this with the adjustment range of the boundary point positions to generate the amount of curvature change at the adjusted boundary points, where L... i,new L represents the curvature value at the i-th boundary point after adjustment. i,old X represents the curvature value of the i-th boundary point before adjustment, E represents the total number of abnormal boundary points, and X represents the curvature value of the i-th boundary point before adjustment. j,new X j,old Represents the X and Y coordinates of the j-th boundary point after adjustment and before adjustment. j,new Y j,old represents the Y-coordinate of the j-th boundary point after adjustment and before adjustment, and W represents the total number of boundary points adjusted.

[0160] Based on the set of boundary curvature anomalies, the local gradient of each anomaly is calculated, and the position of the boundary points is adjusted using interpolation to make their curvature changes more stable. The adjustment step size Δd is set to 2 pixels for boundary point P. i Perform a smooth adjustment, and determine the position P of the boundary point after adjustment; the calculation is as follows:

[0161] X i,new =X i,old +Δdcos(θ i );

[0162] Y i,new =Y i,old+Δdsin(θ i );

[0163] Where, θ i Let L be the gradient direction angle at the current point. Calculate the average curvature change after adjustment using the formula: Substitute point number 4 in Table 5: Curvature L before adjustment. 4,old =0.45 after adjustment of curvature L 4,new =0.28 coordinate adjustment X 4,new =60, Y 4,new Substitute 72 into the formula to calculate:

[0164]

[0165] The calculated change in curvature at the adjusted boundary points is 0.48.

[0166] S413: Based on the change in curvature of the adjusted boundary points, calculate the overall fitted curvature according to the local change trend of the boundary points, and smooth the curvature value to obtain the defect boundary curvature fitting result.

[0167] Based on the adjusted curvature change at the boundary points, the overall fitted curvature of the boundary points is calculated. A second-order polynomial fitting method is used to smooth the curvature values ​​of all boundary points, and the second-order fitting curve is defined as: L(x) = ax 2 +bx+c calculates the fitting parameters a, b, c using the least squares method, and defines the boundary point coordinate set (Xi, K). i Substitute the values ​​into the least squares equations and solve:

[0168]

[0169] The calculation yielded:

[0170] a = 0.0025;

[0171] b = -0.1;

[0172] c = 1.2;

[0173] The final curvature function is obtained by fitting:

[0174] L(x) = 0.0025x 2 -0.1x+1.2;

[0175] The fitted curvature value is calculated and smoothed to obtain the final curvature fitting result of the defect boundary.

[0176] Table 6 shows the curvature values ​​before and after adjustment and the fitted curvature values ​​for different boundary points.

[0177] Table 6. Curvature values ​​before and after adjustment and fitted curvature values

[0178] Boundary point numbering <![CDATA[Pre-adjustment curvature L old > <![CDATA[Adjusted curvature L new > <![CDATA[Fitted curvature L fit > 1 0.12 0.11 0.10 2 0.18 0.17 0.16 3 0.30 0.28 0.27 4 0.45 0.28 0.29

[0179] As shown in Table 6, after fitting, the curvature value is smoothed, and the final result of the defect boundary curvature fitting is generated.

[0180] Please see Figure 6 The S5 steps are as follows:

[0181] S511: Based on the curvature fitting results of the defect boundary, calculate the gradient distribution inside the defect region, call the gradient values ​​and spatial coordinate data, calculate the gradient direction differences in each region, filter local gradient abrupt change points, and obtain the gradient change distribution record inside the defect.

[0182] Based on the curvature fitting results of the defect boundary, the defect region is divided into grids. Using each grid cell as the basic unit, the gradient value of each pixel within that cell is calculated. The gradient direction is obtained using differential operations, and the local distribution trend of gradient changes is obtained through statistical analysis to detect gradient differences between grid cells. Specifically, the gradient value is calculated using the partial derivative of the pixel's grayscale value, i.e.

[0183]

[0184] Where I is the gray value of a pixel, and x and y are the spatial coordinates. The gradient direction can be determined by...

[0185]

[0186] Calculations show that, in practical applications, with an image resolution of 1024×1024 pixels and each grid cell containing 10×10 pixels, 100 sets of gradient values ​​can be calculated within each grid cell, and the overall gradient direction of that cell is calculated using the average. The gradient abrupt change threshold of 15° is set based on the fact that gradient changes on normal material surfaces typically do not exceed 10°, while for defects such as cracks and scratches, experimentally measured gradient direction changes are usually above 15°. Furthermore, in the detection of metal material surfaces, the actual measured gradient changes at crack initiation points are between 14° and 18°. Therefore, 15° is chosen as the judgment threshold to ensure effective capture of defect areas while avoiding misjudging normal surface textures. If the difference in the average gradient of adjacent cells is greater than 15°, the grid cell is determined to be an abrupt change point. Based on the gradient abrupt changes of all grid cells, the gradient changes within the defect area are extracted to form the gradient change distribution within the defect.

[0187] Table 7 Examples of gradient distribution within the defect region

[0188] Grid number Coordinate center (x, y) Mean gradient direction (°) Mutation determination 1 (50,50) 10 no 2 (60,50) 12 no 3 (70,50) 28 yes 4 (80,50) 30 yes

[0189] As shown in Table 7, the gradient direction of some grids changes abruptly. These are identified as gradient abrupt change points and included in the analysis of gradient changes within the defect. Finally, the distribution record of gradient changes within the defect is obtained.

[0190] S512: Based on the gradient change distribution record inside the defect, calculate the gradient characteristic value of the boundary region, compare the numerical difference between the gradient inside the defect region and the boundary gradient, analyze the gradient distribution trend, determine the local gradient change pattern, and obtain the gradient change comparison results.

[0191] The gradient distribution records within the defect are retrieved, and the gradient characteristic values ​​of the boundary region are calculated. A local window is established centered on the boundary point, and a 5×5 grid cell around the boundary point is selected as the computational region. The mean and standard deviation of the gradient within this region are calculated, and the numerical differences between the gradient within the defect region and the boundary gradient are compared. For the gradient calculation at the boundary point, the Sobel operator is used to calculate the gradient magnitude, and its formula is as follows:

[0192]

[0193] Among them, G x G y This represents the gradient components in the x and y directions. By calculating the average gradient at all boundary points, a reference benchmark is set. For example, if the average gradient at a boundary point is 25, while the average gradient at a point inside the defect region is 40, the gradient difference is 15. If this exceeds a set threshold of 10, the gradient at that point is considered abnormal. This threshold is based on the fact that in normal, defect-free areas, the gradient difference between the boundary and the interior is typically between 5 and 8, while in experimentally measured crack and depression areas, this value generally exceeds 10. Therefore, 10 is chosen as a reasonable threshold to ensure the accuracy of distinguishing between normal and abnormal boundary regions. For different materials, this value can be adjusted based on experimental statistical results. For example, in plastic materials, experimental data shows that the gradient difference at crack boundaries is generally between 8 and 12, while in metal materials, the gradient difference can reach 12 to 18. Therefore, for metal detection, it can be adjusted to 12, while for plastic detection, it can be maintained at 10 to reduce false positives. The mean square error of all gradient difference values ​​is further calculated to assess the overall gradient change in the defect region. Based on the above calculation process, a gradient change comparison result is formed.

[0194] Table 8. Comparison of gradient data between boundary and defect regions.

[0195]

[0196]

[0197] As shown in Table 8, the gradient difference in some regions exceeds the set threshold, indicating that there are abnormal gradient distribution characteristics in these regions, and the final gradient change comparison results are obtained.

[0198] S513: Based on the gradient change comparison results, and according to the curvature change trend and gradient distribution pattern, classify the defect types, including cracks, dents, and scratches, and establish product defect classification data.

[0199] Based on the comparison results of gradient changes, and according to the curvature change trend and gradient distribution pattern, defect types are classified. Specific classification criteria are based on the spatial distribution pattern of gradient changes. For example, cracks typically exhibit abrupt gradient changes in a localized area with consistent direction, while depressions show a generally lower and more gradual gradient, and scratches exhibit linearly arranged abrupt gradient changes. The following classification rules are adopted:

[0200] If the gradient change in the defect area is small overall, and the difference between the average gradient value of the boundary area and the average gradient value of the defect area does not exceed 5, it is judged as a depression. The basis for setting this threshold is that the curvature gradient change of a normal surface usually does not exceed 3, while in the depression area, the experimentally measured gradient change is usually between 3 and 5. Therefore, 5 is selected as the judgment standard to avoid misjudging normal surface changes as depressions.

[0201] If the gradient changes linearly and the gradient directions are relatively consistent, it is determined to be a crack;

[0202] If the direction of the gradient change is irregular and the local gradient difference exceeds 20, it is judged as a scratch. This value is set based on experimental results. The gradient change in the scratch area measured in the test sample is between 18 and 22, while the direction change of the normal surface is usually no more than 15. Therefore, 20 is selected as the judgment standard to ensure that scratches and normal boundary changes can be effectively distinguished.

[0203] Suppose a defective region has an internal gradient mean of 18 and a boundary gradient mean of 22, with relatively small gradient variations, meeting the criteria for a depression. Another region has an internal gradient mean of 35 and a boundary gradient mean of 10, showing a significant abrupt change in gradient direction; these are then classified as cracks. Finally, based on these classification criteria, product defect classification data is generated.

[0204] A product quality control system based on machine vision includes:

[0205] The quality inspection surface gradient extraction module acquires product surface image data, calculates the grayscale gradient value of each pixel, extracts the grayscale gradient change rate in each direction, records gradient magnitude and direction information, and generates product surface gradient data.

[0206] The quality inspection multi-scale mutation point analysis module is based on product surface gradient data. It calculates the gradient change trend and extracts points with sudden increases in the rate of change. It calculates the standard deviation change rate of the gradient direction in adjacent areas, compares it with the set standard deviation change threshold of the gradient direction, filters out abnormal points and marks potential defect areas, and generates a multi-scale texture mutation point set.

[0207] The quality inspection direction consistency analysis module is based on a multi-scale texture mutation point set. It calculates the key texture direction angle of the region where the mutation point is located, calculates the direction deviation between pixels, sets the direction consistency mutation threshold, and filters out the direction consistency mutation region.

[0208] The quality inspection defect boundary curvature calculation module is based on the directional consistency abrupt change region. It calculates the local curvature change of the boundary point of the abrupt change region, filters the boundary point with abnormal curvature continuity, calculates the directional gradient change rate of the boundary region, adjusts the position of the boundary point, and generates the defect boundary curvature fitting result.

[0209] The quality inspection defect classification and identification module calculates the gradient distribution inside the defect region based on the defect boundary curvature fitting results, compares it with the gradient features of the boundary region, and classifies the defect type according to the curvature change trend and gradient distribution pattern to obtain product defect classification data.

[0210] The above are merely preferred embodiments of the present invention and are not intended to limit the present invention in any other way. Any person skilled in the art may make changes or modifications to the above-disclosed technical content to create equivalent embodiments that can be applied to other fields. However, any simple modifications, equivalent changes, and modifications made to the above embodiments based on the technical essence of the present invention without departing from the scope of the present invention shall still fall within the protection scope of the present invention.

Claims

1. A product quality control method based on machine vision, characterized in that, Includes the following steps: S1: Acquire product surface image data, calculate grayscale gradient value of each pixel, extract grayscale gradient change rate, record gradient magnitude and direction information, and generate product surface gradient data. S2: Based on the product surface gradient data, calculate the gradient change trend, statistically analyze the changes in the local gradient change rate, extract points with sudden increases in change rate, calculate the standard deviation change rate to screen out anomalies and mark potential defect areas, and generate a multi-scale texture mutation point set. S3: Based on the multi-scale texture mutation point set, calculate the key texture direction angle of the region where the mutation point is located, calculate the direction deviation between pixels, filter the region where the cumulative direction deviation exceeds the direction consistency mutation threshold, and summarize to obtain the direction consistency mutation region. S4: Based on the direction consistency mutation region, calculate the local curvature change of the boundary point of the mutation region, screen the boundary points with curvature continuity anomalies, adjust the position of the boundary points according to the local change trend, and generate the defect boundary curvature fitting result. S5: Based on the curvature fitting results of the defect boundary, calculate the gradient distribution inside the defect region, classify the defect types according to the curvature change trend and gradient distribution pattern, and generate product defect classification data.

2. The product quality control method based on machine vision according to claim 1, characterized in that, The product surface gradient data includes gradient magnitude, gradient direction, and local grayscale gradient change rate. The multi-scale texture mutation point set includes mutation point coordinates, scale change trend records, and gradient direction standard deviation change rate. The direction consistency mutation region includes cumulative direction deviation value, direction consistency mutation threshold exceeding region, and key texture direction of mutation region. The defect boundary curvature fitting result includes boundary point set, local curvature change analysis result, and boundary point position adjustment result. The product defect classification data includes defect region gradient distribution record, boundary region gradient features, curvature change trend record, gradient distribution pattern, and defect type.

3. The product quality control method based on machine vision according to claim 1, characterized in that, The specific steps for acquiring product surface image data, calculating the grayscale gradient value of each pixel, extracting the grayscale gradient change rate, and recording gradient magnitude and direction information to generate product surface gradient data are as follows: S111: Acquire product surface image data captured by an industrial camera, calculate grayscale gradient value for each pixel of the image, extract grayscale gradient change rate in each direction based on the calculation method of grayscale value change rate between adjacent pixels, and construct pixel gradient change rate matrix. S112: Based on the pixel gradient change rate matrix, calculate the gradient magnitude change of adjacent pixels within a set window range, accumulate the gradient magnitude in different directions, and combine the gradient direction of each pixel to obtain local gradient cumulative magnitude data. S113: Based on the accumulated local gradient magnitude data, calculate the gradient direction offset of each pixel, and calculate the difference in gradient direction changes between adjacent pixels using the following formula: Calculate the pixel gradient offset distribution value g, and combine it with gradient direction information to generate product surface gradient data, where... This represents the gradient value of pixel i in the x-direction. This represents the gradient value of pixel i in the y-direction. This represents the gradient value of pixel i-1 in the x-direction. This represents the gradient value of pixel i+1 in the x-direction. This represents the gradient value of pixel i-1 in the y-direction. represents the gradient value of pixel i+1 in the y direction, and N represents the total number of pixels in the calculation area.

4. The product quality control method based on machine vision according to claim 1, characterized in that, Based on the product surface gradient data, the specific steps for calculating the gradient change trend, statistically analyzing the changes in local gradient change rates, extracting points with sudden increases in change rates, calculating the standard deviation change rate to screen outliers and mark potential defect areas, and generating a multi-scale texture abrupt change point set are as follows: S211: Based on the product surface gradient data, calculate the gradient change trend under different scale windows, statistically analyze the local gradient change rate, extract the gradient change value corresponding to each scale, and obtain a multi-scale gradient change matrix. S212: Based on the multi-scale gradient change matrix, calculate the gradient change rate with scale growth. For the change amplitude at each scale, extract the point of sudden increase in the change rate, using the formula: Calculate the gradient change rate V, determine the abrupt increase point, and generate a set of abrupt change rate points, where, S represents the gradient change at scale i. i This represents the size of scale i. S represents the gradient change at scale i-1. i-1 Represents the size of scale i-1. The average gradient change value represents all scales, n represents the total number of scales used in the calculation, and m represents the number of scales used in the standard deviation calculation. S213: Based on the mutation rate point set, calculate the standard deviation change rate of the gradient direction in adjacent regions, compare it with the set change threshold, filter out abnormal points and mark potential defect regions to obtain a multi-scale texture mutation point set.

5. The product quality control method based on machine vision according to claim 1, characterized in that, Based on the multi-scale texture mutation point set, the specific steps for calculating the key texture direction angle of the region where the mutation point is located, calculating the direction deviation between pixels, filtering regions where the cumulative direction deviation exceeds the direction consistency mutation threshold, and summarizing the direction consistency mutation regions are as follows: S311: Based on the multi-scale texture mutation point set, calculate the key texture direction angle of the region where the mutation point is located, calculate the gradient direction distribution for adjacent pixels, and establish regional texture direction angle data. S312: Calculate the directional deviation between pixels based on the region texture direction angle data, and use the formula: Calculate the cumulative value of directional deviation D, where θ i θ represents the texture direction angle of pixel i, B represents the number of pixels within the calculation window, and θ j θ represents the texture direction angle of pixel j within the window, K represents the number of pixels involved in the standard deviation calculation, and θ k The texture direction angle representing pixel k. d represents the global average texture direction angle. k represents the distance between pixel k and the center point, and A represents the total number of pixels in the calculation area; S313: Based on the cumulative value of the directional deviation, set a threshold for directional consistency mutation, compare the cumulative value of the directional deviation of each region, filter out regions that exceed the threshold, and summarize the regions with directional consistency mutation.

6. The product quality control method based on machine vision according to claim 1, characterized in that, Based on the aforementioned directional consistency abrupt change region, the specific steps for calculating the local curvature change at the boundary points of the abrupt change region, screening for boundary points with curvature continuity anomalies, adjusting the boundary point positions according to the local change trend, and generating the defect boundary curvature fitting result are as follows: S411: Based on the aforementioned direction consistency abrupt change region, extract the set of boundary points within the region, calculate the local curvature change value of each boundary point, filter out boundary points with curvature continuity anomalies, call the spatial coordinates and curvature change values ​​of the boundary points, calculate the curvature change gradient, and generate a set of boundary curvature anomaly points. S412: Based on the set of boundary curvature anomalies, adjust the positions of the boundary points according to the local change trend, using the following formula: Calculate the mean curvature change ΔL at the adjusted boundary points, and combine this with the adjustment range of the boundary point positions to generate the amount of curvature change at the adjusted boundary points, where L... i,new L represents the curvature value at the i-th boundary point after adjustment. i,old X represents the curvature value of the i-th boundary point before adjustment, E represents the total number of abnormal boundary points, and X represents the curvature value of the i-th boundary point before adjustment. j,new X j,old Represents the X and Y coordinates of the j-th boundary point after adjustment and before adjustment. j,new Y j,old represents the Y-coordinate of the j-th boundary point after adjustment and before adjustment, and W represents the total number of boundary points adjusted. S413: Based on the adjusted boundary point curvature change, calculate the overall fitting curvature according to the local change trend of the boundary points, and smooth the curvature value to obtain the defect boundary curvature fitting result.

7. The product quality control method based on machine vision according to claim 1, characterized in that, Based on the defect boundary curvature fitting results, the gradient distribution within the defect region is calculated. Based on the curvature change trend and gradient distribution pattern, defect types are classified, and the specific steps for generating product defect classification data are as follows: S511: Based on the curvature fitting result of the defect boundary, calculate the gradient distribution inside the defect region, call the gradient value and spatial coordinate data, calculate the gradient direction difference of each region, filter local gradient abrupt change points, and obtain the gradient change distribution record inside the defect. S512: Based on the gradient change distribution record inside the defect, calculate the gradient characteristic value of the boundary region, compare the numerical difference between the gradient inside the defect region and the boundary gradient, analyze the gradient distribution trend, determine the local gradient change pattern, and obtain the gradient change comparison result. S513: Based on the gradient change comparison results, and according to the curvature change trend and gradient distribution pattern, classify the defect types, including cracks, dents, and scratches, and establish product defect classification data.

8. A product quality control system based on machine vision, characterized in that, The system is used to perform the method according to any one of claims 1-7, comprising: The quality inspection surface gradient extraction module acquires product surface image data, calculates the grayscale gradient value of each pixel, extracts the grayscale gradient change rate in each direction, records gradient magnitude and direction information, and generates product surface gradient data. The quality inspection multi-scale mutation point analysis module calculates the gradient change trend and extracts points with sudden increases in the rate of change based on the product surface gradient data. It calculates the standard deviation change rate of the gradient direction in adjacent areas, compares it with the set standard deviation change threshold of the gradient direction, filters out abnormal points and marks potential defect areas, and generates a multi-scale texture mutation point set. The quality inspection direction consistency analysis module calculates the key texture direction angle of the region where the mutation point is located based on the multi-scale texture mutation point set, calculates the direction deviation between pixels, sets the direction consistency mutation threshold, and filters out the direction consistency mutation region. The quality inspection defect boundary curvature calculation module calculates the local curvature change of the boundary points of the abrupt change region based on the directional consistency change region, filters the boundary points with abnormal curvature continuity, calculates the directional gradient change rate of the boundary region, adjusts the position of the boundary points, and generates the defect boundary curvature fitting result. The quality inspection defect classification and identification module calculates the gradient distribution inside the defect region based on the defect boundary curvature fitting result, compares it with the gradient characteristics of the boundary region, and classifies the defect type according to the curvature change trend and gradient distribution pattern to obtain product defect classification data.

Citation Information

Cited By

  • Early damage identification method for floor support plate

    CN121582226A

  • A method for early damage identification of floor decking

    CN121582226B

  • Product quality detection method based on machine vision

    CN121678679A

  • A product quality detection method based on machine vision

    CN121678679B

  • Shell repair quality evaluation and judgment method based on visual inspection

    CN121861001A