SIM card surface defect detection and analysis method
By constructing a template library and using multi-view image registration technology, combined with dynamic threshold segmentation, the accuracy and efficiency issues of SIM card surface defect detection were solved. The template library was adaptively optimized to adapt to the feature drift of production batches and reduce the need for manual maintenance.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-03-05
- Publication Date
- 2026-05-08
AI Technical Summary
Existing methods for detecting surface defects on SIM cards suffer from low accuracy, low efficiency, poor adaptability, difficulty in adapting to feature drift in production batches, and the need for frequent manual maintenance of template libraries.
A template library is constructed, and texture, color, and shape features are extracted by registering multi-scale templates with multi-view images. These features are then weighted and fused, and combined with dynamic threshold segmentation to achieve defect region identification. The template library is then optimized through incremental updates.
It improves detection accuracy and efficiency, reduces the rate of missed detections and false detections, and achieves adaptive optimization of the template library to meet the needs of large-scale production.
Smart Images

Figure QLYQS_9 
Figure QLYQS_10 
Figure QLYQS_12
Abstract
Description
Technical Field
[0001] This invention relates to the field of SIM card testing technology, and more specifically to a method for detecting and analyzing surface defects in SIM cards. Background Technology
[0002] As an integrated circuit chip and external interface, smart SIM cards have a wide range of applications. Surface defect detection during the production process is a core aspect of SIM card production quality control. SIM card surfaces are prone to defects such as scratches, abrasions, dirt, incomplete sealing, and misalignment. These defects not only affect the product's appearance consistency but may also cause functional failures, placing stringent requirements on detection accuracy, efficiency, and adaptability.
[0003] Existing methods for detecting surface defects on SIM cards suffer from several technical challenges: traditional methods often employ fixed-scale manual templates, which cannot adapt to dimensional deformations caused by changes in shooting distance or angle. Furthermore, template quality varies, manual updates are inefficient, and it is difficult to address feature drift in production batches. Multi-view images lack precise spatial alignment mechanisms, resulting in poor defect feature fusion and easy omission of edge or front / back defects. Feature extraction is simplistic, segmentation thresholds are fixed, and they are sensitive to noise and environmental changes, leading to high rates of missed and false detections. Static template libraries lack self-optimization capabilities, requiring frequent manual maintenance, and their adaptability and detection efficiency are insufficient to meet the demands of large-scale mass production. Summary of the Invention
[0004] The technical problem to be solved by the present invention is to overcome the shortcomings of the prior art and provide a method for detecting and analyzing defects on the surface of SIM cards.
[0005] This invention is achieved through the following technical solution: a method for detecting and analyzing defects on the surface of a SIM card, comprising the following steps: S1. Construct a template library that stores multi-scale templates to provide matching benchmarks and feature comparison basis for SIM card defect detection; S2. Acquire multi-view images from the SIM card, and after preprocessing, align the multi-view images to the same world coordinate reference using a homography matrix; S3. Extract texture, color, and shape features from the aligned image, and obtain comprehensive defect features through weighted fusion. ; S4. Multi-scale templates based on template library, combined with comprehensive defect features Perform adaptation and matching, and determine the defect area through dynamic threshold segmentation; S5. Classify and identify defective areas, and determine the defect level based on dynamic thresholds; S6. Based on the feature drift quantization results of the detection data, the template library is self-evolved and optimized through incremental updates and redundancy elimination.
[0006] In S2, the 3×3 homography matrix H is solved by the RANSAC algorithm, and the multi-view image space mapping is completed based on the homogeneous coordinate transformation relationship. After normalization and restoration, the registered 2D pixel coordinates are obtained, and finally all view images are aligned to the same world coordinate reference.
[0007] S3 includes the following sub-steps: S3-1. Extracting texture features T using the LBP algorithm. LBP ; S3-2, Extracting color features C from the HSV color space HSV ; S3-3, Constructing Hu invariant moments to extract shape features S Hu ; S3-4. Adaptively solve for the optimal fusion weight coefficients using the Bayesian optimization algorithm, and apply the optimal weight coefficients to the texture feature T. LBP Color feature C HSV Shape feature S Hu Perform weighted adaptive fusion to obtain comprehensive defect features .
[0008] S4 includes the following sub-steps: S4-1. Based on the multi-scale templates in the template library, construct a template pyramid according to the scale hierarchy, with each template layer corresponding to a preset defect size range; S4-2. Perform feature matching between the comprehensive defect feature map and each layer of the template pyramid, and calculate the matching confidence of each layer of template. S4-3. The improved OTSU algorithm is used to calculate the initial segmentation threshold. The initial threshold is then fine-tuned by combining Bayesian optimization to obtain the optimal defect segmentation threshold. Based on the optimal segmentation threshold, the comprehensive defect feature map is binarized to distinguish the defect region from the background region and determine the location, outline and pixel range of the defect region.
[0009] S4-1 includes the following sub-steps: S4-1-1. Based on historical defect samples of SIM cards, collect the equivalent diameter of each sample defect to form a defect size set D={d1,d2,…,d…} i ,…,d n}, where d i The equivalent diameter of the i-th defect, in μm; S4-1-2 Solving the defect size distribution function using kernel density estimation To clarify the probability density distribution characteristics of defect size; S4-1-3, Based on Size Distribution Function The scale levels are divided using an adaptive threshold segmentation method; S4-1-4, Using the original baseline template Based on this, corresponding hierarchical templates are generated according to the scale hierarchy, and a template pyramid P={T1,T2,…,T…} is constructed. m ,…,T k}, m=1,2,…,k, This is the template for the m-th layer.
[0010] Defect size distribution function in S4-1-2 The expression is as follows: ; Wherein, K( ) is the Gaussian kernel function. denoted as kernel bandwidth (adaptively solved through cross-validation), and n represents the total number of historical defect samples.
[0011] In S4-1-3, let the number of scale levels be k. The scale of the m-th layer template is defined as the conditional mean of the defect size within the corresponding size interval, as shown below: ; in, , Let m be the boundary of the defect size interval corresponding to the m-th layer scale, where m∈[1,k].
[0012] The m-th layer template in S4-1-4 The formula for generating it is: ; Where (x,y) are the template pixel coordinates; Represents a two-dimensional convolution operation; The kernel is a Gaussian smoothing kernel, and its kernel variance is... .
[0013] S4-2 includes the following sub-steps: S4-2-1. For the SIM card image I to be detected, construct an image scale space I that corresponds one-to-one with the template pyramid. m It is represented as follows: ; S4-2-2, Template for Extracting Scale-Invariant Feature Points Based on the feature point set of the image, the optimal matching feature points are selected, and spatial coordinate alignment is performed to obtain the alignment transformation matrix M. m ; S4-2-3. Based on the aligned features, calculate the matching confidence C between the template and the image region. m This serves as the basis for defect identification.
[0014] The formula for calculating the matching confidence level Cm is: ; in, The confidence threshold is set as follows. This indicates that image feature points Mapping back to the template coordinate system via inverse transformation, when Cm ≥ If the match is successful, it indicates that there is a defect in the corresponding region.
[0015] Compared with the prior art, the beneficial effects of the present invention are: This application addresses the pain points of existing technologies and improves detection accuracy, efficiency, adaptability, and practicality.
[0016] This application uses multi-scale template adaptive generation and dual-dimensional quality assessment to select high-quality templates and adapt them to deformations at different scales. Combined with multi-view image registration and intelligent fusion of multi-dimensional features, it effectively covers various niche and irregular defects, significantly reduces the risk of missed detections and false detections, and the detection accuracy far exceeds that of traditional methods.
[0017] Based on a hierarchical matching architecture and template pyramid design, it enables rapid adaptation and matching as well as parallel management of large-scale templates, avoiding invalid traversal and meeting the high efficiency requirements of real-time pipeline detection.
[0018] The template library is self-evolving and updated based on the drift of production data features, requiring no manual maintenance; key parameters are adaptively solved through intelligent algorithms, and dynamic thresholds are adjusted in real time, reducing manual intervention and operational dependence, avoiding human error, and ensuring long-term stable detection accuracy.
[0019] It is compatible with various SIM card surface defect types and can be flexibly configured to adapt to different product models; the matching results fully record core information, support defect data traceability and production process optimization, and have a wide range of applications. Detailed Implementation
[0020] The technical solutions in the embodiments of the present invention will be clearly and completely described below. Obviously, the described embodiments are only a part of the embodiments of the present invention, and not all of them. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of the present invention.
[0021] The specific steps of the SIM card surface defect detection and analysis method are as follows: S1. Construct a template library. The template library stores high-quality templates at multiple scales to provide matching benchmarks and feature comparison basis for SIM card defect detection.
[0022] The layered template library described in this embodiment includes a basic template layer, a dynamic update layer, and a candidate matching layer.
[0023] The basic template layer stores high-resolution image templates of standard SIM cards (including front and back, multi-view reference templates); the dynamic update layer iteratively optimizes template parameters and feature weights based on normal and defective sample data within a sliding time window; and the candidate matching layer quickly generates a temporary template subset adapted to the current scene for real-time detection images, improving matching efficiency.
[0024] S2. Acquire multi-view images from the SIM card, and after preprocessing, align the multi-view images to the same world coordinate reference using a homography matrix.
[0025] This application's image preprocessing includes: eliminating image noise through filtering; improving the accuracy of image geometric features by correcting geometric distortion; unifying image specifications to achieve consistency between images from different viewpoints; and enhancing the grayscale differences of chip edges based on the Laplacian sharpening algorithm to make the contours clearer and achieve key feature enhancement. Subsequently, the application locates and identifies the SIM card edges, identifies surface characters, locates the chip region, obtains the chip centroid, and acquires the chip contour features.
[0026] In S2, the 3×3 homography matrix H is solved by the RANSAC algorithm, and the multi-view image space mapping is completed based on the homogeneous coordinate transformation relationship. After normalization and restoration, the registered 2D pixel coordinates are obtained, and finally all view images are aligned to the same world coordinate reference.
[0027] Specifically, this embodiment uses multiple 12-megapixel high-speed industrial cameras to capture images of the front, back, and backlight angles of the SIM card. By capturing images of the front, back, and backlight-transmitting surfaces of the SIM card from multiple perspectives, a homography matrix is used to achieve perspective alignment and construct a spatial mapping relationship between images.
[0028] The chip image obtained by the industrial camera has its center in (x, y) coordinates, which is then converted to (u, v) coordinates in the world coordinate system.
[0029] The principle of pixel coordinate calculation is as follows: the source point involved in the calculation is the interior point (effective matching point) after RANSAC removes outliers. Outliers are directly discarded, and only the interior points participate in the registration coordinate calculation. The pixel coordinate transformation is based on homogeneous coordinates (the homography matrix is 3×3, which only satisfies the matrix multiplication rule with homogeneous coordinates), and then the actual pixel coordinates (non-homogeneous) are obtained by normalizing the homogeneous coordinates.
[0030] Furthermore, let the pixel coordinates of the preprocessed original image be (u,v) and the pixel coordinates of the registered image be (u′,v′). Then the homogeneous coordinates of the original image pixels are (u,v,1) and the homogeneous coordinates of the registered image pixels are (u′,v′,1).
[0031] This application achieves homogeneous coordinate mapping using the homography matrix H. The homogeneous coordinates of the registered target point P′ are... , The homography transformation formula is obtained by left-multiplying H by the homogeneous coordinates of the source point P(u′,v′,w), i.e., the homography transformation formula is: .
[0032] The homography matrix H is represented in matrix form as follows: .
[0033] The component expansion formula is: ; Where w is the homogeneous coordinate scale factor, w is non-zero, and is determined by H and the source point coordinates (u,v).
[0034] According to the definition of homogeneous coordinates, three-dimensional homogeneous coordinates The corresponding two-dimensional Cartesian coordinates are: ; ; Will and Substituting the expression, we obtain the pixel coordinates, which are represented as follows: ; ; After a special normalization process, h33=1, the final pixel is: ; .
[0035] S3. Extract texture, color, and shape features from the aligned image, and obtain comprehensive defect features through weighted fusion.
[0036] S3 includes the following sub-steps: S3-1. Extract texture features T using the LBP algorithm (LBP Local Binary Mode). LBP The expression is: ; In the formula, The grayscale value of the center pixel. Let s( be the gray value of the p-th pixel in the 8-neighborhood of the center pixel) Let ) be a symbolic function, and its complete mathematical expression is: .
[0037] S3-2, Extract color features C from the HSV color space (HSV color space mean feature). HSV The expression is: ; In the formula, M×N is the pixel size of the feature region. , , These represent the hue, saturation, and lightness components of the pixel at coordinates (x, y) in the image.
[0038] S3-3, Constructing Hu invariant moments to extract shape features S Hu In this embodiment, seven Hu invariant moments are constructed using second- and third-order central moments to achieve scale invariance, rotation invariance, and translation invariance of the shape features, denoted as . =[ 1, 2, 3, 4, 5, 6, 7).
[0039] S3-4. Adaptively solve for the optimal fusion weight coefficients using the Bayesian optimization algorithm, and apply the optimal weight coefficients to the texture feature T. LBP Color feature C HSV Shape feature S Hu Perform weighted adaptive fusion to obtain comprehensive defect features .
[0040] For texture feature T LBP Color feature C HSV Shape feature S Hu Weighted adaptive fusion is performed to enhance the contribution of effective features, satisfying the constraint that the sum of the weights is 1, and thus obtaining comprehensive defect features. The formula for obtaining the comprehensive defect characteristics is as follows: ; in, , , Texture features T LBP Color feature C HSV Shape feature S Hu The weighting coefficients.
[0041] When solving for the optimal fusion weight coefficients, a Bayesian optimization objective function is constructed with the feature fusion weights and deep learning model hyperparameters as optimization objectives to minimize the defect identification error. The objective function is: ; in, The set of parameters to be optimized (including weight coefficients) , , (and the learning rate, kernel size, iteration stride, etc. of deep learning models). For the feasible region of the parameters; For defect identification loss function, Let i be the true defect label of the i-th sample. For the model in parameters The prediction results are given below, where N is the total number of samples.
[0042] S4. Multi-scale templates based on template library, combined with comprehensive defect features Adaptation and matching are performed, and defect areas are determined through dynamic threshold segmentation.
[0043] To address defects of different sizes on the surface of SIM cards, this embodiment dynamically generates a multi-scale template pyramid. Through scale spatial feature alignment technology, it achieves accurate matching of defects of different sizes and locations, avoiding the problems of missed detection and false detection in traditional fixed-scale templates.
[0044] S4 includes the following sub-steps: S4-1. Based on the multi-scale templates in the template library, construct a template pyramid according to the scale hierarchy, with each template layer corresponding to a preset defect size range; S4-1 includes the following sub-steps: S4-1-1. Based on historical defect samples of SIM cards, collect the equivalent diameter of each sample defect to form a defect size set D={d1,d2,…,d…} i ,…,d n}, where d i The equivalent diameter of the i-th defect, in μm; S4-1-2 Solving the defect size distribution function using kernel density estimation Define the probability density distribution characteristics of defect size, and the defect size distribution function. The expression is as follows: ; Wherein, K( ) is the Gaussian kernel function, whose standard form is: ; denoted as kernel bandwidth (adaptively solved through cross-validation), n is the total number of historical defect samples, and d is the equivalent size feature of the defect.
[0045] S4-1-3, Based on Size Distribution Function An adaptive threshold segmentation method is used to divide the scale levels. Let the number of scale levels be k. The template scale of the m-th level (m∈[1,k]) is defined as the conditional mean of the defect size within the corresponding size interval, as follows: ; in, , Let m be the boundary of the defect size interval corresponding to the m-th layer scale, satisfying: ; , These are the minimum and maximum sizes of historical defects, respectively, and the intervals of any two different levels have no overlap, i.e.: .
[0046] S m This is the average equivalent diameter of all defects within the m-th layer interval, used to determine the size of the detection template for that layer, i.e., the scale level size. This embodiment, based on a historical defect sample library of SIM cards, statistically analyzes the probability density distribution of defect sizes and adaptively divides the template scale levels to ensure that each scale level accurately covers defects within its corresponding size range.
[0047] S4-1-4, Using the original baseline template Based on this, corresponding hierarchical templates are generated according to the scale level, and a template pyramid P={T1,T2,…,T…} is constructed. m ,…,T k}, m=1,2,…,k, This is the template for the m-th layer.
[0048] m-th layer template The formula for generating it is: ; Where (x,y) are the template pixel coordinates; Represents a two-dimensional convolution operation; The kernel is a Gaussian smoothing kernel, and its kernel variance is... . The smoothing kernel variance changes positively with the scale level. The higher the level (corresponding to the larger the defect size), the larger the smoothing kernel variance, so as to effectively suppress the high-frequency noise introduced during the scaling process.
[0049] S4-2. Perform feature matching between the comprehensive defect feature map and each layer of the template pyramid, and calculate the matching confidence of each layer of template. S4-2 includes the following sub-steps: S4-2-1. For the SIM card image I to be detected, construct an image scale space I that corresponds one-to-one with the template pyramid. m It is represented as follows: ; S4-2-2, Template Extraction Based on Scale Invariant Feature Points (SIFT) Using the feature point set of image I, the optimal matching feature points are selected, and spatial coordinate alignment is performed to obtain the alignment transformation matrix M. m .
[0050] Set template The feature point set is F m ={f m,1 f m,2 ,…,f m,i ,…,f m,t The feature point set of image I is E. m ={e m,1 e m,2 , ..., e m,s}
[0051] f is obtained by filtering using the K-Nearest Neighbors (KNN) matching algorithm. m,i Optimal matching feature points in Em Then, spatial coordinate alignment is achieved through feature point matching, and the alignment transformation matrix M is solved. m The solution formula is as follows: ; in, M is the Euclidean distance, and the alignment transformation matrix is... m Specifically, it is a 6-DOF affine transformation matrix, which is solved using the least squares method.
[0052] S4-2-3. Based on the aligned features, calculate the matching confidence C between the template and the image region. m This serves as the basis for defect identification. Matching confidence level C m The calculation formula is: ; in, The confidence threshold is set to 0.5 by default, but can be dynamically adjusted according to the required detection accuracy. This indicates that image feature points Map back to the template coordinate system via inverse transformation. When C m ≥ If the match is successful, it indicates that there is a defect in the corresponding region.
[0053] This embodiment introduces a scale-space feature mapping and spatial coordinate alignment mechanism to achieve accurate matching of defect features at different scales and locations.
[0054] S4-3. Calculate the initial segmentation threshold using the improved OTSU algorithm. By combining Bayesian optimization to fine-tune the initial threshold T, the optimal defect segmentation threshold is obtained. Based on the optimal segmentation threshold, the comprehensive defect feature map is binarized to distinguish the defect area from the background area, and the location, outline and pixel range of the defect area are accurately determined.
[0055] Based on the statistical characteristics of production data, the similarity threshold is adjusted in real time to fuse features from multiple dimensions. Based on this, an improved Otsu's method (OTSU) is used to calculate the initial segmentation threshold. This method achieves optimal segmentation of the two types of regions by maximizing the inter-class variance between the defect region and the background region.
[0056] The total number of pixels in the fused feature map is The gray level range of the feature value is [0, L-1], and the number of pixels with feature value i is... Then pixel probability for: ; The image is divided into defect regions using a threshold T as the boundary. and background area Two categories.
[0057] Pixel ratio of defective areas ; Background area pixel ratio ; Mean of defect region characteristics ; Background region feature mean ; Global feature mean .
[0058] Between-class variance is a core indicator for measuring the difference between defects and background. A larger between-class variance indicates a more significant difference in features between the two classes, resulting in better segmentation. The calculation formula is as follows: .
[0059] The initial threshold T is the solution that maximizes the inter-class variance G(T), and it is expressed as follows: .
[0060] To address the noise sensitivity of traditional OTSU, a multi-feature weight constraint is introduced, which assigns weights to texture, color, and shape features. , , Incorporating inter-class variance calculation, denoted as This strengthens the contribution of effective features. It is expressed as follows: ; in, , and The inter-class variances were calculated separately for texture, color, and shape features, and the final initial threshold was adjusted as follows: .
[0061] The initial threshold T is included in the parameter set after Bayesian optimization. Combined with defect identification loss function The feedback enables adaptive fine-tuning of the threshold, further improving segmentation accuracy and thus achieving dynamic segmentation with the optimal threshold.
[0062] S5. Classify and identify defective areas (such as scratches, dirt, and missing seals), and determine the defect level based on dynamic thresholds. The classification of SIM card defect types (such as scratches, dirt, missing seals, etc.) and defect levels can be determined according to the actual product settings (such as classifying defect types and defect levels based on parameters such as the area, size, and quantity of identified defects), and will not be elaborated here.
[0063] S6. Template Library Iterative Update: Based on the feature drift quantization results of the detection data, the template library is self-evolved and optimized through incremental updates and redundancy elimination.
[0064] This embodiment constructs a three-dimensional quantitative evaluation index system to quantitatively assess the comprehensive data value of each template; the calculation formula is as follows: ; Where V represents the overall value of the template data. , , These are the weighting coefficients for the corresponding access frequency, timeliness, and identification contribution, respectively.
[0065] The definitions of each dimension's indicators and weighting coefficients are as follows: F represents the template access frequency, which is the actual number of times the template has been used for feature matching in the past 30 days. The metric is positively correlated with data value; the lower the access frequency, the lower the quantitative value of the corresponding template. T represents the timeliness of the template, which is the time difference between the current time and the last time the template was last updated. A timeliness expiration threshold Texp is set (the threshold is determined by the business iteration cycle of the production scenario). The larger the time difference, the lower the timeliness index, and the lower the quantitative value of the corresponding template. C represents the template recognition contribution: the value is the percentage increase in accuracy when the template participates in the target recognition task. The indicator is positively correlated with the data value. The lower the contribution, the lower the quantitative value of the corresponding template. , , The weighting coefficients for access frequency, timeliness, and identification contribution are respectively, and must meet the following constraints: The weight coefficients are adaptively solved using a Bayesian optimization algorithm, which can accurately match the differentiated data value orientation under different production scenarios.
[0066] This application also performs low-value template screening, with the screening rule being a dynamically set value threshold. Filter out those that meet the requirements The template was determined to be a low-value template.
[0067] Complete the quantitative calculation of the comprehensive data value V for all templates in the template library, and execute it on a daily cycle, such as during daily shift handover or during the batch production change phase of the production control system; Dynamic value threshold The system dynamically adjusts based on two dimensions: the size of the template library and the core requirements of the business side for recognition accuracy. Based on this threshold, it can accurately screen low-value templates.
[0068] This embodiment integrates newly added normal samples into the template library after feature verification, and adaptively forgets low-frequency defect samples and expired data to ensure the timeliness and conciseness of the template library; at the same time, based on the defect type clustering results, it supplements exclusive templates to enhance the identification ability of niche defects.
[0069] The above description is merely an optional embodiment of the present invention and does not limit the patent scope of the present invention. Any equivalent structural transformations made using the content of the present invention under the concept of the present invention, or direct / indirect applications in other related technical fields, are included within the patent protection scope of the present invention.
Claims
1. A method for detecting and analyzing defects on the surface of a SIM card, characterized in that, Includes the following steps: S1. Construct a template library that stores multi-scale templates to provide matching benchmarks and feature comparison basis for SIM card defect detection; S2. Acquire multi-view images from the SIM card, and after preprocessing, align the multi-view images to the same world coordinate reference using a homography matrix; S3. Extract texture, color, and shape features from the aligned image, and obtain comprehensive defect features through weighted fusion. ; S4. Multi-scale templates based on template library, combined with comprehensive defect features Perform adaptation and matching, and determine the defect area through dynamic threshold segmentation; S5. Classify and identify defective areas, and determine the defect level based on dynamic thresholds; S6. Based on the feature drift quantization results of the detection data, the template library is self-evolved and optimized through incremental updates and redundancy elimination.
2. The SIM card surface defect detection and analysis method according to claim 1, characterized in that, In S2, the 3×3 homography matrix H is solved by the RANSAC algorithm, and the multi-view image space mapping is completed based on the homogeneous coordinate transformation relationship. After normalization and restoration, the registered 2D pixel coordinates are obtained, and finally all view images are aligned to the same world coordinate reference.
3. The SIM card surface defect detection and analysis method according to claim 1, characterized in that, S3 includes the following sub-steps: S3-1. Extracting texture features T using the LBP algorithm. LBP ; S3-2, Extracting color features C from the HSV color space HSV ; S3-3, Constructing Hu invariant moments to extract shape features S Hu ; S3-4. Adaptively solve for the optimal fusion weight coefficients using the Bayesian optimization algorithm, and apply the optimal weight coefficients to the texture feature T. LBP Color feature C HSV Shape features S Hu Perform weighted adaptive fusion to obtain comprehensive defect features .
4. The SIM card surface defect detection and analysis method according to claim 1, characterized in that, S4 includes the following sub-steps: S4-1. Based on the multi-scale templates in the template library, construct a template pyramid according to the scale hierarchy, with each template layer corresponding to a preset defect size range; S4-2. Perform feature matching between the comprehensive defect feature map and each layer of the template pyramid, and calculate the matching confidence of each layer of template. S4-3. The improved OTSU algorithm is used to calculate the initial segmentation threshold. The initial threshold is adjusted by combining Bayesian optimization to obtain the optimal defect segmentation threshold. Based on the optimal segmentation threshold, the comprehensive defect feature map is binarized to distinguish the defect area from the background area and determine the location, outline and pixel range of the defect area.
5. The SIM card surface defect detection and analysis method according to claim 4, characterized in that, S4-1 includes the following sub-steps: S4-1-1. Based on historical defect samples of SIM cards, collect the equivalent diameter of each sample defect to form a defect size set D={d1,d2,…,d…} i ,…,d n }, where d i The equivalent diameter of the i-th defect, in μm; S4-1-2 Solving the defect size distribution function using kernel density estimation To clarify the probability density distribution characteristics of defect size; S4-1-3, Based on Size Distribution Function The scale levels are divided using an adaptive threshold segmentation method; S4-1-4, Using the original baseline template Based on this, corresponding hierarchical templates are generated according to the scale hierarchy, and a template pyramid P={T1,T2,…,T…} is constructed. m ,…,T k }, m=1,2,…,k, This is the template for the m-th layer.
6. The SIM card surface defect detection and analysis method according to claim 5, characterized in that, Defect size distribution function in S4-1-2 The expression is as follows: ; Wherein, K( ) is the Gaussian kernel function. Where n is the kernel bandwidth and n is the total number of historical defect samples.
7. The SIM card surface defect detection and analysis method according to claim 6, characterized in that, In S4-1-3, let the number of scale levels be k. The scale of the m-th layer template is defined as the conditional mean of the defect size within the corresponding size interval, as shown below: ; in, , Let m be the boundary of the defect size interval corresponding to the m-th layer scale, where m∈[1,k].
8. The SIM card surface defect detection and analysis method according to claim 7, characterized in that, The m-th layer template in S4-1-4 The formula for generating it is: ; Where (x,y) are the template pixel coordinates; Represents a two-dimensional convolution operation; The kernel is a Gaussian smoothing kernel, and its kernel variance is... .
9. The SIM card surface defect detection and analysis method according to claim 8, characterized in that, S4-2 includes the following sub-steps: S4-2-1. For the SIM card image I to be detected, construct an image scale space I that corresponds one-to-one with the template pyramid. m It is represented as follows: ; S4-2-2, Template for Extracting Scale-Invariant Feature Points Based on the feature point set of the image, the optimal matching feature points are selected, and spatial coordinate alignment is performed to obtain the alignment transformation matrix M. m ; S4-2-3. Based on the aligned features, calculate the matching confidence C between the template and the image region. m This serves as the basis for defect identification.
10. The SIM card surface defect detection and analysis method according to claim 9, characterized in that, The formula for calculating the matching confidence level Cm is: ; in, The confidence threshold is set as follows. This indicates that image feature points Mapping back to the template coordinate system via inverse transformation, when Cm ≥ If the match is successful, it indicates that there is a defect in the corresponding region.