# Magnitude Modeling of Personalized HRTF Based on Ear Images and Anthropometric Measurements
## 3 Proposed Method
### Deep Learning Model Design
#### 3.2.1 Spherical Harmonic Decomposition  
The spherical harmonics (SH) are a set of the orthogonal basis of spherical coordinates. The target HRTF amplitude \(H(\theta,\phi)\) along the direction can be expressed as the weighted sum of real-valued spherical harmonic functions, as the function below:  
\[H(\theta,\phi)=\sum_{l,k}Y_{l}^{k}(\theta,\phi)\beta_{l}^{k} \tag{1}\]  
where \(H(\theta,\phi)\) represents the HRTF, in which the azimuth \(\theta\in[0,\pi]\) is measured from the z-axis and the elevation \(\phi\in[0,2\pi]\) is measured from the x-axis. \(Y_{l}^{k}(\theta,\phi)\) denotes the spherical harmonic basis function of order \(l\) and degree \(k\); \(\beta_{l}^{k}\) is the SH decomposed coefficients.  
The real spherical harmonics are defined as follows. The real spherical harmonics have the same orthonormality properties as the complex spherical harmonics.  
\[Y_{l}^{k}(\theta,\phi)=\left\{\begin{array}{ll}\sqrt{\frac{(2l+1)}{2\pi}} \frac{(l-|k|)}{(l+|k|)^{2}}P_{l}^{k}(\cos\theta)\cos\left(k\phi\right)&\quad k >0\\ \sqrt{\frac{(2l+1)}{4\pi}}P_{l}^{k}(\cos\theta)&\quad k=0\\ \sqrt{\frac{(2l+1)}{2\pi}}\frac{(l-|k|)}{(l+|k|)^{2}}P_{l}^{k|}(\cos\theta) \sin\left(|k|\phi\right)&\quad k<0\end{array}\right. \tag{2}\]  
where \(P_{l}^{k}\) is the associated Legendre function of order \(l\) and degree \(k\). Figure 7 shows the real parts of the first 4 th order SH basis. The spherical harmonic function of order 0 is an omnidirectional sphere, so the recorded sound field has no azimuth information. The 1 st order spherical harmonic function is three 8-shaped, which respectively receive the information components in the x, y, and z directions. The number of components added to each order is 2\(\times\)(\(l\)+1), so the number of \(L\)-order spherical harmonic basis functions is \((L+1)^{2}\).  
The process of SHT is to calculate the coefficients of each SH basis function [37]. Representing (1) in matrix form, we have:  
\[h=Yb \tag{3}\]  
Figure 7: Spherical harmonic bases up to \(L\) = 4.  
where  
\[\begin{split}& h=[h(\theta_{1},\phi_{1}),...h(\theta_{s},\phi_{s})]^{T} \\ & Y=[y_{00},y_{1-1},y_{10},...y_{ll}]\\ & Y_{l}^{k}=[Y_{l}^{k}(\theta_{1},\phi_{1}),...Y_{l}^{k}(\theta_{s },\phi_{s})]^{T}\\ & b=[b_{00},b_{1-1},b_{10},...b_{ll}]\end{split} \tag{4}\]  
In Equation (4), \(h\) contains the original magnitude values on \(S\) spatial directions, \(Y\) contains SH base values of up to order \(L\), and \(b\) is the SH coefficients. To calculate the vector \(b\), we use the least-squares (LS) approach the decomposition coefficients. That is:  
\[b=(Y^{T}Y+\lambda I)^{-1}Y^{T}h \tag{5}\]  
The spherical harmonic coefficient \(b\) includes the spatial orientation characteristics of the HRTF at a certain position in space, and the reconstructed HRTF at a certain position can be obtained by multiplying the spherical harmonic coefficient and the spherical harmonic basis function.  
Ref. [23] proposes and verifies that the HRTF model based on 4 th order SH can retain accurate localization performance. The audience is not sensitive to fine spectral details in the HRTF amplitude spectrum. Therefore, in the method of this paper, the truncation order of SH is set to \(L=4\), the amplitude operation is performed on the HRTF of the subject, and the SHT is performed for each frequency to obtain the corresponding SH base coefficients (\(b\) vector). Finally, the \(b\) vector of each frequency bin is connected as a reference value for the model.