# Cavity Detection in Steel-Pipe Culverts Using Infrared Thermography +
## 4 Method
### Principal Components Thermography  
Principal components analysis (PCA) is a statistical approach that maps a set of possibly correlated N-dimensional data to a new space with orthogonal basis along directions with the largest variances. Data in the new space is uncorrelated (diagonal covariance matrix). In machine learning and pattern recognition, PCA is generally used to improve the curse of dimensionality and feature reduction. In some disciplines (e.g., oceanography, meteorology, and climate science) PCA is known as empirical orthogonal function (EOF) analysis [65; 66]. PCT [50] is the application of PCA in thermography for nondestructive testing and inspection.  
For large matrices, which is often the case in image processing, the computational cost of the traditional PCA analysis becomes extremely large and limits the usage of this approach. A more computationally effective alternative is based on singular value decomposition (SVD). In this method, similar to the traditional approach, each 2D image matrix is converted to a vector by concatenation of its row. If the thermal images are denoted by \(T(i,j,k)\) where \(i=1,2,\cdots N_{i}\), \(j=1,2,\cdots N_{k}\), and \(k=1,2,\cdots N_{k}\), then the corresponding vectors are \(\mathbf{x}_{k}=[x_{1k},x_{2k},\cdots,x_{M}]^{T}\) where \(M=N_{i}\times N_{j}\) and \(N=N_{k}\). This process is repeated for all the images of the thermal sequence and all these column vectors are combined into a matrix as follows:  
\[\mathbf{A}=\begin{pmatrix}\uparrow&\uparrow&&\uparrow\\ \mathbf{x}_{1}&\mathbf{x}_{2}&\cdots&\mathbf{x}_{N}\\ \downarrow&\downarrow&&\downarrow\end{pmatrix}, \tag{6}\]  
in which \(N\) is the number of frames of the thermal sequence. Now, the data is normalized using its mean value and standard deviation:  
\[\hat{A}(n,m)=\frac{A(n,m)-\mu_{m}}{\sigma_{m}}, \tag{7}\]  
with  
\[\mu_{m}=\frac{1}{N}\sum_{n=1}^{N}A(m,n), \tag{8}\]  
\[\sigma_{m}^{2}=\frac{1}{N-1}\sum_{n=1}^{N}\left(A(m,n)-\mu_{m}\right)^{2}. \tag{9}\]  
Then the following factorization (known as SVD) of \(\hat{\mathbf{A}}\) is used:  
\[\hat{\mathbf{A}}=\mathbf{U}\mathbf{D}\mathbf{V}^{\mathrm{T}}, \tag{10}\]  
where \(\mathbf{U}\) is an \(M\times M\) unitary matrix (aka the left-singular vectors of \(\hat{\mathbf{A}}\)), \(D\) is a diagonal matrix consisting of singular values of \(\hat{\mathbf{A}}\), and \(\mathbf{V}\) is an \(N\times N\) unitary matrix (aka the right-singular vectors of \(\hat{\mathbf{A}}\)). Columns of \(\mathbf{U}\) are orthonormal eigenvectors of \(\hat{\mathbf{A}}\hat{\mathbf{A}}^{T}\) and singular values of \(\hat{\mathbf{A}}\) are the square root of eigenvalues of \(\hat{\mathbf{A}}\hat{\mathbf{A}}^{T}\). Columns of \(\mathbf{U}\) can be seen as basis vectors(principal components) of \(\hat{\mathbf{A}}\) and their contribution to reconstruction of \(\hat{\mathbf{A}}\) is determined by corresponding singular values. Singular vectors and corresponding singular values are often sorted in a descending order. The first few components contribute to more than 99% of the total data variation. Therefore, only this part of the data is used for analysis. The first few columns can be converted back to 2D matrices and shown as images that are sometimes referred to as EOFs.