Infrared defect detection method and device
Through the variational inference method of three-dimensional tensor decomposition and Bayesian model, the background, defect and noise signals in the infrared thermal image are separated, which solves the accuracy and robustness problems of infrared defect detection in complex environments and realizes efficient and accurate defect detection.
Patent Information
- Application Number
- CN202510716011.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-30
- Publication Date
- 2025-09-23
AI Technical Summary
Existing infrared defect detection technology has insufficient detection accuracy and poor robustness in complex thermal interference environments, making it difficult to effectively extract defect area information.
The three-dimensional tensor decomposition method is used to decompose the infrared thermal image sequence into the sum of low-rank tensor, sparse tensor and noise tensor. A Bayesian model is constructed and the prior distribution is introduced. The model parameters are updated through variational inference, and the sparse tensor is output as the defect area information. The detection results are optimized by combining the kurtosis value and skewness value sorting.
It improves the accuracy and efficiency of defect detection, can effectively suppress noise, clearly display defect areas, reduce manual screening time, and enhance the robustness and stability of the algorithm.
Smart Images

Figure CN120689282A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of non-destructive testing and processing, and in particular relates to an infrared defect detection method and device. Background Art
[0002] Infrared defect detection technology is based on the thermal radiation properties of objects. According to physical principles, any object above absolute zero will emit infrared radiation. When a defect exists within an object, heat transfer is hindered, resulting in an abnormal temperature distribution on the surface. High-precision infrared detection equipment can capture these temperature differences, thereby determining the location and general shape of the defect.
[0003] However, current infrared defect detection technology has certain limitations at the algorithm level. For example, the detection algorithm is not robust enough. When there is complex thermal interference in the detection environment, such as unstable background heat source and inconsistent surface emissivity of the detection object, the detection algorithm is easily affected, resulting in fluctuations or even errors in the detection results. The detection accuracy needs to be further improved. Summary of the Invention
[0004] The present invention provides an infrared defect detection method and device, which can effectively suppress noise and further effectively extract information of defect areas in infrared thermal images, thereby improving defect detection accuracy and detection efficiency.
[0005] One aspect of the present invention provides an infrared defect detection method, comprising:
[0006] The infrared thermal image sequence of the test piece is modeled as a three-dimensional tensor, and the tensor is decomposed into the sum of a low-rank tensor, a sparse tensor, and a noise tensor;
[0007] A Bayesian model is constructed, introducing the prior distribution of low-rank tensors, sparse tensors, noise tensors, and mode coupling parameters to jointly represent the defect posterior distribution;
[0008] The posterior distribution is approximated by variational inference, and the variational distribution is updated by iterative calculation;
[0009] The final sparse tensor is output as the defect area information to obtain the infrared defect detection map.
[0010] Optionally, before constructing the Bayesian model, the method further includes:
[0011] Initial values are assigned to the low-rank tensor, the sparse tensor, and the noise tensor, and hyperparameters are initialized, including a sparsity parameter, a noise variance parameter, and a mode coupling parameter.
[0012] Optionally, introduce prior distributions of low-rank tensors, sparse tensors, noise tensors, and mode coupling parameters, including:
[0013] A Gaussian prior distribution is introduced for the low-rank tensor, a Laplace prior distribution is introduced for the sparse tensor, and a Gaussian prior distribution is introduced for the noise tensor. The Gaussian distribution is used as the prior distribution of the mode coupling parameter.
[0014] Optionally, update the variational distribution through iterative calculations, including:
[0015] The variation distribution is updated by minimizing the variational free energy. The variational free energy updates the variational distribution of the low-rank tensor, sparse tensor, noise tensor, and mode coupling parameters through iterative calculation. In each iteration, the expectation is calculated based on the variational distribution of the current low-rank tensor, sparse tensor, noise tensor, and mode coupling parameters, and the expectation is used to update the hyperparameters in the subsequent maximization step until the changes in the low-rank tensor, sparse tensor, and mode coupling parameters are all less than the first threshold or the change in variational free energy is less than the second threshold, and the iteration is stopped.
[0016] Optionally, the variational free energy is iteratively calculated to update the variational distribution of the low-rank tensor, sparse tensor, noise tensor, and mode coupling parameters, including:
[0017] The variational distribution of the sparse tensor, noise tensor, and mode coupling parameters are fixed, and the variational distribution of the low-rank tensor is updated by maximizing the expectation with respect to the sparse tensor, noise tensor, and mode coupling parameters;
[0018] The variational distribution of the low-rank tensor, the noise tensor, and the mode coupling parameters are fixed, and the variational distribution of the sparse tensor is updated by maximizing the expectation with respect to the low-rank tensor, the noise tensor, and the mode coupling parameters;
[0019] The variational distribution of the low-rank tensor, the sparse tensor, and the mode coupling parameters are fixed, and the variational distribution of the noise tensor is updated by maximizing the expectation with respect to the low-rank tensor, the sparse tensor, and the mode coupling parameters;
[0020] The variational distribution of the low-rank tensor, sparse tensor, and noise tensor is fixed, and the variational distribution of the mode coupling parameter is updated by maximizing the expectation with respect to the low-rank tensor, sparse tensor, and noise tensor.
[0021] Optionally, update sparsity parameters including:
[0022] Computes the expectation of the absolute value of each element in a sparse tensor under its variational distribution, and computes the expectation of the sum of the absolute values of all elements;
[0023] Update the sparsity parameter based on the expected sum of the absolute values of all elements.
[0024] Optionally, update the noise variance parameter including:
[0025] Compute the expectation of the square of each element in the noise tensor under the variational distribution of the noise tensor, and compute the expectation of the sum of the squares of all elements;
[0026] Update the noise variance parameter based on the expected sum of squares of all elements.
[0027] Optionally, update mode coupling parameters including:
[0028] Calculate the expectation and square of the mode coupling parameters;
[0029] The mode coupling parameters are updated according to the expectation of the mode coupling parameters and the expectation of the square.
[0030] Optionally, after outputting the final sparse tensor as defect area information to obtain the infrared defect detection image, the method further includes:
[0031] Calculate the kurtosis value of each infrared defect detection image;
[0032] Sort the infrared defect detection images according to the kurtosis value, and select multiple infrared defect detection images with kurtosis values less than the kurtosis value threshold as infrared defect detection result images;
[0033] Calculate the skewness value of the infrared defect detection result graph;
[0034] The infrared defect detection result images are sorted according to the skewness values, and one or more infrared defect detection result images with skewness values less than a skewness value threshold are selected as the final infrared defect detection result images.
[0035] Another aspect of the present invention further provides an infrared defect detection device for executing any of the methods described in the above aspect.
[0036] The present invention also includes a computer program product, including a computer program, which, when executed by a processor, implements the steps of the infrared defect detection method formed by any one of the above examples or a combination of multiple examples.
[0037] The present invention also includes a terminal, including a memory and a processor, wherein the memory stores computer instructions that can be run on the processor, and when the processor runs the computer instructions, it executes the steps of the infrared defect detection method formed by any one or more of the above examples.
[0038] The present invention provides an infrared defect detection method and device. The infrared image data to be detected is input in the form of a tensor and decomposed into a low-rank tensor, a sparse tensor and a noise tensor, a Bayesian model is constructed, and the prior distribution of the low-rank tensor, the sparse tensor, the noise tensor and the mode coupling parameter is further introduced. The prior distribution of the low-rank tensor conforms to the regularity of the background information, the prior distribution of the sparse tensor induces the sparse part to highlight the defect information, the prior distribution of the noise part conforms to the random characteristics of noise, the prior distribution of the mode coupling parameter is used to capture the correlation between different modes, and the variational inference method is used to approximate the posterior distribution and update the variational distribution, which can accurately estimate the parameters of each part of the model. The expectation maximization (EM) algorithm is used to dynamically update the hyperparameters, which can enable the model to better fit the data, thereby effectively suppressing noise, and effectively extracting information about the defect area in the infrared thermal image, thereby improving the accuracy of defect detection. The present invention calculates the kurtosis and skewness values of the infrared defect detection image. The kurtosis value can reflect the concentration of the image grayscale distribution near the mean and the thickness of the tail, and the skewness value can reflect the symmetry of the image grayscale distribution. Images with clearer and more obvious defects usually show a more concentrated grayscale value distribution in the defect area, which is manifested as a higher kurtosis value, and their grayscale distribution will have a more significant deviation from the mean, with a specific skewness value. Therefore, by further re-sorting the images according to the kurtosis and skewness values, images with these characteristics can be quickly screened out from a large number of infrared defect detection images, that is, results with clearer and more obvious defects, thereby avoiding the large amount of time spent on manually checking images one by one, greatly reducing the time cost of detection, and improving detection efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] The specific embodiments of the present invention are further described in detail below in conjunction with the accompanying drawings. The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The same reference numerals are used in these drawings to represent the same or similar parts. The schematic embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application.
[0040] Figure 1 A flow chart of a method provided as an example of the present invention;
[0041] Figure 2 A flow chart of a method provided for a preferred embodiment of the present invention;
[0042] Figure 3 Schematic diagram of defect detection results of carbon fiber material specimens based on the method of the present invention;
[0043] Figure 4 Schematic diagram of defect detection results of coating material specimens based on the method of the present invention. DETAILED DESCRIPTION
[0044] The technical solution of the present invention is described clearly and completely below with reference to the accompanying drawings. It is apparent that the embodiments described are only a portion of the embodiments of the present invention, not all of them. All other embodiments derived by persons of ordinary skill in the art based on the embodiments of the present invention without inventive effort are intended to fall within the scope of protection of the present invention.
[0045] In the description of the present invention, it should be noted that the directions or positional relationships indicated by terms such as "center," "up," "down," "left," "right," "vertical," "horizontal," "inside," and "outside" are based on the directions or positional relationships described in the accompanying drawings and are intended only to facilitate and simplify the description of the present invention and should not be construed as limiting the present invention. Furthermore, the use of ordinal numbers (e.g., "first and second," etc.) is intended to distinguish between objects and is not limited to this order, and should not be construed as indicating or implying relative importance.
[0046] In the description of the present invention, it should be noted that, unless otherwise specified or limited, the terms "mounted," "connected," and "connected" should be understood broadly, and may refer to direct connection or indirect connection through an intermediary. Those skilled in the art will understand the specific meanings of these terms in the present invention.
[0047] In addition, the technical features involved in different embodiments of the present invention described below can be combined with each other as long as they do not conflict with each other.
[0048] In one example, if Figure 1 As shown, an infrared defect detection method includes the following steps:
[0049] S11: Treat the infrared thermal image sequence of the test piece as a three-dimensional tensor Where I1 represents the length of the infrared heat map, I2 represents the width of the infrared heat map, I3 represents the number of frames in the infrared heat map sequence, and R represents the real number field; the tensor X is decomposed into the sum of a low-rank tensor L, a sparse tensor S, and a noise tensor ε. The low-rank tensor represents the background component of the infrared heat map, the sparse tensor represents the defect component of the infrared heat map, and the noise tensor represents the noise component of the infrared heat map.
[0050] S12: Assign initial values to the low-rank tensor, the sparse tensor, and the noise tensor, and initialize hyperparameters, which include a sparsity parameter, a noise variance parameter, and a mode coupling parameter.
[0051] Specifically, the canonical / parallel factor (CANDECOMP / PARAFAC, CP) decomposition method is used to obtain the initial estimate of the low-rank tensor L (0) , the sparse tensor initial value S (0) Initialized to zero tensor, the noise tensor is given the initial value ε(0) =XL (0) .
[0052] Furthermore, the sparsity parameter α, the noise variance parameter β, and the mode coupling parameter γ are initialized. Optionally, the initialization is performed based on experience or prior knowledge of the data. For example, α is initialized to 0.01, β is estimated to be 0.1 based on the approximate noise level of the data, and γ is initialized to 0.5.
[0053] S13: Construct a Bayesian model and introduce the prior distribution of low-rank tensor, the prior distribution of sparse tensor, the prior distribution of noise tensor and the prior distribution of mode coupling parameters to jointly represent the defect posterior distribution.
[0054] Among them, the prior distribution of low-rank tensors is used to capture the global structure and main features in the infrared thermal image sequence. The global structure is the main spatiotemporal pattern in the infrared thermal image, which reflects the overall thermal distribution characteristics of the infrared thermal image background. The main features correspond to the stable feature information of the background part of the infrared thermal image; the sparse tensor prior is used to capture the sparse features in the infrared thermal image sequence, corresponding to the defect area; the noise tensor prior is used to model the noise part in the infrared thermal image sequence; the mode coupling parameter prior is used to capture the correlation between different modes. In the infrared thermal image sequence, the infrared thermal images at different time points may have similar thermal distribution patterns. These patterns may be related to the presence of defects. By introducing the mode coupling parameter prior distribution, the Bayesian model can use these correlations to improve the detection ability of defects. Through the above prior distribution, the Bayesian model can construct a comprehensive posterior distribution. Under the condition of observed data (infrared thermal image sequence) and prior knowledge, it is used to estimate the most likely state of the defect, thereby realizing accurate detection of defects, including defect location, defect size and type.
[0055] S14: Approximate the posterior distribution using variational inference and update the variational distribution by minimizing the variational free energy. The variational free energy is iteratively calculated to update the variational distribution q(L) of the low-rank tensor, the variational distribution q(S) of the sparse tensor, the variational distribution q(S) of the noise tensor, and the variational distribution q(γ) of the mode coupling parameter. In each iteration, the expectation is calculated based on the current variational distribution q(L), q(S), q(ε), and q(γ), and the expectation is used to update the hyperparameters in the subsequent maximization step until the changes in the low-rank tensor, sparse tensor, and mode coupling parameter are all less than the first threshold or the change in the variational free energy is less than the second threshold, at which point the iteration is stopped. The first and second thresholds are change thresholds, which can be customized based on historical experience, experiments, etc. The first and second thresholds can be equal or different.
[0056] This step uses the expectation maximization (EM) approach, which calculates a series of expectations based on the current variational distributions q(L), q(S), q(ε), and q(γ). These expectations are then used to update hyperparameters in the subsequent M steps (maximization steps), allowing them to be dynamically adjusted and optimized based on the real-time characteristics of the data. Through continuous iteration, the hyperparameters gradually converge to more optimal values, allowing the prior distributions of the sparse, noisy, and pattern-coupled parts of the model to more accurately match the true characteristics of the data. This significantly improves the adaptability of the sparse Bayesian robust tensor decomposition algorithm to complex data, making the decomposition results of the low-rank, sparse, and noisy parts more accurate, enhancing the robustness and stability of the algorithm, and providing a more reliable data foundation for subsequent tasks such as data analysis and feature extraction based on the tensor decomposition results.
[0057] S15: Output the final sparse tensor as the defect area information to obtain an infrared defect detection map.
[0058] This paper uses a sparse Bayesian tensor decomposition algorithm based on pattern coupling to solve the infrared thermal image sequence of the test piece. Specifically, the infrared thermal image sequence is modeled as a three-dimensional tensor and decomposed into the sum of a low-rank tensor, a sparse tensor, and a noise tensor, effectively separating the background, defect, and noise signals. The constructed Bayesian model introduces a prior distribution and combines variational inference to dynamically update hyperparameters, optimizing the posterior distribution of defects. The final output is a sparse tensor as defect area information, resulting in a clear infrared defect detection map that effectively suppresses complex background and noise, thereby improving the accuracy of defect detection.
[0059] In one example, a Bayesian model is constructed, introducing the prior distribution of low-rank tensors, the prior distribution of sparse tensors, the prior distribution of noise tensors, and the prior distribution of mode coupling parameters, including:
[0060] A Gaussian prior distribution is introduced for the low-rank tensor, a Laplace prior distribution is introduced for the sparse tensor, and a Gaussian prior distribution is introduced for the noise tensor. The Gaussian distribution is used as the prior distribution of the mode coupling parameter.
[0061] For the prior distribution p(L) of low-rank tensor, a Gaussian prior distribution is introduced for the low-rank tensor L Where N represents Gaussian distribution, Represents the variance of the low-rank tensor, I represents the unit tensor, which can be initialized based on the low-rank tensor L (0) Compute the variance of its elements as the initial value.
[0062] For the prior distribution p(S) of the sparse tensor, the Laplace prior distribution is introduced for the sparse tensor S To promote sparsity, most elements in S tend to zero to satisfy the "sparse" property. Where α represents the sparsity parameter; Represents each element in the sparse tensor S, i1, i2, i3 represent the element index of the sparse tensor S; exp represents the exponential function.
[0063] For the prior distribution p(ε) of the noise tensor, a Gaussian prior distribution is introduced for the noise tensor ε in is the noise variance, which can be obtained based on the initialized noise tensor ε (0) Compute the variance of its elements as the initial value.
[0064] For the prior distribution of mode coupling parameters p(γ), a Gaussian distribution is used where μ γ and are the mean and variance of the mode coupling parameters.
[0065] The prior distribution of low-rank tensors, the prior distribution of sparse tensors, the prior distribution of noise tensors and the prior distribution of mode coupling parameters jointly represent the defect posterior distribution. Based on Bayes' theorem, the posterior distribution is p(L, S, ε, γ|X)∝p(X|L, S, ε, γ)p(L)p(S)p(ε)p(γ), where p(L, S, ε, γ|X) represents the condition on the observed data (three-dimensional tensor of infrared thermal image sequence) X. The posterior distribution of the low-rank tensor L, the sparse tensor S, the noise tensor ε, and the mode coupling parameter γ is given by ∝. p(X|L,S,ε,γ) is the likelihood function, which represents the conditional probability of the observed data X given the low-rank tensor L, the sparse tensor S, the noise tensor ε, and the mode coupling parameter γ. ∝ indicates that the posterior distribution p(L,S,ε,γ|X) is proportional to the product of the likelihood function p(X|L,S,ε,γ) and the prior distribution. The likelihood function P(X|L,S,ε,γ) takes into account the influence of mode coupling and is described by constructing a corresponding probabilistic model.
[0066] In one example, the variational inference method is used to approximate the posterior distribution p(L, S, ε, γ|X), and the variational distribution q(L, S, ε, γ) = q(L)q(S)q(ε)q(γ) is introduced. The variational distribution is updated by minimizing the variational free energy F(q), thereby making the variational distribution q closer to the true posterior distribution. The variational free energy F(q) is defined as F(q) = E q [logq(L, S, ε, γ)-logp(L, S, ε, γ|X)], E represents the expectation, E q represents the expectation under the variational distribution q.
[0067] Furthermore, the variational free energy is iteratively calculated to update the variational distribution of the low-rank tensor, sparse tensor, noise tensor, and mode coupling parameters, including:
[0068] Update the variational distribution q(L) of the low-rank tensor: fix the variational distribution q(S) of the sparse tensor, the variational distribution q(ε) of the noise tensor, and the variational distribution q(γ) of the mode coupling parameter, and maximize E by Newton's method q(S),q(e),q(γ) [logp(X|L, S, ε, γ)p(L)] updates q(L), that is, the variational distribution q(L) of the low-rank tensor is updated by maximizing the expectation of the sparse tensor, noise tensor, and mode coupling parameters through Newton's method.
[0069] Update the variational distribution q(S) of the sparse tensor: fix the variational distribution q(L) of the low-rank tensor, the variational distribution q(ε) of the noise tensor, and the variational distribution q(γ) of the mode coupling parameter, and maximize E q(L),q(e),q(γ) [logp(X|L,S,ε,γ)p(S)] updates q(S), that is, by maximizing the expected update of the sparse tensor q(S) with respect to the low-rank tensor, the noise tensor, and the mode coupling parameter. Due to the existence of the Laplace prior, the soft thresholding method is used. The soft thresholding formula is: in, Represents the element value of the updated sparse tensor S; represents the element value of the sparse tensor S before the update; sign represents the sign function; max represents the maximum value function; λ is the threshold parameter related to the sparsity parameter α.
[0070] Update the variational distribution q(ε) of the noise tensor: fix the variational distribution q(L) of the low-rank tensor, the variational distribution q(S) of the sparse tensor, and the variational distribution q(γ) of the mode coupling parameter, and use the least squares method to maximize E q(L),q(S),q(γ) [logp(X|L, S, ε, γ)p(ε)] updates q(ε), that is, updates the variational distribution q(ε) of the noise tensor by maximizing the expectation with respect to the low-rank tensor, the sparse tensor, and the mode coupling parameters.
[0071] Update the variational distribution q(γ) of the mode coupling parameters: fix the variational distribution q(L) of the low-rank tensor, the variational distribution q(S) of the sparse tensor, and the variational distribution q(ε) of the noise tensor, and use the gradient descent method to maximize E q(L),q(S),q(ε) [logp(X|L,S,ε,γ)p(γ)] updates q(γ) by maximizing the variational distribution q(γ) of the expected update mode coupling parameters with respect to the low-rank tensor, sparse tensor, and noise tensor.
[0072] Furthermore, hyperparameter update is performed at each iteration by updating the hyperparameters α, β, and γ based on the current variational distributions q(L), q(S), q(ε), and q(γ). This is achieved using the concept of expectation maximization (EM). Specifically, the core of the E-step (expectation step) is to calculate a series of expectations based on the current variational distributions q(L), q(S), q(ε), and q(γ). These expectations are then used to update the hyperparameters in the subsequent M-step (maximization step). The maximization step updates the hyperparameters based on the expectations calculated in the expectation step.
[0073] In one example, updating the sparsity parameter α includes:
[0074] 1) Compute the expectation associated with the sparsity parameter α, that is, calculate the expectation of the absolute value of each element in the sparse tensor under the variational distribution of the sparse tensor, and calculate the expectation of the sum of the absolute values of all elements.
[0075] Specifically, the prior distribution of the sparse tensor S is To update the sparsity parameter α, we need to first calculate the expectation of the absolute value of a single element: for each element in the sparse tensor S To calculate the expectation of its absolute value under the variational distribution q(S) of the sparse tensor Consider q(S) to be Gaussian distributed is the mean and variance of the sparse tensor. According to the definition of expectation, where q S (s) is the probability density function of q(S). Then, the expectation of the sum of the absolute values of all elements is calculated According to the expected linear properties,
[0076] 2) Update the sparsity parameter α according to the expectation of the sum of the absolute values of all elements.
[0077] Specifically, α is updated by maximizing the approximate value of the marginal likelihood function p(X|α) with respect to the sparsity parameter α. The calculation expression is:
[0078]
[0079] Among them, α new represents the updated sparsity parameter; |S| represents the total number of elements in the sparse tensor S.
[0080] The update of the sparsity parameter α is completed by continuously repeating the expectation step and the maximization step until the sparsity parameter α converges, that is, the change of the sparsity parameter α in two adjacent iterations is less than the preset threshold.
[0081] In one example, updating the noise variance parameter β includes:
[0082] 1) Calculate the expectation associated with the noise variance parameter β, that is, calculate the expectation of the square of each element in the noise tensor under the variational distribution of the noise tensor, and calculate the expectation of the sum of the squares of all elements.
[0083] Specifically, the prior distribution of the noise tensor is To update the noise variance parameter β, it is necessary to calculate the expectation of the sum of squares of all noise elements in is the square of the Frobenius norm of the noise tensor ε, that is, the sum of the squares of all elements in the noise tensor. is the mean and variance of the noise tensor, for a single element in the noise component The variance of a single element in the noise tensor represents the expected value of the square of a single element in the noise component under the variational distribution q(ε); Represents the square of the expected value of a single element in the noise component under the variational distribution q(ε), and we can get represents the mean of a single element in the noise component, then
[0084] 2) Update the noise variance parameter β according to the expectation of the sum of squares of all elements.
[0085] Specifically, β is updated by maximizing the approximate value of the marginal likelihood function p(X|β) with respect to the noise variance parameter β. The calculation expression is:
[0086]
[0087] Among them, β new is the updated noise variance parameter; |ε| represents the total number of elements in the sparse tensor ε.
[0088] The update of the noise variance parameter β is completed by repeating the expectation step and the maximization step until the noise variance parameter β converges, that is, the change of the noise variance parameter β between two adjacent iterations is less than the preset threshold.
[0089] In one example, updating the mode coupling parameter γ includes:
[0090] 1) Calculate the expectation related to the mode coupling parameter γ, that is, calculate the expectation and square expectation of the mode coupling parameter.
[0091] Specifically, the prior distribution of the mode coupling parameters is To update γ, the expectation of γ itself and the expectation of the square need to be calculated: due to the variational distribution of the mode coupling parameter is the mean and variance of the mode coupling parameter. According to the properties of Gaussian distribution, E q(γ) [γ]=μq , E q(γ) [γ] represents the expected value of the mode coupling parameter γ under the variational distribution q(γ); E q(γ) [γ 2 ] represents the expected value of the square of the mode coupling parameter γ under the variational distribution q(γ); represents the mean μ of the variational distribution q(γ) q The square of .
[0092] 2) Update the mode coupling parameter γ according to the expectation and square of the mode coupling parameter.
[0093] Specifically, γ is updated by maximizing the approximate value of the marginal likelihood function p(X|γ) of the mode coupling parameter γ. Taking the partial derivative of the logarithmic marginal likelihood function with respect to γ and setting the partial derivative to 0, we obtain an equation for γ:
[0094] g(γ,E q(γ) [γ],E q(γ) [γ 2 ])=0
[0095] Where g represents the function equation.
[0096] Furthermore, the iterative formula for updating the mode coupling parameters is calculated using the numerical optimization method, and the calculation expression is:
[0097]
[0098] Where g′ is the derivative of g with respect to γ, k is the value of γ at the kth iteration, γ k+1 It is the value of γ at the k+1th iteration, and it is iterated continuously until the convergence condition is met (for example, the change of γ between two adjacent iterations is less than the preset threshold).
[0099] Furthermore, when the variational free energy updates the variational distribution q(L) of the low-rank tensor, the variational distribution q(S) of the sparse tensor, the variational distribution q(S) of the noise tensor, and the variational distribution q(γ) of the mode coupling parameter through iterative calculation, convergence judgment is required:
[0100] First, calculate the low-rank tensor L, sparse tensor S, mode coupling parameter γ in two adjacent iterations or calculate the change in variational free energy F(q) in two adjacent iterations. If the changes in the low-rank tensor L, sparse tensor S, mode coupling parameter γ are all less than the first threshold or the change in variational free energy is less than the second threshold, stop the iteration. For example, calculate ΔL = || L (k+1) -L k || F , where ΔL represents the change in the low-rank tensor between two adjacent iterations, Represents the Frobenius norm. If ΔL<∈, ∈ represents the first threshold, such as ∈=10 -6 , or the change in variational free energy is less than the preset second threshold, the algorithm is considered to have converged and the iteration is stopped; otherwise, the iteration continues to update the variational distribution.
[0101] In one example, after outputting the final sparse tensor as the infrared defect detection result, the following steps are also included:
[0102] Calculate the kurtosis value of each infrared defect detection image. For the kth infrared defect detection image I k The kurtosis value K of (x, y) k The calculation formula is as follows.
[0103]
[0104] Where M represents the height of the infrared defect detection image; N represents the width of the infrared defect detection image; I k (x, y) represents the grayscale value of the kth infrared defect image at the coordinate (x, y); It represents the average grayscale value of all pixels in the k-th infrared defect image. Its calculation formula is:
[0105] Sort the infrared defect detection images by kurtosis value, and select multiple infrared defect detection images with kurtosis values less than a kurtosis threshold as the infrared defect detection result images. The kurtosis threshold can be customized based on historical experience or experiments. Optionally, re-sort the infrared defect detection images by kurtosis value from smallest to largest to obtain a preliminary sorting result S′1; select the first six infrared defect detection images in S1 as the infrared defect detection result images.
[0106] Calculate the skewness value of each infrared defect detection result image. For the kth infrared defect detection image, the skewness value S k The calculation formula is as follows.
[0107]
[0108] Sort the infrared defect detection result images by skewness value, and select one or more infrared defect detection result images with skewness values less than a skewness threshold as the final infrared defect detection result image. The skewness threshold can be customized based on historical experience or experimentation. Optionally, re-sort the infrared defect detection result images by skewness value from smallest to largest to obtain a final sorted result S′2, which is used as the final infrared defect detection result image.
[0109] In this example, a statistical priority sorting algorithm is used to sort the infrared defect detection results, so that the sequence of infrared defect detection images is arranged from high to low according to the obviousness of the defect feature information, thereby improving the detection efficiency.
[0110] Combining the above examples, we can obtain an example of the present invention, such as Figure 2 As shown, the method now includes the following steps:
[0111] S1': Construct a sparse Bayesian robust tensor decomposition algorithm model to preliminarily process the infrared defect heat map sequence, including the following sub-steps:
[0112] S11': Treat the infrared thermal image sequence of the test piece as a three-dimensional tensor Decompose the tensor X into the sum of the low-rank tensor L, the sparse tensor S and the noise tensor ε;
[0113] S12': Assign initial values to the low-rank tensor L, sparse tensor S, and noise tensor ε, and initialize the sparsity parameter α, noise variance parameter β, and mode coupling parameter γ;
[0114] S13': Construct a Bayesian model, introduce the prior distribution of low-rank tensors, the prior distribution of sparse tensors, the prior distribution of noise tensors, and the prior distribution of mode coupling parameters, which are used to jointly represent the defect posterior distribution
[0115] S14': Approximate the posterior distribution by variational inference, and update the variational distribution by minimizing the variational free energy. The variational free energy updates the variational distribution q(L) of the low-rank tensor, the variational distribution q(S) of the sparse tensor, the variational distribution q(S) of the noise tensor, and the variational distribution q(γ) of the mode coupling parameter by iterative calculation. In each iteration, the expectation is calculated based on the current variational distribution q(L), q(S), q(ε), and q(γ), and the expectation is used to update the hyperparameters in the subsequent maximization step until the changes in the low-rank tensor, the sparse tensor, and the mode coupling parameter are all less than the first threshold or the change in the variational free energy is less than the second threshold, and the iteration is stopped;
[0116] S15': Output the final sparse tensor as the defect area information to obtain the infrared defect detection map.
[0117] S2': Prioritize the infrared defect detection results using a statistical sorting algorithm, including the following sub-steps:
[0118] S21': Calculate the kurtosis value of each infrared defect detection image;
[0119] S22′: sorting the infrared defect detection images according to the skewness values, and selecting one or more infrared defect detection images with skewness values less than a skewness value threshold as infrared defect detection result images;
[0120] S23': Calculate the skewness value of the infrared defect detection result image;
[0121] S24′: sorting the infrared defect detection result images according to the skewness values, and selecting one or more infrared defect detection result images with skewness values less than a skewness value threshold as the final infrared defect detection result images.
[0122] To verify the feasibility of the solution of the present invention, a defect detection experiment was conducted on infrared defect data of composite materials. In this experiment, two types of specimens were used: specimen 1 was a carbon fiber material specimen, and specimen 2 was a coating material specimen. Figure 3 are the subsurface defect detection results of the two specimens, where Figure 3 (a), (b), and (c) are the first three result images of the carbon fiber material specimen defect detection results output in step S15'. Figure 3 (d), (e), and (f) are the first three result images of the carbon fiber material specimen defect detection results output by step S24' after statistical priority sorting. It can be seen that Figure 3 (d), (e), and (f) compared to Figure 3 The defect feature information in (a), (b), and (c) is more obvious; Figure 4 (a), (b), and (c) are the first three result images of the coating material specimen defect detection results output in step S15'. Figure 4 (d), (e), and (f) are the first three result images of the carbon fiber material specimen defect detection results output by step S24' after statistical priority sorting. It can be seen that Figure 4 (d), (e), and (f) compared to Figure 4 The defect characteristics of (a), (b), and (c) are more obvious. Comparing the result graphs of each group shows that step S1' of the present method can effectively detect sub-surface defects in composite materials. In combination with step S2', it can also realize the priority sorting of the result graphs processed by the unsupervised algorithm, which can save the time and labor cost of re-screening the test results and improve the detection efficiency.
[0123] The present invention also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the infrared defect detection method described in any one or a combination of the above examples. The processor may be a single-core or multi-core central processing unit or a specific integrated circuit, or one or more integrated circuits configured to implement the present invention.
[0124] The present invention also provides a terminal having the same inventive concept as any example or combination of examples corresponding to the above-mentioned infrared defect detection method, comprising a memory and a processor. The memory stores computer instructions executable by the processor, and the processor executes the steps of the above-mentioned infrared defect detection method when executing the computer instructions. The processor can be a single-core or multi-core central processing unit or a specific integrated circuit, or one or more integrated circuits configured to implement the present invention.
[0125] In one example, the terminal, i.e., the electronic device, is presented in the form of a general-purpose computing device, and the components of the electronic device may include but are not limited to: at least one processing unit (processor) mentioned above, at least one storage unit mentioned above, and a bus connecting different system components (including storage units and processing units).
[0126] The storage unit stores program code that can be executed by the processing unit, causing the processing unit to perform the steps described in the "Exemplary Methods" section above according to various exemplary embodiments of the present invention. For example, the processing unit can perform the above-mentioned infrared defect detection method.
[0127] The storage unit may include a readable medium in the form of a volatile memory unit, such as a random access memory unit (RAM) and / or a cache memory unit, and may further include a read-only memory unit (ROM).
[0128] The storage unit may also include a program / utility having a set (at least one) of program modules, such program modules including but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment.
[0129] The bus can represent one or more of several types of bus structures, including a memory unit bus or memory unit controller, a peripheral bus, an accelerated graphics port, a processing unit, or a local bus using any of a variety of bus architectures.
[0130] The electronic device may also communicate with one or more external devices (e.g., keyboards, pointing devices, Bluetooth devices, etc.), one or more devices that enable a user to interact with the electronic device, and / or any device that enables the electronic device to communicate with one or more other computing devices (e.g., routers, modems, etc.). Such communication may be performed via an input / output (I / O) interface. Furthermore, the electronic device may also communicate with one or more networks (e.g., local area networks (LANs), wide area networks (WANs), and / or public networks, such as the Internet) via a network adapter. The network adapter communicates with other modules of the electronic device via a bus. It should be understood that other hardware and / or software modules may be used in conjunction with the electronic device, including but not limited to microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0131] Through the above description, it is easy for those skilled in the art to understand that the example embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solution according to this exemplary embodiment can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, and includes several instructions to enable a computing device (which can be a personal computer, a server, a terminal device, or a network device, etc.) to execute the method of the exemplary embodiment of the present application.
[0132] The above specific implementation methods are detailed descriptions of the present invention. It cannot be considered that the specific implementation methods of the present invention are limited to these descriptions. For ordinary technicians in the technical field to which the present invention belongs, they can make several simple deductions and substitutions without departing from the concept of the present invention, which should be regarded as falling within the scope of protection of the present invention.
Claims
1. An infrared defect detection method, characterized in that: include: The infrared thermal image sequence of the test piece is modeled as a three-dimensional tensor, and the tensor is decomposed into the sum of a low-rank tensor, a sparse tensor, and a noise tensor; A Bayesian model is constructed, introducing the prior distribution of low-rank tensors, sparse tensors, noise tensors, and mode coupling parameters to jointly represent the defect posterior distribution; The posterior distribution is approximated by variational inference, and the variational distribution is updated by iterative calculation; The final sparse tensor is output as the defect area information to obtain the infrared defect detection map.
2. The infrared defect detection method according to claim 1, characterized in that: Before building the Bayesian model, the method further includes: Initial values are assigned to the low-rank tensor, the sparse tensor, and the noise tensor, and hyperparameters are initialized, including a sparsity parameter, a noise variance parameter, and a mode coupling parameter.
3. The infrared defect detection method according to claim 1, characterized in that: Introducing prior distributions of low-rank tensors, sparse tensors, noise tensors, and mode coupling parameters, including: A Gaussian prior distribution is introduced for the low-rank tensor, a Laplace prior distribution is introduced for the sparse tensor, and a Gaussian prior distribution is introduced for the noise tensor. The Gaussian distribution is used as the prior distribution of the mode coupling parameter.
4. The infrared defect detection method according to claim 1, characterized in that: The variational distribution is updated through iterative calculation, including: The variation distribution is updated by minimizing the variational free energy. The variational free energy updates the variational distribution of the low-rank tensor, sparse tensor, noise tensor, and mode coupling parameters through iterative calculation. In each iteration, the expectation is calculated based on the variational distribution of the current low-rank tensor, sparse tensor, noise tensor, and mode coupling parameters, and the expectation is used to update the hyperparameters in the subsequent maximization step until the changes in the low-rank tensor, sparse tensor, and mode coupling parameters are all less than the first threshold or the change in variational free energy is less than the second threshold, and the iteration is stopped.
5. The infrared defect detection method according to claim 4, characterized in that: The variational free energy is iteratively calculated to update the variational distribution of low-rank tensors, sparse tensors, noise tensors, and mode coupling parameters, including: The variational distribution of the sparse tensor, noise tensor, and mode coupling parameters are fixed, and the variational distribution of the low-rank tensor is updated by maximizing the expectation with respect to the sparse tensor, noise tensor, and mode coupling parameters; The variational distribution of the low-rank tensor, the noise tensor, and the mode coupling parameters are fixed, and the variational distribution of the sparse tensor is updated by maximizing the expectation with respect to the low-rank tensor, the noise tensor, and the mode coupling parameters; The variational distribution of the low-rank tensor, the sparse tensor, and the mode coupling parameters are fixed, and the variational distribution of the noise tensor is updated by maximizing the expectation with respect to the low-rank tensor, the sparse tensor, and the mode coupling parameters; The variational distribution of the low-rank tensor, sparse tensor, and noise tensor is fixed, and the variational distribution of the mode coupling parameter is updated by maximizing the expectation with respect to the low-rank tensor, sparse tensor, and noise tensor.
6. The infrared defect detection method according to claim 5, characterized in that: Update sparsity parameters include: Computes the expectation of the absolute value of each element in a sparse tensor under its variational distribution, and computes the expectation of the sum of the absolute values of all elements; Update the sparsity parameter based on the expected sum of the absolute values of all elements.
7. The infrared defect detection method according to claim 5, characterized in that: Updating the noise variance parameters includes: Compute the expectation of the square of each element in the noise tensor under the variational distribution of the noise tensor, and compute the expectation of the sum of the squares of all elements; Update the noise variance parameter based on the expected sum of squares of all elements.
8. The infrared defect detection method according to claim 5, characterized in that: Update mode coupling parameters include: Calculate the expectation and square of the mode coupling parameters; The mode coupling parameters are updated according to the expectation of the mode coupling parameters and the expectation of the square.
9. The infrared defect detection method according to claim 1, characterized in that: After outputting the final sparse tensor as defect area information to obtain the infrared defect detection image, the method further includes: Calculate the kurtosis value of each infrared defect detection image; Sort the infrared defect detection images according to the kurtosis value, and select multiple infrared defect detection images with kurtosis values less than the kurtosis value threshold as infrared defect detection result images; Calculate the skewness value of the infrared defect detection result graph; The infrared defect detection result images are sorted according to the skewness values, and one or more infrared defect detection result images with skewness values less than a skewness value threshold are selected as the final infrared defect detection result images.
10. An infrared defect detection device, characterized in that: Used to perform the method according to any one of claims 1 to 9.