## 2 Principle and Methods of Sparse Representation  
According to the theory of ultrasonic propagation, and considering the attenuation in frequency and shape change caused by the scattering of acoustic waves in different media, each reflected echo has a different shape. So, the model of ultrasonic echo signal is defined as:  
\[y(t)=\sum_{i}c_{i}\phi_{i}(t)+\varepsilon, \tag{1}\]  
Figure 1: Solder joint defect types. where \(\phi_{i}\) represents the reflected signal propagating to the \(i_{\text{th}}\) interface. \(c_{i}\) refers to the reflection function, and \(\varepsilon\) represents the noise from the test sample and the system. It can be seen that the accuracy of detecting the size and the location of defects in the ultrasonic testing process depends on the ability to describe the reflected echo information contained in the ultrasonic signal. As a result of the particularity of the object, the number of interfaces or defects is usually limited, the non-zero value only exists in several isolated locations in the time domain of reflection function \(c_{i}\). That is, the reflection function is sparse, which provides the validity of sparse representation for the ultrasonic signal. The sparse representation of signals refers to approximating the original signals with fewer basis functions (atoms). For a given ultrasound signal \(y\), sparse representation means that under a set of appropriate basis functions Q, the signal can have a set of corresponding decomposition coefficients \(x\). The sparse representation coefficient of signal \(y\) is obtained by calculating:  
\[\min\lVert x\rVert_{0}s.t\lVert y-Dx\rVert_{2}^{2}<\varepsilon, \tag{2}\]  
where \(\lVert x\rVert_{0}\) denotes the \(l_{0}\)-norm of the vector \(x\) to ensure the sparsity of solution. \(D\) refers to the set of base functions \(Q\), i.e., dictionary \(D=\left\{Q_{i}Q_{i}\in R^{N}\right\}_{i=1}^{L}\), \(x\) represents the sparse decomposition coefficient of the signal, and \(\varepsilon\) is the residue of coefficient representation. The set of atoms in the dictionary corresponding to non-zero elements in \(x\) is the support set of the solution. In order to make the shape of the atoms in the dictionary more similar to the signal and the support set smaller, the dictionary is usually extended into an over-complete dictionary. That is, the dictionary is composed of L atoms. The length of each atom is \(N\), where \(N<L\). For the time-domain signal of ultrasonic echo, it is generally a broadband pulse signal centered on the probe frequency. The Gabor function can be used to make a complete description. When generating a complete dictionary based on the Gabor function, the dictionary contains many control parameters, and each atom in the dictionary can be represented by Equation (3):  
\[a=\frac{K}{\sqrt{S}}\exp(-\pi\frac{(t-u)^{2}}{s^{2}})*\cos(2\pi f(t-u)), \tag{3}\]  
where \(a\) represents a single atom, \(S\) is a scaling parameter, \(u\) is a translation parameter, \(f\) is a frequency domain parameter, and \(K\) is the amplitude parameter used for atom normalization. Values of \(S\), \(u\), and \(f\) are determined by the reference echoes obtained from experiments. The surface echo signal is obtained as a reference echo by using a high-frequency ultrasound probe to detect a sufficiently large plane, and the echo is fitted by the Gabor model. The results are \(S_{\gamma}=0.67\), \(f_{\gamma}=0.24\), and \(u_{\gamma}=49.72\) respectively. Equation (3) is solved by the least squares orthogonal matching pursuit algorithm. The basic idea is to start with an empty set and construct an approximation of \(K\) terms by keeping a set of effective supporting set atoms. Then, we expand the solution set by adding one supporting set atom at each step. Each time the solution set is extended, the columns that can minimize the residuals are selected directly on the basis of the current support set, thus approaching \(y\) gradually.