An industrial product surface defect image analysis method for a few-shot scenario
By constructing a local texture data matrix and performing singular value decomposition and orthogonal projection, combined with iterative reconstruction and adaptive threshold segmentation, the accuracy problem of surface defect detection in industrial products under few-sample scenarios is solved, achieving precise decoupling of background and defects and efficient capture of weak defects.
Patent Information
- Application Number
- CN202511986500.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-26
- Publication Date
- 2026-03-03
- Estimated Expiration
- 2045-12-26
AI Technical Summary
In scenarios with few samples, existing technologies struggle to effectively distinguish between the background structure of industrial product surfaces and local abnormal signals, leading to the loss of high-frequency texture details and inaccurate defect detection.
By constructing a local texture data matrix, extracting principal components of good texture using singular value decomposition, performing orthogonal subspace projection, truncating unstructured noise components, and combining iterative reconstruction and adaptive threshold segmentation, accurate decoupling of background signal and defect noise is achieved.
Accurately capture subtle defects against complex texture backgrounds, reduce background assimilation, improve the accuracy of defect detection and contrast difference residual signals, adapt to changes in curved surface textures, and reduce the computational power required for 3D reconstruction.
Smart Images

Figure CN121391886B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to an image analysis method for surface defects of industrial products in scenarios with few samples, belonging to the field of image data processing technology. Background Technology
[0002] In current precision industrial manufacturing processes, surface defect detection is a key process to ensure yield. In large-scale stable production scenarios, supervised deep learning models achieve high accuracy through training on massive samples. However, in scenarios involving the introduction of new products or multiple batches of small-volume production with few samples, due to the lack of sufficient defect samples to fit the texture distribution, the industry typically adopts an unsupervised detection strategy based on image reconstruction. This strategy utilizes the non-local self-similarity of good product textures, searches for similar patches in the neighborhood, calculates the statistical mean to reconstruct the background, and extracts defect signals by comparing the differences between the original image and the reconstructed background.
[0003] Existing pixel-based grayscale statistical reconstruction methods face fundamental challenges when processing complex geometric features of industrial components. High-quality industrial products commonly exhibit high-frequency structural textures such as chamfers, scale lines, or metal brushing on their surfaces. Various minute defects also manifest as high-frequency abrupt signals in the frequency domain. Traditional weighted averaging algorithms, essentially low-pass filtering operations, cannot mathematically distinguish between structured high-frequency background information and unstructured abnormal information from defects. Suppressing noise using scalar statistical smoothing mechanisms leads to the loss of high-frequency details in the background texture. To compensate for the lack of single-dimensional information, existing technologies attempt to introduce complex acquisition and fusion methods, relying solely on stacked hardware imaging systems and attempting to fuse them through software algorithms. However, this approach has limitations in practical applications. For example, Chinese invention patent application CN120953741A discloses a multi-channel image adaptive fusion method and system for detecting surface defects in industrial products. This scheme acquires multi-channel data through multi-angle, multi-source imaging, presets Laplacian operator or Hessian matrix feature extraction rules for specific defects such as scratches and dents, and performs multi-resolution fusion within the pyramid frequency domain.
[0004] Therefore, simply adjusting parameters or increasing the number of good samples cannot solve the frequency domain smoothing trap introduced by the signal processing logic itself. Establishing an accurate decoupling mechanism between the image background structure and local abnormal signals, preserving complex texture topological features, and keenly capturing weak defect image analysis mechanisms has become the technical problem to be solved by this invention. Summary of the Invention
[0005] To address the problems mentioned in the background art, the technical solution of the present invention is as follows: A method for analyzing surface defects of industrial products in scenarios with few samples, comprising the following steps:
[0006] Acquire the surface grayscale image data of the product to be analyzed, calculate the structure tensor matrix of each pixel in the surface grayscale image data, and generate an anisotropy map representing the intensity of texture directionality based on the eigenvalue decomposition results of the structure tensor matrix.
[0007] Centered on each local patch of the surface grayscale image data, multiple reference patches with structural similarity are searched within a preset search neighborhood based on the structural tensor matrix. The multiple reference patches are vectorized and arranged in columns to form a local texture data matrix.
[0008] Perform singular value decomposition on the local texture data matrix, extract the left singular vectors corresponding to the top k largest singular values, and span the principal subspace representing the distribution of good textures in the current local region by the left singular vectors;
[0009] Construct a projection operator that projects onto the principal subspace. Use the projection operator to perform orthogonal projection on the vectors corresponding to the local tiles. Truncate the null space components orthogonal to the principal subspace in the vectors as unstructured noise components to generate reconstructed background tiles.
[0010] All reconstructed background image patches are stitched together to form a full-frame reconstructed background image. The grayscale difference map between the surface grayscale image data and the full-frame reconstructed background image is calculated, and adaptive threshold segmentation is performed based on the grayscale difference map to extract defect features.
[0011] Preferably, the step of performing singular value decomposition on the local texture data matrix includes: stretching the selected K reference patches into column vectors of dimension d to construct a local texture data matrix of dimension d multiplied by K; performing singular value decomposition on the local texture data matrix to obtain the left singular matrix, and truncating the first r column vectors of the left singular matrix as the principal subspace basis vectors, where r is the truncation rank dynamically set according to the singular value decay characteristics of the local texture data matrix; and performing orthogonal projection operation on the vectors corresponding to the local patches using the projection operator includes: calculating the projection components of the vectors on the principal subspace basis vectors, using the projection components as the reconstructed background texture signal, and defining the residual vector obtained by subtracting the projection components from the vector as the null space component.
[0012] Preferably, the process of searching for multiple reference tiles with structural similarity and generating reconstructed background tiles adopts an iterative optimization process that includes primary screening and secondary refinement. The iterative optimization process includes: performing a first round of reference tile search and orthogonal projection reconstruction, extracting a primary defect mask based on the generated grayscale difference map; marking the region in the surface grayscale image data corresponding to the primary defect mask as the search mask region; performing a second round of reference tile search, excluding tiles whose center pixels fall into the search mask region during the search process, reconstructing the local texture data matrix based on the reference tiles that do not fall into the search mask region, and performing singular value decomposition and orthogonal projection operations.
[0013] Preferably, the step of searching for multiple reference patches with structural similarity further includes: calculating the texture principal orientation angle of each pixel based on the eigenvectors of the structural tensor matrix; calculating the difference in texture principal orientation angles between the current local patch and the candidate reference patch; constructing a rotation transformation matrix based on the difference in texture principal orientation angles; performing inverse rotation calibration on the candidate reference patch using the rotation transformation matrix; and using the calibrated patch to construct a local texture data matrix.
[0014] Preferably, the step of calculating the grayscale difference map between the surface grayscale image data and the fully reconstructed background image includes: constructing a first structural tensor field based on the surface grayscale image data, and constructing a second structural tensor field based on the fully reconstructed background image; calculating the tensor matrix norm difference between the first structural tensor field and the second structural tensor field pixel by pixel to generate a tensor difference feature map; and performing weighted fusion of the tensor difference feature map with the basic difference map calculated based on the pixel grayscale difference to obtain a grayscale difference map for adaptive threshold segmentation.
[0015] Preferably, the step of performing adaptive thresholding based on the grayscale difference map includes: statistically analyzing the singular value distribution characteristics of the local texture data matrix and calculating the reconstruction entropy index, which characterizes the reliability of local texture reconstruction; generating a dynamic threshold matrix of the same size as the surface grayscale image data based on the reconstruction entropy index, wherein the threshold value of each point in the dynamic threshold matrix is positively correlated with the reconstruction entropy index; and using the dynamic threshold matrix to perform point-by-point comparison of the grayscale difference map to obtain a binarized defect mask.
[0016] Preferably, before performing adaptive thresholding on the grayscale difference map, a basis correction step based on the statistical properties of the residual histogram is further included. The basis correction step calculates the corrected dynamic segmentation threshold according to the following formula. : ,in, The preset base threshold, This is the sensitivity adjustment coefficient. This represents the full width and height (FWHM) of the grayscale histogram of the current grayscale difference image. The half-width and height of the residual histogram under the preset baseline defect-free state.
[0017] Preferably, after performing adaptive threshold segmentation on the grayscale difference image, the method further includes: extracting connected regions in the grayscale difference image that exceed the threshold as candidate defect regions; calculating the geometric morphological features and texture statistical features of the candidate defect regions; mapping the geometric morphological features and texture statistical features to a preset feature space, calculating the Euclidean distance between them and the pre-stored few-sample defect prototype vectors, and classifying the candidate defect regions into the category to which the nearest defect prototype belongs.
[0018] Preferably, the step of calculating the structure tensor matrix of each pixel includes: calculating the gradient of the surface grayscale image data in the horizontal and vertical directions; calculating the outer product matrix of the gradient, and performing Gaussian smoothing filtering on the outer product matrix to generate the structure tensor matrix; the step of generating the anisotropy map includes: calculating the maximum and minimum eigenvalues of the structure tensor matrix, and using the ratio of the difference between the maximum and minimum eigenvalues to the sum of the maximum eigenvalues as the anisotropy of the pixel.
[0019] Preferably, the steps of constructing the projection operator for projection onto the principal subspace include: constructing a projection matrix using the left singular vector, the projection matrix being equal to the sum of the products of the left singular vector and its transpose; the steps of truncating the null space components orthogonal to the principal subspace in the vector as unstructured noise components include: retaining the projection components of the vectors corresponding to the local tiles in the principal subspace through the projection matrix, thereby eliminating random noise components and non-repetitive defect components located in the null space.
[0020] Compared with the prior art, the beneficial effects of the present invention are:
[0021] 1. In the analysis of surface defects in industrial products, a linear subspace of local texture data matrix is constructed. Singular value decomposition is used to extract principal component vectors representing the texture of good products. The background reconstruction is transformed from pixel weighted averaging to orthogonal subspace projection. By utilizing the low-rank characteristics of the local neighborhood of industrial good product texture and the sparse characteristics of random defects, the structured texture components of the test block are retained in the principal subspace, while the unstructured abnormal components are truncated in the null space, thus achieving accurate decoupling between background signals and defect noise.
[0022] 2. A feedback loop for searching taboo domains based on initial detection results is introduced. During iterative reconstruction, a logical mask is used to remove potential defect areas and participate in the background reference patch selection. A self-correcting process from coarse screening to fine finishing is constructed to prevent large-area or repetitive defects from being misidentified as normal textures and participating in the background synthesis path. This ensures the purity of the reconstructed image and enables the system to maintain a high contrast difference residual signal when facing dense defect groups, overcoming the defect assimilation phenomenon common in non-local self-similarity algorithms.
[0023] 3. By reusing the structural tensor to calculate and generate the main direction data of the texture, a virtual rotation calibration logic for local patches is established to achieve adaptive matching of three-dimensional curved surface texture distortion in two-dimensional pixel space. Before calculating the similarity, candidate patches are rotated and aligned in reverse based on the difference of the main direction to eliminate the influence of texture phase deflection caused by the curvature change of the product surface. This enables the single-view planar image analysis algorithm to overcome spatial position differences and capture the texture consistency of curved surface parts. It solves the problem of background suppression of complex geometric surfaces without the need for three-dimensional reconstruction computing power. Attached Figure Description
[0024] Figure 1This is a flowchart of the defect analysis method based on orthogonal subspace projection of the present invention;
[0025] Figure 2 This is a graph showing the correlation between the structural tensor eigenvalues and anisotropy of the present invention.
[0026] Figure 3 This is a schematic diagram of the hardware and software collaborative detection system architecture and data interaction of the present invention. Detailed Implementation
[0027] The present invention will be described in detail below with reference to specific embodiments. It should be understood that the specific embodiments described herein are merely for explaining the present invention and are not intended to limit the scope of protection of the present invention.
[0028] This invention provides a method for analyzing surface defects in industrial products in scenarios with few samples. It consists of four core processing stages: a feature space construction stage based on structural tensors, a background reconstruction stage based on low-rank projection of local manifolds, a mask purification stage based on iterative feedback, and a defect decision stage based on adaptive statistical properties. Each stage interacts with a defined data flow to transform a single-channel grayscale image into a defined binary defect mask. The structural tensor field provides topological guidance for subsequent similarity block search and geometric calibration, while the projection operator derived from singular value decomposition serves as the core filter, achieving orthogonal decoupling between the good product background and the defect signal within the feature subspace. Addressing the problem of blurring and artifacts easily occurring during the reconstruction of complex textures on industrial product surfaces, this invention establishes a feature perception procedure based on anisotropic structural tensors. The system adopts the following defined algorithm path: Input the single-channel grayscale image data to be analyzed. Perform gradient calculation on it, using The Sobel operator calculates the gradient of the image in the horizontal direction. and the gradient in the vertical direction Construct pixel-level gradient outer product matrices and introduce standard deviation. Gaussian kernel of 1.5 pixels Perform pointwise convolution smoothing on the outer product matrix to generate the structure tensor matrix. For any pixel in the image Its structural tensor matrix Defined as: ,in, For pixels The horizontal gradient at that point For pixels Vertical gradient at that point This represents the convolution operation, based on this matrix. The system further performs eigenvalue decomposition to obtain the principal eigenvalues. and secondary eigenvalues (in Using these two feature values, the system calculates the anisotropy degree of the pixel. The degree of anisotropy Quantifying the geometric strength of a local region: when When the value approaches 1, it indicates that the region has strong linear texture or edges; when... When the value approaches 0, it indicates that the region is an isotropic flat region or a noisy region. This quantitative indicator is used as a core weight factor and is input into the subsequent similar patch search module.
[0029] After constructing the feature space, this invention performs background reconstruction based on local manifold low-rank projection. This scheme employs a subspace projection strategy to separate the background from defects. The specific implementation procedure is as follows: For each dimension in the image... Local patch of pixels to be reconstructed The system is centered on it, in the defined Within the pixel search window, filters are performed based on Euclidean distance and structural tensor similarity. For example The system will select the most similar reference tile. Each reference tile is stretched into a dimension. The column vectors are arranged in columns to construct a local texture data matrix. Execution matrix In-situ DC component stripping procedure, for arbitrary column vectors Calculate the scalar mean strength Perform vector subtraction operation By physically isolating low-frequency illumination gradients from high-frequency geometric topological features, the principal singular values are forced to represent only texture structural similarity, and the mean of the vector to be reconstructed is latched synchronously. Used for subsequent background grayscale linear restoration For the matrix Perform singular value decomposition, i.e. In the formula, It is a left singular matrix. It is a singular value diagonal matrix. Given a right singular matrix, the system dynamically determines the truncated rank based on the criterion that the cumulative contribution rate of singular value energy reaches 90%. And extract the left singular matrix. The former column vectors ,this A principal subspace of good texture is spanned by several orthogonal basis vectors for the current local region. Finally, the projection operator is used. Vectors corresponding to the plot to be reconstructed Perform orthogonal projection and calculate the reconstructed vector. This operation mathematically forces the preservation of vectors. The projection component in the good product subspace, and the residual component orthogonal to the subspace, i.e. the defect signal, is truncated in the null space.
[0030] To further avoid the assimilation effect that may result from large-area or repetitive defects during the search process, this invention configures an iterative purification mechanism based on tabu region feedback. The system executes a two-round reconstruction process. The first round performs the aforementioned projection reconstruction and difference calculation to generate a primary binary mask containing potential defect regions. In the second round of similar tile search, a logical constraint is introduced: for any candidate tile within the search window, if its center pixel coordinates... exist The corresponding value is 1, so it is removed and prevented from entering the local texture data matrix. The construction sequence, this feedback mechanism forces the algorithm to only use areas not covered by the mask to infer the background texture of the occluded area; to address the problem of surface texture of curved products undergoing rotational distortion with geometric curvature, this invention integrates a virtual rotation calibration function based on the principal direction of the tensor. The system utilizes the aforementioned structural tensor matrix From the feature vector direction, the principal orientation angle of the texture at each pixel is extracted. In matching the tiles to be reconstructed With candidate reference tiles Previously, the system calculated the difference in principal orientation angles between the two. Construct the inverse rotation transformation matrix to The center is the origin, and the angle of execution is... Bilinear interpolation rotation, Texture orientation calibration to Consistent, deploy oversampling affine transformation logic, and set the original data reading aperture. The envelope of the rotation trajectory is covered, where, The side length of the local map piece to be reconstructed is represented by the inverse rotation matrix. The target grid coordinates are mapped to the source floating-point coordinate system. Bicubic interpolation resampling is performed on the source buffer data. Valid tiles are cropped from the center of the resampling buffer to eliminate boundary invalid value filling and jagged noise caused by discrete rotation of micro-tiles. The calibrated tiles are then used to calculate similarity and construct the texture data matrix. This geometric adaptation mechanism achieves logical flattening of curved manifold textures in two-dimensional pixel space without introducing three-dimensional point cloud data.
[0031] In the defect determination stage, to address the non-uniform noise caused by lighting fluctuations and processing marks, this invention employs an adaptive threshold segmentation strategy based on reconstruction entropy and histogram drift. The system utilizes a local texture data matrix. The normalized singular value distribution is used to calculate the local Shannon entropy, generating a reconstructed entropy map of the same size as the original image. This entropy map reflects the complexity and uncertainty of the current region's texture reconstruction, and the system constructs a dynamic threshold surface based on this. ,in As the baseline threshold, The sensitivity adjustment coefficient is used, and the system simultaneously calculates the gray-level histogram of the difference residuals across the entire image in real time, extracting the position of the main peak of the histogram. Before performing the segmentation, the residual map is subtracted as a whole. To eliminate the substrate bias introduced by ambient light drift, the system can maintain high sensitivity to capture weak defects in flat areas while suppressing structural false alarms in complex textures through the above spatiotemporal joint adaptive adjustment.
[0032] Example 1: In the scenario of detecting minor scratches on the surface of precision bearing rollers, the system faces the challenge of detecting the superposition of high curvature geometry features and strongly anisotropic turning tool marks. In the early stages of the new production line, samples are scarce, and only single-channel grayscale image data containing radial minor scratches with a depth of about 5 micrometers and diffuse oil stains with a diameter of about 20 pixels can be obtained. The image resolution is Pixels, the system utilizes The Sobel operator calculates the image gradient and passes it via the standard deviation. Gaussian smoothing generates the structure tensor matrix for each pixel. Based on eigenvalue decomposition, the system calculates the degree of anisotropy. Normal turning tool marks area The value remains between 0.85 and 0.95, exhibiting strong texture characteristics, while scratches and oil stains... When a local abrupt change occurs in the value, the tensor field data of this structure is directly used as the topology guide for subsequent tile search. To address the issue of continuous texture phase deflection caused by the roller surface, the system uses... Using local patches of pixels as processing units, the principal eigenvectors of the structure tensor are used to calculate the principal orientation angle of the texture at each pixel. In constructing local texture data matrices Previously, the system calculated the difference in principal orientation angles between the current tile to be reconstructed and the candidate reference tiles in the search neighborhood. Based on this difference, the system performs inverse bilinear interpolation rotation calibration on the candidate reference tiles, mapping the textures that originally had different orientations due to curvature on the three-dimensional manifold into linear alignment signals in two-dimensional Euclidean space. This geometric calibration step reduces the intrinsic dimension of the good texture in the feature space, so that high-fidelity reconstruction can be achieved with only a few basis vectors.
[0033] The system processes the matrix composed of calibrated reference tile vectors. Perform singular value decomposition and dynamically determine the truncated rank based on the cumulative energy contribution rate threshold. (Typical area in this embodiment) ), and from the front of the left singular matrix Each column vector spans a locally good texture principal subspace, which is then used to project the vectors. To reconstruct the plot vector Perform orthogonal projection to generate reconstructed vectors The weak scratch signal belongs to the non-repetitive sparse anomaly, and its energy is mainly orthogonal to the principal subspace and distributed in the null space, so it is truncated in the projection operation; the high-frequency knife-mark features belonging to the background are completely preserved because they are highly correlated with the basis vectors of the principal subspace. In view of the risk of background assimilation caused by large-area oil pollution, the system executes an iterative process based on tabu region feedback, and the primary mask generated in the first round of projection reconstruction is used for this purpose. In the middle, although the central area of the oil slick was detected, the edges were blurred. During the second round of reconstruction, the system will... Regions marked with a value of 1 are designated as forbidden zones for searching, and any tiles falling within these regions are excluded from the matrix. The construction of this logical feedback mechanism cuts off the path of self-replication of abnormal signals, enabling the removal of oil components from the pure twin background image generated in the second round; the system utilizes local singular value distribution to calculate and reconstruct the entropy map. Based on this, a dynamic threshold surface is constructed. In complex texture areas with intersecting knife marks, a higher reconstruction entropy automatically raises the detection threshold to suppress structural false alarms. In areas with smooth textures, a lower reconstruction entropy lowers the threshold. Through full-width difference and adaptive segmentation, the binary defect mask output by the system separates weak scratch and oil stain areas without producing artifacts at the high curvature of the roller edge.
[0034] Example 2: This example verifies the stability of the invention under controlled non-ideal conditions and quantifies the synergistic effect and parameter selection rationality of the scheme through multi-dimensional comparative experiments. The test environment is configured as an industrial vision inspection platform with adjustable light source disturbance and simulated mechanical vibration. A 5-megapixel industrial area array camera is used as the acquisition end, which is fixed to the end of a six-degree-of-freedom robotic arm to simulate the small displacement jitter on the production line. The test object is a group of metal samples that have undergone precision laser etching. Their surfaces contain micron-level scratches of different depths (5 microns, 10 microns, 20 microns) and periodic milling textures as the background. To introduce interference that conforms to engineering reality, the test platform is configured with two independent programmable light sources: one as the main light source to provide basic illumination, and the other as an interference source to generate stroboscopic interference with intensity fluctuations at a frequency of 50Hz as the reference brightness ±20%. Gaussian white noise with a signal-to-noise ratio (SNR) of 25dB is artificially superimposed on the camera output signal to simulate the influence of the electromagnetic environment on signal transmission.
[0035] Experiments were conducted to verify the nonlinear gain generated by the local manifold low-rank projection and the taboo domain feedback mechanism when working together. To this end, the following control system was constructed: Control group A (existing technology): background reconstruction was performed using the classic nonlocal mean (NLM) filter, followed by differential detection; Control group B (partially missing type): reconstruction was performed using only the local manifold low-rank projection of this invention, but without introducing the taboo domain feedback mechanism; Sample group of this invention: a complete technical solution including local manifold low-rank projection and taboo domain feedback was adopted. For the above groups, under the condition of flicker interference and Gaussian white noise, the same group of mixed defect samples containing large-area oil stains (diameter > 50 pixels) and weak scratches (depth 5 micrometers) were detected. The cross-union ratio (IoU) between the output defect mask and the real defect label of each group and the contrast signal-to-noise ratio (CNR) of the scratch area were recorded. The relevant data are shown in Table 1.
[0036] Table 1: Comparison of Detection Performance of Different Technical Solutions under Complex Working Conditions
[0037]
[0038] Data shows that control group A could hardly separate weak scratches under strong noise, and its CNR improvement was limited. Control group B improved the scratch CNR through subspace projection (from 1.2 to 8.9), but when dealing with large areas of oil stains, the IoU was only 55.4%, indicating that there was a significant background assimilation phenomenon, that is, some oil stains were incorrectly reconstructed as background. In contrast, the oil stain IoU of the sample group of this invention jumped to 94.1%, and the scratch CNR was further improved to 14.2.
[0039] The experiment targets truncated rank This key parameter underwent cross-range verification during the construction of a local texture data matrix. After (the number of columns is 16), set them respectively. The values were 2, 4, 8, and 12, and their impact on detection performance was examined. The experimental results showed that when... At that time, the reconstructed background was severely underfitted, and a large number of good textures were misjudged as defects, resulting in a surge in the false alarm rate; when At that time, overfitting of the reconstructed background leads to defect signals (especially scratches) being contained within the principal subspace and failing to be truncated, resulting in an increased false negative rate. Only when... to Within the range (corresponding to a cumulative energy contribution rate of 85%-95%), the system can achieve the best balance between suppressing background and retaining defects, with IoU maintained above 90%. In addition, to verify the adaptability of the scheme to changes in illumination, the experiment introduced an illumination intensity gradient control, setting the flicker amplitude of the interfering light source to ±5%, ±10%, ±20%, and ±30%, respectively. The results showed that, thanks to the histogram drift correction mechanism, the false alarm rate fluctuation of the sample group of this invention was less than 2% at all test levels, while the false alarm rate of the control group without this correction mechanism exceeded 15% under ±20% interference.
[0040] Example 3: This example combines Figures 1 to 3 This paper describes a method for analyzing surface defects in industrial products using images in scenarios with few samples. Figure 1 As shown, the surface grayscale image data of the product to be analyzed is obtained as the raw input. The structure tensor matrix is calculated to generate an anisotropy map representing the intensity of texture directionality. Then, similar patches are searched in the preset search neighborhood to construct a local texture data matrix. Singular value decomposition (SVD) is performed on the matrix to extract the principal subspace. Based on this, the local patches are orthogonally projected and reconstructed using the constructed projection operator to generate reconstructed background patches. All patches are then stitched together to form a full-frame reconstructed background image. Finally, the grayscale difference map between the surface grayscale image data and the full-frame reconstructed background image is calculated. Based on this difference map, adaptive threshold segmentation is performed to extract and output defect features.
[0041] like Figure 2 As shown, the left vertical axis represents the magnitude of the eigenvalues, and the right vertical axis represents the anisotropy degree A(p). The solid curve in the figure represents the principal eigenvalues. The changing trend of eigenvalues shows that their values fluctuate with texture intensity, and the dashed curve represents the secondary eigenvalues. The trend of change of is relatively low and remains stable, while the dotted curve represents the anisotropy A(p) calculated based on these two characteristic values. This index changes with . and The increase is due to the increase in the difference between them; such as Figure 3As shown, the system architecture includes a physical sensing (OT) domain and an intelligent computing (IT) domain. The two domains transmit grayscale image streams through a data interaction bus. The physical sensing domain integrates an environmental simulation system containing a main light source and a flicker interference source, a multi-axis actuator consisting of a six-degree-of-freedom robotic arm, an image acquisition unit containing a high-resolution industrial camera, and a field dashboard for displaying results. The intelligent computing domain deploys a texture manifold perception module for calculating the structural tensor field and an adaptive decision module based on a dynamic threshold of reconstructed entropy. Its core processing component is a low-rank subspace projection engine that performs SVD decomposition and orthogonal truncation. This engine forms a closed-loop logic with an iterative mask purification module that uses a tabu domain feedback mechanism. By interactively purifying the reference patch and the initial detection results, the defect location is finally calculated.
[0042] Example 4: This example aims to deepen and make transparent the adaptive threshold segmentation strategy involved in the aforementioned specific implementations, especially by establishing a definite quantization procedure for the mapping relationship between reconstruction entropy and threshold surface, in order to eliminate the black box of parameter setting. In actual industrial deployment, the rationality of threshold setting directly determines the false alarm rate and false negative rate of the system, and this setting is often affected by the nonlinearity of local texture complexity. The system defines a quantization index of local texture complexity for each The system uses local texture data matrices of pixels to represent local patches. The singular value distribution is used to calculate the reconstruction entropy, let the matrix be... singular values Normalize it to obtain the normalized singular value distribution. Calculate the Shannon entropy of this distribution. The entropy value It directly reflects the degree of dispersion of texture information in the current local area: in flat areas, energy is concentrated on a few principal singular values and the entropy value is low; while in areas with complex textures or intersecting edges, the energy distribution is more dispersed and the entropy value is higher.
[0043] Based on the calculated reconstruction entropy The system establishes its relationship with dynamic thresholds. To ensure that the mapping function between the two regions suppresses complex texture noise without losing weak defect signals in flat areas, the system employs a piecewise linear model for threshold modulation. Specifically, a baseline threshold is set. Add three times the standard deviation to the mean of the overall map's difference residuals, and set the sensitivity adjustment coefficient. The value is 0.5, for any pixel in the image. Its dynamic threshold The calculation follows the following logic: when the reconstruction entropy at the corresponding position Less than the preset low entropy threshold like When the region is considered flat, the threshold remains at [value]. ;when In With high entropy threshold For example When the threshold is between these values, it increases linearly with the entropy value, i.e. ;when Greater than When a region is identified as having an extremely complex texture, the threshold is truncated to the maximum allowed value. To avoid missing strong defects due to excessively high thresholds, the system was tested on standard samples with different texture complexities to verify the effectiveness of the above parameter setting logic. In flat areas, the average reconstruction entropy was 0.3, the dynamic threshold was maintained at the baseline level, and weak scratches with a contrast of only 3 gray levels were detected. In areas with intersecting knife marks, the average reconstruction entropy rose to 1.8, and the dynamic threshold was automatically adjusted up by about 0.65 times the baseline value to shield high-frequency residual noise caused by texture registration errors.
[0044] Example 5: This example describes the offline calibration and data filling procedure for the adaptive threshold segmentation strategy. Before the system is officially deployed or switched to a different type of product line, such as from bearing rollers to blade surfaces, this procedure is executed to determine the adaptability of the model parameters to the current working conditions. Data acquisition and feature space calibration of the benchmark samples are performed. The system collects no less than 50 defect-free standard good product images as a dataset. For each image, its structural tensor field is calculated and the local texture data matrix is extracted. Singular value decomposition is performed on the local texture data matrix, and the distribution law of its singular values is statistically analyzed. The system calculates the normalized singular value cumulative energy curve of all samples and sets an energy retention threshold, such as 95%. The average truncated rank corresponding to this threshold is found as the default initial rank of the system, and a good product texture benchmark based on statistics is established.
[0045] The system performs boundary testing and threshold surface calibration of defect response characteristics. After completing the calibration of the good product benchmark, the system introduces artificial defect samples containing known sizes and types. The system uses the projection operator determined based on the good product benchmark to reconstruct and differentiate the artificial defect samples, records the reconstruction entropy and the corresponding differential residual intensity of different texture regions (flat regions and edge regions), and fits the functional relationship between reconstruction entropy and residual noise basis through regression analysis, thereby determining the sensitivity adjustment coefficient and benchmark threshold in the dynamic threshold formula.
[0046] Example 6: This example establishes a standardized engineering procedure for core model parameter calibration and system initial state configuration, eliminating the reliance on experience in parameter setting and ensuring the reproducibility and stability of the system under different deployment environments. It performs adaptive calibration of the local texture window size, acquires high-resolution images of the surface of the product to be inspected, selects no fewer than 100 sample regions containing typical texture units, and calculates the feature scale of the texture using an autocorrelation function. The side length of the local processing window Set to greater than and closest An even value is used to ensure that the window contains complete texture structure information while maintaining sensitivity to local defects. If the calculated value is... If the pixel size is less than 3 pixels, set the window size to the system's default minimum value. Pixel.
[0047] The system performs dynamic optimization of the structure tensor smoothing scale. After determining the window size, it introduces different standard deviations into the sample images. A Gaussian kernel is used for convolution to generate a multi-scale structured tensor field. For each... Value, calculate the anisotropy degree of the entire graph. mean With variance Construct the evaluation function This function aims to find the optimal scale that maximizes texture orientation consistency while minimizing local fluctuations, iterating through... The value range is from 0.5 to 3.0. Select the value that makes... When the maximum value is reached As a curing smoothing parameter for this product model, this step ensures that the structure tensor field can accurately characterize the inherent topological structure of the good texture; and performs a singular value truncation rank boundary condition test. Based on the above parameters, a local texture data matrix is constructed. And perform singular value decomposition on it, before the system calculates Cumulative energy contribution rate of each singular value Set energy retention threshold The system automatically selects those that meet the 95% requirement. The smallest integer As the initial truncation rank Introduce a standard defect sample containing the smallest known detectable defect, in Fine-tune the truncated rank within a range of ±2, record the signal-to-noise ratio of the defect area, and finally determine the rank that maximizes the signal-to-noise ratio. These are established as the operating parameters under this condition.
[0048] It will be apparent to those skilled in the art that the present invention is not limited to the details of the exemplary embodiments described above, and that the present invention can be implemented in other specific forms without departing from the spirit or essential characteristics of the present invention.
[0049] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention.
Claims
1. An industrial product surface defect image analysis method for a few-shot scenario, characterized in that, The method comprises the following steps: Obtaining surface gray image data of a product to be analyzed, calculating a structure tensor matrix of each pixel point in the surface gray image data, and generating an anisotropy map representing the texture directionality strength according to the eigenvalue decomposition result of the structure tensor matrix; Centering each local patch of the surface gray image data, searching for a plurality of reference patches with structural similarity in a preset search neighborhood based on the structure tensor matrix, vectorizing the plurality of reference patches and arranging them in columns into a local texture data matrix; Performing singular value decomposition on the local texture data matrix, extracting left singular vectors corresponding to the first k largest singular values, and spanning a main subspace representing the good product texture distribution of the current local area from the left singular vectors; Constructing a projection operator projecting onto the main subspace, performing an orthogonal projection operation on the vector corresponding to the local patch using the projection operator, truncating the null space component of the vector orthogonal to the main subspace as an unstructured noise component, and generating a reconstructed background patch; Splicing all the reconstructed background patches into a full-frame reconstructed background image, calculating a gray difference map between the surface gray image data and the full-frame reconstructed background image, and performing adaptive threshold segmentation according to the gray difference map to extract defect features.
2. The industrial product surface defect image analysis method for a few-shot scene according to claim 1, characterized in that, The step of performing singular value decomposition on the local texture data matrix comprises: stretching the selected K reference patches into column vectors with a dimension of d, constructing a local texture data matrix with a dimension of d by K, performing singular value decomposition on the local texture data matrix to obtain a left singular matrix, and truncating the first r column vectors of the left singular matrix as main subspace basis vectors, wherein r is a truncation rank dynamically set according to the singular value decay characteristics of the local texture data matrix; the step of performing an orthogonal projection operation on the vector corresponding to the local patch using the projection operator comprises: calculating the projection component of the vector on the main subspace basis vector, taking the projection component as the reconstructed background texture signal, and defining the residual vector obtained by subtracting the projection component from the vector as the null space component.
3. The industrial product surface defect image analysis method for a few-shot scene according to claim 1, characterized in that, The process of searching for a plurality of reference patches with structural similarity and generating a reconstructed background patch adopts an iterative optimization process including primary screening and secondary refinement, which comprises: performing the first round of reference patch searching and orthogonal projection reconstruction, extracting a primary defect mask based on the generated gray difference map; marking the area corresponding to the primary defect mask in the surface gray image data as a search shielding area; performing the second round of reference patch searching, excluding the patches whose center pixels fall into the search shielding area in the search process, reconstructing the local texture data matrix based on the reference patches not falling into the search shielding area, and performing singular value decomposition and orthogonal projection operation.
4. The industrial product surface defect image analysis method for a few-shot scene according to claim 1, characterized in that, The step of searching for a plurality of reference patches with structural similarity further comprises: calculating the texture main direction angle of each pixel point based on the eigenvectors of the structure tensor matrix; calculating the difference between the texture main direction angles of the current local patch and the candidate reference patch; constructing a rotation transformation matrix based on the difference between the texture main direction angles, and performing inverse rotation calibration on the candidate reference patch using the rotation transformation matrix, and using the calibrated patch to construct the local texture data matrix.
5. The industrial product surface defect image analysis method for few-shot scene according to claim 1, characterized in that, The step of calculating the gray difference map between the surface gray image data and the full-width reconstructed background image comprises: constructing a first structure tensor field based on the surface gray image data, and constructing a second structure tensor field based on the full-width reconstructed background image; calculating the tensor matrix norm difference between the first structure tensor field and the second structure tensor field pixel by pixel to generate a tensor difference feature map; and performing weighted fusion on the tensor difference feature map and a basic difference map calculated based on the pixel gray difference value to obtain a gray difference map for adaptive threshold segmentation.
6. The industrial product surface defect image analysis method for few-shot scene according to claim 1, characterized in that, The step of performing adaptive threshold segmentation according to the gray difference map comprises: statistically analyzing the singular value distribution characteristics of the local texture data matrix to calculate a reconstruction entropy index representing the local texture reconstruction reliability; generating a dynamic threshold matrix with the same size as the surface gray image data based on the reconstruction entropy index, wherein the threshold values of each point in the dynamic threshold matrix are positively correlated with the reconstruction entropy index; and comparing the gray difference map with the dynamic threshold matrix point by point to obtain a binary defect mask.
7. The industrial product surface defect image analysis method for a few-shot scene according to claim 1, characterized in that, Before performing adaptive threshold segmentation on the gray difference image, a base correction step based on residual histogram statistical characteristics is further included, and the base correction step calculates a corrected dynamic segmentation threshold according to the following formula : , wherein is a preset base threshold, is a sensitivity adjustment coefficient, is a half-height width of a gray histogram of the current gray difference image, is a preset half-height width of a residual histogram in a reference defect-free state.
8. The industrial product surface defect image analysis method for few-shot scene according to claim 1, characterized in that, After performing adaptive threshold segmentation on the gray difference map, the method further comprises: extracting a connected region exceeding the threshold in the gray difference map as a candidate defect region; calculating the geometric morphological characteristics and the texture statistical characteristics of the candidate defect region; mapping the geometric morphological characteristics and the texture statistical characteristics to a preset feature space, calculating the Euclidean distance between the candidate defect region and a pre-stored few-sample defect prototype vector, and classifying the candidate defect region into a category to which the defect prototype with the closest distance belongs.
9. The industrial product surface defect image analysis method for few-shot scene according to claim 1, characterized in that, The step of calculating the structure tensor matrix of each pixel point comprises: calculating the gradients of the surface gray image data in the horizontal direction and the vertical direction; calculating the outer product matrix of the gradients, and performing Gaussian smoothing filtering on the outer product matrix to generate the structure tensor matrix; and the step of generating the anisotropy degree map comprises: calculating the maximum eigenvalue and the minimum eigenvalue of the structure tensor matrix, and taking the ratio of the difference value of the maximum eigenvalue and the minimum eigenvalue to the sum value of the maximum eigenvalue as the anisotropy degree of the pixel point.
10. The industrial product surface defect image analysis method for few-shot scene according to claim 1, characterized in that, The step of constructing the projection operator for projecting into the principal subspace comprises: constructing a projection matrix using the left singular vector, wherein the projection matrix is equal to the sum of the product of the left singular vector and the transpose vector of the left singular vector; and the step of truncating the zero space component in the vector orthogonal to the principal subspace as an unstructured noise component comprises: retaining the projection component of the vector corresponding to the local block in the principal subspace by the projection matrix, so as to eliminate the random noise component and the non-repetitive defect component in the zero space.
Citation Information
Patent Citations
Multi-channel image adaptive fusion method and system for industrial product surface defect detection
CN120953741A
Non-local mean value CT image noise reduction method based on structure tensor
CN110570379A
Fan blade defect detection method based on direction constraint edge extraction and texture discrimination
CN120876942A