Vision-based method and system for detecting cosmetic defects of a component
By calculating multi-dimensional feature difference degree and Euclidean distance, the problem of low-contrast defects being difficult to distinguish on highly reflective curved iron soleplates by traditional methods is solved, achieving efficient and accurate defect detection and improving the robustness and accuracy of detection.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-15
- Publication Date
- 2026-04-07
AI Technical Summary
Traditional methods for detecting surface defects struggle to distinguish between low-contrast defects and normal textures on highly reflective curved surfaces and workpieces with complex geometries, leading to missed detections and misjudgments. This is especially true for iron soleplates, where existing technologies ignore the relative grayscale differences and gradient changes between defects and normal structures in their local neighborhoods.
By calculating multi-dimensional feature differences, including edge probability, contour features and gradient distribution, and combining Euclidean distance and defect matching degree, defects such as micro-pits, vapor hole deformation and surface scratches can be finely distinguished, avoiding misjudging the normal structure of highly reflective areas.
In complex backgrounds and low-contrast conditions, it can accurately identify real defects, improve the robustness and accuracy of detection, avoid misjudgments, and ensure the reliability and accuracy of detection results.
Smart Images

Figure CN121329969B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of image processing. In particular, it relates to a vision-based accessory appearance defect detection method and system. BACKGROUND
[0002] Traditional appearance defect detection methods mainly rely on gray threshold segmentation, template matching and connected component analysis based on artificial rule algorithm. Such methods have certain detection ability for high-contrast and simple structure defects under ideal lighting and stable working conditions.
[0003] However, on workpieces such as electric iron bottom plates with high light-reflecting curved surfaces and complex geometric structures (such as steam holes and flow guide pits), the surface reflection characteristics are easily affected by light source angle, environmental light changes and material differences of different production batches, resulting in significant non-uniform pixel distribution in the normal area of the image. At the same time, defects such as shallow scratches, micro pits, slight deformation of steam holes or local deformation of flow guide pits are common in actual production, and the contrast is extremely low, which is difficult to distinguish from normal texture or light reflection artifacts, making it difficult for traditional rule algorithms to establish a stable and robust discrimination boundary, resulting in a large number of missed detections and inaccurate appearance defect detection results. SUMMARY
[0004] To solve the above technical problems, the present application provides solutions in the following aspects.
[0005] In a first aspect, a vision-based accessory appearance defect detection method includes: collecting a target image of an iron and a historical defect label corresponding to the target image, the target image being any historical bottom plate gray image, and obtaining a to-be-detected bottom plate gray image; obtaining a connected component of the target image, and obtaining a connected component of the to-be-detected bottom plate gray image in the same way, obtaining a defect connected component of the target image according to the actual defect position of the target image, and calculating the feature difference between the connected component of the to-be-detected bottom plate gray image and the defect connected component; taking the connected component of the target image other than the defect connected component as a general domain, calculating the Euclidean distance between the centroid of the defect connected component and the centroid of the general domain, and calculating the first distance standard deviation of all Euclidean distances in the target image, obtaining the second distance standard deviation of the to-be-detected bottom plate gray image in the same way according to the calculation method of the first distance standard deviation, and calculating the defect matching degree between the to-be-detected bottom plate gray image and the target image based on the first distance standard deviation, the second distance standard deviation and the feature difference, to complete defect detection.
[0006] Preferably, obtaining the connected components of the target image includes: taking any pixel in the target image as a study point; calculating the first discrimination index of the target image; calculating the second ratio of the pixel value of the study point to the maximum pixel value in the target image, and using the standard deviation of all second ratios as the second discrimination index of the target image; calculating the first standard deviation of the first ratio of the study point in all preset directions, and obtaining the first standard deviation of each pixel in the 8-neighborhood of the study point, and using the mean of all first standard deviations as the first edge probability of the study point; using the standard deviation of the second ratio of each pixel in the 8-neighborhood of the study point as the second edge probability of the study point; calculating the final edge probability of the study point based on the first discrimination index, the second discrimination index, the first edge probability, and the second edge probability; traversing to obtain the normalized final edge probability of each pixel in the target image, taking pixels with a normalized final edge probability greater than a preset threshold as edge pixels, and connecting the edge pixels to obtain the connected components of the target image.
[0007] Preferably, the calculation of the first discrimination of the target image includes: taking any preset direction as the study direction, where the preset direction is 0 degrees, 45 degrees, 90 degrees and 135 degrees; calculating the gradient value of the study point in the study direction, obtaining the maximum gradient value in the study direction, calculating the first ratio of the gradient value of the study point in the study direction to the maximum gradient value, traversing to obtain the first ratio of each pixel in the study direction, calculating the standard deviation of all ratios, traversing to obtain the standard deviation of the ratio in each preset direction, and taking the mean of all standard deviations of the ratios as the first discrimination of the target image.
[0008] Preferably, the calculation of the final edge probability of the study point includes: calculating a third ratio of the sum of the first discrimination of all historical background grayscale images to the sum of the second discrimination of all historical background grayscale images; calculating a fourth ratio of the sum of the second discrimination of all historical background grayscale images to the sum of the first discrimination of all historical background grayscale images; calculating a first product of the third ratio and the first edge probability; calculating a second product of the fourth ratio and the second edge probability; and using the sum of the first product and the second product as the final edge probability of the study point.
[0009] Preferably, the feature difference includes: taking any connected region in the grayscale image of the substrate to be detected as the detection region, taking the standard deviation of the curvature of all edge pixels in the detection region as the first contour feature value; taking the standard deviation of the gradient magnitude of all edge pixels in the detection region as the second contour feature value; taking any preset direction as the research direction, the preset directions being 0 degrees, 45 degrees, 90 degrees, and 135 degrees, taking the average gradient of all pixels in the detection region in the research direction as the first distribution feature value, traversing to obtain the first distribution feature value of each preset direction, so as to obtain the minimum and maximum first distribution feature values of the detection region; obtaining the defect connected region of the target image according to the actual defect location of the target image, and similarly obtaining the first distribution feature value of the defect connected region. The system calculates the contour feature value, the second contour feature value, the minimum first distribution feature value, and the maximum first distribution feature value; it calculates the first difference between the first contour feature value of the domain to be detected and the first contour feature value of the defect connected domain, calculates the second difference between the second contour feature value of the domain to be detected and the second contour feature value of the defect connected domain, and calculates the absolute value of the first product of the first difference and the second difference; it calculates the third difference between the maximum first distribution feature value of the domain to be detected and the maximum first distribution feature value of the defect connected domain, calculates the fourth difference between the minimum first distribution feature value of the domain to be detected and the minimum first distribution feature value of the defect connected domain, and calculates the absolute value of the second product of the third difference and the fourth difference; and it uses the sum of the absolute values of the first product and the second product as the feature difference degree.
[0010] Preferably, the feature difference degree further includes: for any preset direction, calculating the fifth difference between the first distribution feature value of the domain to be detected and the first distribution feature value of the defect connected domain, traversing to obtain the fifth difference value for each preset direction, and calculating the average of the fifth differences; calculating the first absolute difference between the fifth difference value and the average of the fifth differences in any preset direction, and calculating the cumulative value of the absolute differences in all preset directions; and using the sum of the absolute value of the first product and the cumulative value of the absolute differences as the feature difference degree.
[0011] Preferably, the calculation of the defect matching degree between the grayscale image of the substrate to be detected and the target image includes: constructing a defect set from the connected components of the historical substrate grayscale images with the same historical defect labels, and taking any defect set as the set to be matched; for any connected component of the defect in the set to be matched, obtaining the feature difference degree between the connected component of the grayscale image of the substrate to be detected and any connected component of the defect; calculating the second absolute difference between the first distance standard deviation and the second distance standard deviation, calculating the third product of the second absolute difference and the feature difference degree, traversing to obtain the third product of each connected component of the defect in the set to be matched, calculating the mean of the third products of all the third products, and taking the exponent of the inverse of the mean of the third products as the defect matching degree.
[0012] Secondly, a vision-based accessory appearance defect detection system includes: a processor and a memory, wherein the memory stores computer program instructions, and when the computer program instructions are executed by the processor, the vision-based accessory appearance defect detection method described in any one of the claims is implemented.
[0013] The present invention has the following effects:
[0014] This invention calculates feature differences across multiple dimensions, including edge probability, contour features, and gradient distribution, enabling it to finely distinguish defects such as low-contrast micro-pits, vapor hole deformation, and surface scratches, while avoiding misjudging the normal structure of highly reflective areas.
[0015] By comprehensively considering multiple features such as grayscale value, gradient response, and geometric morphology, it can accurately identify real defects even in complex backgrounds and low-contrast conditions. This is particularly true when structures like steam vents and flow guide pits are prone to misidentification, enabling precise differentiation between abnormal defects and normal structures. Furthermore, by considering the spatial distribution characteristics of defects, the reliability of defect type determination is further improved, ensuring high robustness and accuracy of the detection results. Attached Figure Description
[0016] Figure 1 This is a flowchart of a vision-based method for detecting appearance defects in accessories according to an embodiment of the present invention. Detailed Implementation
[0017] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are some embodiments of the present invention, but not all embodiments.
[0018] The specific embodiments of the present invention will now be described in detail with reference to the accompanying drawings.
[0019] Reference Figure 1 The vision-based method for detecting defects in the appearance of accessories includes steps S1-S3, as detailed below:
[0020] S1: Collect the target image of the iron and the corresponding historical defect labels. The target image is any historical substrate grayscale image, and obtain the substrate grayscale image to be inspected.
[0021] In one embodiment, a high-resolution industrial camera is used to acquire RGB (red, green, blue) images of a batch of defective electric iron soleplate samples with known defect types and clearly defined defect locations under controlled lighting conditions. All acquired RGB images are converted to grayscale to obtain historical soleplate grayscale images, thereby reducing data dimensionality and highlighting structural and brightness variation characteristics. The defect serves as the defect label for each grayscale image, thus obtaining several historical soleplate grayscale images and the corresponding historical defect labels for each historical soleplate grayscale image.
[0022] The defect samples cover three typical types of defects: surface scratches, local pitting deformation (such as collapse or pressure loss of guide pits), and geometric deformation of steam vents (such as irregular vent diameter, edge collapse, etc.). Each defective substrate contains only one type of defect to ensure the clarity of sample labels and the relevance of subsequent model training. Similarly, grayscale images of the substrates to be detected are obtained.
[0023] S2: Obtain the connected components of the target image. Similarly, obtain the connected components of the grayscale image of the substrate to be detected. Obtain the defect connected components of the target image based on the actual defect location. Calculate the feature difference between the connected components of the grayscale image of the substrate to be detected and the defect connected components.
[0024] It should be noted that in the inspection of appearance defects in electric iron soleplate accessories, because the soleplate is usually made of highly reflective metal and has inherent structures such as regularly distributed circular steam holes and drainage pits on its surface, these normal structures will produce complex light and dark distributions and edge responses in the grayscale image due to light reflection, surface geometry, and changes in viewing angle. Especially when low-contrast defects such as shallow scratches, small pits, or local deformation of steam holes occur, the grayscale values and gradient features of their outline pixels are highly similar to those of the surrounding normal structures (such as hole edges and pit transition areas), resulting in blurred boundaries between the defect area and the background and extremely low distinguishability. Existing technologies mostly use global or local thresholding to binarize grayscale images and perform defect discrimination based on connected component analysis, but they rely solely on absolute pixel values and ignore the relative grayscale differences and gradient change trends between defects and normal structures in the local neighborhood. Therefore, it is easy to misjudge normal steam holes or flow guide pits in highly reflective areas as abnormal defects. At the same time, because the gray level of the defect area is close to that of the background, it may miss or misjudge real defects such as steam hole deformation and flow guide pit collapse as normal structures.
[0025] In one embodiment, any pixel in the target image is taken as the study point, and any preset direction is taken as the study direction, where the preset directions are 0 degrees, 45 degrees, 90 degrees, and 135 degrees. The gradient value of the study point in the study direction is calculated, the maximum gradient value in the study direction is obtained, the first ratio of the gradient value of the study point in the study direction to the maximum gradient value is calculated, the first ratio of each pixel in the study direction is obtained through iteration, the standard deviation of all ratios is calculated, the standard deviation of the ratio in each preset direction is obtained through iteration, and the mean of all standard deviations of ratios is taken as the first discriminant of the target image.
[0026] Calculate the second ratio of the pixel value of the study point to the maximum pixel value in the target image, and use the standard deviation of all second ratios as the second discrimination of the target image.
[0027] Calculate the first standard deviation of the first ratio of the study point in all preset directions, and obtain the first standard deviation of each pixel in the 8-neighborhood of the study point. Use the mean of all first standard deviations as the first edge probability of the study point.
[0028] The standard deviation of the second ratio of each pixel within an 8-neighborhood of the study point is used as the second marginal probability of the study point.
[0029] Calculate the third ratio of the sum of the first discrimination scores of all historical background grayscale images to the sum of the second discrimination scores of all historical background grayscale images; calculate the fourth ratio of the sum of the second discrimination scores of all historical background grayscale images to the sum of the first discrimination scores of all historical background grayscale images; calculate the first product of the third ratio and the first marginal probability; calculate the second product of the fourth ratio and the second marginal probability; and use the sum of the first product and the second product as the final marginal probability of the research point.
[0030] The logic behind the final edge probability is as follows: The first and second discriminative strengths characterize the degree of distribution difference between a local region and the surrounding background at a given location in the grayscale value dimension and gradient magnitude dimension, respectively. The ratio of the two is used to quantify the relative strength of the differences in these two dimensions. When the discriminative strength of one dimension is significantly higher than that of the other, it indicates that the dimension is more discriminative in representing edge features in the current region. The greater the discriminative strength, the stronger the contribution of that dimension to the discrimination of edge pixels, and therefore, it should be given higher weight in subsequent edge fusion or threshold decision-making, which helps to more accurately screen out true edge points and extract more accurate and complete connected components. At the same time, the first and second edge probabilities reflect the confidence level of a pixel being judged as an edge pixel based on grayscale change features and gradient response features, respectively, that is, the probability that the point belongs to the edge in its respective dimension. By comprehensively considering the discriminative strength ratio and the two-dimensional edge probabilities, adaptive weighted fusion of edge pixels can be achieved, effectively suppressing false detections and false negatives caused by defects such as high reflectivity, complex structure, or low contrast, and improving the robustness and accuracy of connected component extraction in defective regions.
[0031] The normalized final edge probability of each pixel in the target image is obtained by traversing the graph. Pixels with a normalized final edge probability greater than a preset threshold are designated as edge pixels. These edge pixels are then connected to obtain the connected components of the target image. Similarly, the connected components of the grayscale image of the substrate to be detected are obtained, and the defect connected components of the target image are obtained based on the actual defect locations.
[0032] Any connected region in the grayscale image of the substrate to be detected is taken as the detection region. The standard deviation of the curvature of all edge pixels in the detection region is taken as the first contour feature value. The standard deviation of the gradient magnitude of all edge pixels in the detection region is taken as the second contour feature value.
[0033] The average gradient of all pixels in the detection domain along the research direction is used as the first distribution feature value. The first distribution feature value of each preset direction is obtained by iterating through the domain to obtain the minimum and maximum first distribution feature values of the domain to be detected.
[0034] Based on the actual defect location in the target image, the defect connected region of the target image is obtained. Similarly, the first contour feature value, second contour feature value, minimum first distribution feature value, and maximum first distribution feature value of the defect connected region are obtained.
[0035] Calculate the first difference between the first contour feature value of the domain to be detected and the first contour feature value of the defect connected domain; calculate the second difference between the second contour feature value of the domain to be detected and the second contour feature value of the defect connected domain; and calculate the absolute value of the first product of the first difference and the second difference. Calculate the third difference between the maximum first distribution feature value of the domain to be detected and the maximum first distribution feature value of the defect connected domain; calculate the fourth difference between the minimum first distribution feature value of the domain to be detected and the minimum first distribution feature value of the defect connected domain; and calculate the absolute value of the second product of the third difference and the fourth difference. The sum of the absolute values of the first and second products is taken as the feature difference degree.
[0036] It should be explained that in the appearance defect inspection of electric iron soleplate accessories, because the soleplate is made of highly reflective metal material and has inherent structures such as regularly distributed circular steam holes and drainage pits on its surface, some defects (such as partial collapse of steam holes, edge deformation or slight deformation of drainage pits) are highly similar to normal structures in terms of traditional pixel values and gradient amplitudes, making it difficult to effectively distinguish them through conventional grayscale or edge intensity differences.
[0037] Meanwhile, the area, shape, and location of defect regions vary significantly among different defect samples, further increasing the complexity of detection. Existing technologies typically rely on pixel value differences at edge points within connected regions or single gradient features for defect discrimination. However, this method ignores the high similarity in edge gradient intensity between deformed steam vent defects and normal steam vents, as well as subtle differences in contour geometry. This can easily lead to misclassification of slightly deformed steam vents as normal structures, or misidentification of linear defects such as scratches as abnormal circular structures, resulting in missed detections or misclassifications.
[0038] To address this issue, this invention extracts the edge contours of suspected defective connected regions and then performs quantitative analysis from two key dimensions: first, it calculates the standard deviation of curvature of edge pixels to characterize the regularity of the contour shape (e.g., circular structures have stable curvature, while scratches or deformed structures have large curvature fluctuations); second, it calculates the standard deviation of the gradient magnitude of edge points to reflect the uniformity of local pixel responses. Furthermore, it further combines gradient change trends in multiple directions (e.g., horizontal, vertical, and diagonal) to distinguish between directional scratches and isotropic circular structures (e.g., steam vents).
[0039] In another embodiment, the feature difference degree further includes: for any preset direction, calculating the fifth difference between the first distribution feature value of the domain to be detected and the first distribution feature value of the defect connected domain, traversing to obtain the fifth difference value for each preset direction, and calculating the average of the fifth differences; calculating the first absolute difference between the fifth difference value and the average of the fifth differences in any preset direction, and calculating the cumulative value of the absolute differences in all preset directions; and using the sum of the absolute value of the first product and the cumulative value of the absolute differences as the feature difference degree.
[0040] It should be noted that the first contour feature value is used to quantify the geometric shape difference of the connected region contour itself. It measures the degree of deviation from the standard circular structure (such as a normal steam vent) by the curvature change. The more irregular the contour, the larger the feature value, indicating that it is more likely to be a defect such as a scratch, tear, or asymmetric deformation. The second contour feature value focuses on the pixel characteristic difference in the region adjacent to the connected region contour, that is, the stability of the gradient distribution, reflecting the degree of abnormality of the defect area and its surrounding background in imaging performance. The larger the value, the less similar the pixels around the contour are to the normal structural area, which helps to identify micro-pits or edge collapses with low contrast but abnormal structure. In addition, the first distribution feature value captures the directional sensitivity by analyzing the differences in pixel intensity or gradient energy distribution of the connected region in multiple directions (such as horizontal, vertical, diagonal, etc.): scratches usually show a significant linear distribution characteristic in a certain main direction, while circular structural deformation is relatively uniformly distributed in all directions.
[0041] S3: Treat the connected regions in the target image other than the defect connected regions as general regions, calculate the Euclidean distance between the centroids of the defect connected regions and the centroids of the general regions, and calculate the first standard deviation of all Euclidean distances in the target image. Similarly, obtain the second standard deviation of the grayscale image of the substrate to be inspected based on the calculation method of the first standard deviation. Calculate the degree of defect matching between the grayscale image of the substrate to be inspected and the target image based on the first standard deviation, the second standard deviation, and the feature difference degree, and complete the defect detection.
[0042] It should be noted that in the design of an electric iron soleplate, the positions of the steam vents and guide recesses are not randomly arranged, but precisely configured according to the steam flow path and heat transfer efficiency. This arrangement exhibits a highly fixed geometric distribution pattern and a clear spacing relationship, ensuring that steam can evenly and efficiently cover the entire ironing surface. In contrast, defects generated during manufacturing or use exhibit different spatial distribution characteristics: scratches typically have random directions and no fixed location or orientation; while abnormal dents (such as indentations or depressions) may appear in specific areas, their location, number, and arrangement do not follow the structural pattern between the steam vents and guide recesses.
[0043] However, existing defect detection technologies often focus only on local pixel or contour features when classifying defects, ignoring the fundamental differences between defects and normal structures in their overall spatial distribution patterns. For example, when a smooth indentation in a non-standard location appears in an area of the base plate that should be unstructured, the system may misclassify it as a normal structure because its shape and size are similar to a drainage indentation, thus missing the defect. While such misjudgments may seem visually plausible, in actual use, local protrusions or indentations can cause clothing to snag, snag, or even burn, seriously affecting product safety.
[0044] In one embodiment, defect connected regions in historical substrate grayscale images with the same historical defect labels are constructed as a defect set, and any defect set is used as a set to be matched; for any defect connected region in the set to be matched, the feature difference degree between the connected region of the substrate grayscale image to be detected and any defect connected region is obtained.
[0045] Calculate the second absolute difference between the first and second standard deviations of the distance, calculate the third product of the second absolute difference and the feature difference degree, iterate through each defect connected region in the set to be matched to obtain the third product, calculate the mean of the third products of all the third products, and take the exponent of the inverse of the mean of the third products as the defect matching degree.
[0046] The calculation logic for defect matching degree is as follows: By calculating the Euclidean distance distribution between the connected region to be detected and its neighboring structures or preset templates in the location space, and statistically analyzing the density characteristics of structural points within a unit area, it is possible to effectively quantify whether it conforms to the density law of a normal steam hole-guide pit layout. Normal structures, due to their regular layout, have density characteristics consistent with the template height, resulting in a smaller Euclidean distance. Scratches or random pits, lacking a systematic arrangement, have lower local densities, leading to a significantly increased Euclidean distance from normally distributed templates. Therefore, using Euclidean distance as a criterion for distribution density consistency can effectively help distinguish random defects from regular functional structures. When pixel and contour features are similar, it further improves the accuracy of defect type matching, avoiding misjudging abnormal pits as guide pits, thereby ensuring ironing safety and detection reliability.
[0047] Thus, the degree of defect matching between the grayscale image of the substrate to be detected and the historical grayscale images of the substrate under different defects can be obtained. In response to the degree of defect matching being greater than a preset threshold, the defect type of the grayscale image of the substrate to be detected can be determined. Moreover, the grayscale image of the substrate to be detected can contain multiple defect types, that is, multiple defect matching degrees are greater than the prediction threshold.
[0048] The system includes a processor and a memory, the memory storing computer program instructions, which, when executed by the processor, implement the vision-based method for detecting defects in the appearance of accessories according to the first aspect of the present invention.
[0049] The system also includes other components well known to those skilled in the art, such as communication buses and communication interfaces, the settings and functions of which are known in the art and will not be described in detail here.
[0050] It should be noted that those skilled in the art can make various modifications and improvements without departing from the inventive concept, and these all fall within the scope of protection of this invention. Therefore, the scope of protection of this patent should be determined by the appended claims.
Claims
1. A vision-based method for detecting appearance defects in accessories, characterized in that, include: Collect the target image of the iron and the corresponding historical defect labels. The target image is any historical grayscale image of the substrate, and obtain the grayscale image of the substrate to be inspected. Obtain the connected components of the target image, and similarly obtain the connected components of the grayscale image of the substrate to be detected. Obtain the defect connected components of the target image based on the actual defect location, and calculate the feature difference between the connected components of the grayscale image of the substrate to be detected and the defect connected components. The connected regions in the target image other than the defect connected region are taken as general regions. The Euclidean distance between the centroid of the defect connected region and the centroid of the general region is calculated. The first standard deviation of all Euclidean distances in the target image is calculated. The second standard deviation of the grayscale image of the substrate to be inspected is obtained by the same method as the calculation of the first standard deviation. The degree of defect matching between the grayscale image of the substrate to be inspected and the target image is calculated based on the first standard deviation, the second standard deviation and the feature difference degree, and the defect detection is completed.
2. The vision-based method for detecting appearance defects in accessories according to claim 1, characterized in that, The connected components of the target graph include: Take any pixel in the target image as the research point; The calculation of the first discriminative index of the target image includes: taking any preset direction as the study direction, where the preset directions are 0 degrees, 45 degrees, 90 degrees, and 135 degrees; calculating the gradient value of the study point in the study direction, obtaining the maximum gradient value in the study direction, calculating the first ratio of the gradient value of the study point in the study direction to the maximum gradient value, traversing to obtain the first ratio of each pixel in the study direction, calculating the standard deviation of all ratios, traversing to obtain the standard deviation of the ratio in each preset direction, and using the mean of all standard deviations of the ratios as the first discriminative index of the target image. Calculate the second ratio between the pixel value of the study point and the maximum pixel value in the target image, and use the standard deviation of all second ratios as the second discrimination index of the target image; Calculate the first standard deviation of the first ratio of the study point in all preset directions, and obtain the first standard deviation of each pixel in the 8 neighborhood of the study point. Use the mean of all first standard deviations as the first edge probability of the study point. The standard deviation of the second ratio of each pixel within an 8-neighborhood of the study point is used as the second marginal probability of the study point. The final marginal probability of the study point is calculated based on the first discriminant, the second discriminant, the first marginal probability, and the second marginal probability. The normalized final edge probability of each pixel in the target image is obtained by traversing the graph. Pixels with a normalized final edge probability greater than a preset threshold are taken as edge pixels. The edge pixels are then connected to obtain the connected components of the target image.
3. The vision-based method for detecting appearance defects in accessories according to claim 2, characterized in that, The final marginal probability of the calculated study point includes: Calculate the third ratio of the sum of the first discrimination of all historical background grayscale images to the sum of the second discrimination of all historical background grayscale images, and calculate the fourth ratio of the sum of the second discrimination of all historical background grayscale images to the sum of the first discrimination of all historical background grayscale images. Calculate the first product of the third ratio and the first marginal probability, and calculate the second product of the fourth ratio and the second marginal probability. The sum of the first and second products is taken as the final marginal probability of the research point.
4. The vision-based method for detecting appearance defects in accessories according to claim 1, characterized in that, The feature difference includes: Take any connected region in the grayscale image of the substrate to be detected as the detection region, and take the standard deviation of the curvature of all edge pixels in the detection region as the first contour feature value. The standard deviation of the gradient magnitude of all edge pixels in the detection domain is used as the second contour feature value. Take any preset direction as the research direction, where the preset directions are 0 degrees, 45 degrees, 90 degrees and 135 degrees. Take the average gradient of all pixels in the detection domain in the research direction as the first distribution feature value. Iterate through each preset direction to obtain the first distribution feature value, so as to obtain the minimum first distribution feature value and the maximum first distribution feature value of the detection domain. Based on the actual defect location in the target image, the defect connected region of the target image is obtained. Similarly, the first contour feature value, the second contour feature value, the minimum first distribution feature value, and the maximum first distribution feature value of the defect connected region are obtained. Calculate the first difference between the first contour feature value of the domain to be detected and the first contour feature value of the defect connected domain; calculate the second difference between the second contour feature value of the domain to be detected and the second contour feature value of the defect connected domain; and calculate the absolute value of the first product of the first difference and the second difference. Calculate the third difference between the maximum first distribution eigenvalue of the domain to be detected and the maximum first distribution eigenvalue of the defect connected domain; calculate the fourth difference between the minimum first distribution eigenvalue of the domain to be detected and the minimum first distribution eigenvalue of the defect connected domain; and calculate the absolute value of the second product of the third difference and the fourth difference. The sum of the absolute values of the first and second products is used as the feature difference.
5. The vision-based method for detecting appearance defects in accessories according to claim 4, characterized in that, The feature difference degree also includes: For any preset direction, calculate the fifth difference between the first distribution feature value of the domain to be detected and the first distribution feature value of the defect connected domain, iterate through each preset direction to obtain the fifth difference value, and calculate the average of the fifth differences. Calculate the first absolute difference between the fifth difference and the mean of the fifth differences in any preset direction, and calculate the cumulative value of the absolute differences in all preset directions; The sum of the absolute value of the first product and the cumulative value of the absolute difference is used as the feature difference degree.
6. The vision-based method for detecting appearance defects in accessories according to claim 1, characterized in that, The calculation of the defect matching degree between the grayscale image of the substrate to be inspected and the target image includes: Construct a defect set from the connected components of the historical base grayscale image with the same historical defect label, and use any defect set as the set to be matched. For any connected component of a defect in the set to be matched, obtain the feature difference degree between the connected component of the grayscale image of the substrate to be detected and any connected component of a defect; Calculate the second absolute difference between the first and second standard deviations of the distance, calculate the third product of the second absolute difference and the feature difference degree, iterate through each defect connected region in the set to be matched to obtain the third product, calculate the mean of the third products of all the third products, and take the exponent of the inverse of the mean of the third products as the defect matching degree.
7. A vision-based component appearance defect detection system, characterized in that, include: A processor and a memory, the memory storing computer program instructions that, when executed by the processor, implement the vision-based accessory appearance defect detection method according to any one of claims 1-6.
Citation Information
Patent Citations
Image feature template matching method being applied to detection of mobile phone screen defects
CN105894036A
Optical film surface flaw detection method and system, product and medium
CN119919387A