# Diesel Spray Macroscopic Parameter Estimation Using a Synthetic Shapes Database
## 2 Algorithm
This operation is referred to as Principal Component Analysis, and is commonly used for image compression. It also turns out to be successfully used for recognition purposes [22]. Let us consider a database made up of \(n\) binary images \(\boldsymbol{\varphi}_{i}\ (i\ =\ 1,\ 2,\ \ldots,n)\), whose images are represented as vectors of size \((h\cdot w)\ \times\ 1\). The mean database image is:  
\[\overline{\boldsymbol{\varphi}}\ =\ \frac{1}{n}\sum_{i\ =\ 1}^{n}\boldsymbol{ \varphi}_{i}\ \ \overline{\boldsymbol{\varphi}}\in\ \mathbb{R}^{N\times 1} \tag{1}\]  
The deviation matrix \(\boldsymbol{D}\) of the database can be evaluated as:  
\[\boldsymbol{D}\ =\ \{\boldsymbol{\omega}_{1},\boldsymbol{\omega}_{2},\ldots, \boldsymbol{\omega}_{n}\}\ \boldsymbol{D}\in\ \mathbb{R}^{N\times n} \tag{2}\]  
where the columns are the deviation vectors of each database image with respect to the mean image. The following formula is used for the computation:  
\[\boldsymbol{\omega}_{i}\ =\ (\boldsymbol{\varphi}_{i}-\overline{\boldsymbol{ \varphi}})\ (i\ =\ 1,2,\ldots,n) \tag{3}\]  
The covariance matrix \(\boldsymbol{C}\) can be obtained by matrix \(\boldsymbol{D}\):  
\[\boldsymbol{C}\ =\ \frac{1}{n}\sum_{i\ =\ 1}^{n}\boldsymbol{\omega}_{i} \boldsymbol{\omega}_{i}^{\ T}\ =\ \boldsymbol{D}\boldsymbol{D}^{T}\ \boldsymbol{C}\in\ \mathbb{R}^{N\times N} \tag{4}\]  
The principal components of the database are the \(M\ (M\leq N)\) eigenvectors \(\boldsymbol{e}_{j}\), also referred to as eigenimages, of the covariance matrix. As stated before, the principal components represent a coordinate system that easily allows for the representation of the data (database image). The computation of the eigenvalues is extremely time-consuming, as it requires the solution of a polynomial equation of order \(N^{2}\) being \(N\) representative of the image size (commonly \(1024\times 768\) or larger). Figure 3: Artificial spray parametrization. As reported in [22], given that the covariance matrix is obtained from a database of only \(n\) images, instead of the covariance matrix \(\mathbf{C}\), the reduced matrix \(\mathbf{B}\) can be used:  
\[\mathbf{B}\ =\ \mathbf{D^{T}}\mathbf{D}\ \mathbf{B}\in\ \mathbb{R}^{n\times n} \tag{5}\]  
Given that \(n\ \ll\ N\), the benefit derived from considering \(\mathbf{B}\) instead of \(\mathbf{C}\) is evident. Each image of the database can be optimally approximated in terms of a linear combination of the \(M\ (M\ \leq\ n)\) eigenvectors:  
\[\hat{\mathbf{\varphi}}_{i}\ \cong\sum_{j\ =\ 1}^{M}b_{ij}\mathbf{e}_{j}+\overline{\mathbf{ \varphi}}\ (i\ =\ 1,2,\ldots,n) \tag{6}\]  
The original spray image, \(\mathbf{\psi}\), is similar to the images of the database. Therefore, one could think to also provide a description of \(\mathbf{\psi}\) by using the computed coordinate system:  
\[\hat{\mathbf{\psi}}\ \cong\sum_{j\ =\ 1}^{M}a_{j}\mathbf{e}_{j}+\overline{\mathbf{\varphi}} \tag{7}\]  
Figure 4 shows a spray image (a) and its approximation (b) obtained using Equation (7). This reconstruction procedure can be seen as a projection of image \(\mathbf{\psi}\) or \(\mathbf{\varphi}_{i}\) over the computed image space. By means of this operation, images become comparable, and the best match can be found by evaluating the minimum Euclidean distance between the spray image projection \(\hat{\mathbf{\psi}}\) and every database reconstructed image \(\hat{\mathbf{\varphi}}_{i}\) :  
\[\delta_{i}^{2}\ =\ \|\hat{\mathbf{\psi}}-\hat{\mathbf{\varphi}}_{i}\ \|\ =\ \sum_{j\ =\ 1}^{M}\left(a_{j}-\ b_{ij}\right)^{2}\ (i\ =\ 1,2, \ldots,n) \tag{8}\]  
where \(a_{j}\) and \(b_{ij}\) are the projection weights to scale each eigenvector. The latter are computed as:  
\[ \begin{array}{rcl}a_{j}&=&\mathbf{e}_{j}^{T}(\mathbf{\psi}-\overline{\mathbf{\varphi}}) &(j\ =\ 1,2,\ldots,M)\\ b_{ij}&=&\mathbf{e}_{j}^{T}(\mathbf{\varphi}_{i}-\overline{\mathbf{\varphi}})&(i\ =\ 1,2,\ldots,n\ )\end{array}