# SNR Analysis for Quantitative Comparison of Line Detection Methods
## 4 Method--SNR of SGAD for Line Detection
### Dispersion of Gradient Angle Differences  
The dispersion of the single-angle difference between the \(i\)th and the \(j\)th pixels, \(D\{\theta_{i}\text{-}\theta_{j}\}\) is calculated as follows:  
\[D\{\theta_{i}\text{-}\theta_{j}\}= \begin{bmatrix}1&-1\end{bmatrix} D\bigg{\{} \begin{bmatrix}\theta_{i}\\ \theta_{j}\end{bmatrix} \bigg{\}} \begin{bmatrix}1\\ -1\end{bmatrix} . \tag{48}\]  
The dispersion of the vector of the angles in Equation (48) is derived as follows:  
\[D\bigg{\{} \begin{bmatrix}\theta_{i}\\ \theta_{j}\end{bmatrix} \bigg{\}}=\mathbf{J}_{\theta(i,j)}D\left\{\begin{bmatrix} \begin{bmatrix}\xi_{i}\\ \xi_{i}\\ \xi_{i}\\ \xi_{i}\end{bmatrix} \right\}\mathbf{J}_{\theta(i,j)}^{T}, \tag{49}\]  
where  
\[\mathbf{J}_{\theta(i,j)}= \begin{bmatrix}\frac{\partial\theta_{i}}{\partial\xi _{i}}&\frac{\partial\theta_{i}}{\partial\xi_{i}}&0&0\\ 0&0&\frac{\partial\theta_{i}}{\partial\xi_{i}}&\frac{\partial\theta_{i}}{ \partial\xi_{i}}\end{bmatrix} ,\]  
\[\frac{\partial\theta}{\partial\xi_{i}}= - \frac{\xi_{i}}{\xi_{i}^{2}+\xi_{i}^{2}},\] \[\frac{\partial\theta}{\partial\xi_{i}}= \frac{\xi_{i}}{\xi_{i}^{2}+\xi_{i}^{2}}.\]  
Then, the dispersion of the vector of the gradients in Equation (49) is derived as follows:  
\[D\left\{ \begin{bmatrix}\xi_{i}\\ \xi_{i}\\ \xi_{i}\\ \xi_{i}\\ \xi_{i}\end{bmatrix} \right\}=\mathbf{J}_{g(i,j)}\sigma_{\mathbf{n}*\mathbf{s}} ^{2}\mathbf{R}_{i,j}\mathbf{J}_{g(i,j)}^{T}. \tag{50}\]  
The value of the gradient in the column direction at the \(i\)th pixel is calculated by convoluting the smoothed image with the kernel \(\mathbf{D_{c}}\) as follows:  
\[g_{ci}=\left(\mathbf{I}*\mathbf{s}*\mathbf{D_{c}}\right)_{i}=\left(\mathbf{F}* \mathbf{b}*\mathbf{s}*\mathbf{D_{c}}\right)_{i}+\left(\mathbf{n}*\mathbf{s}* \mathbf{D_{c}}\right)_{i} \tag{51}\]  
To calculate the gradients in the row direction, a kernel is defined as follows:  
\[\mathbf{D_{r}}=\frac{1}{8} \begin{bmatrix}-1&-2&-1\\ 0&0&0\\ 1&2&1\end{bmatrix} . \tag{52}\]  
Then, the value of the gradient in the row direction at the \(i\)th pixel is calculated using the convolution of the smoothed image with the kernel \(\mathbf{D_{r}}\) as follows:  
\[g_{r_{i}}=\left(\mathbf{I}*\mathbf{s}*\mathbf{D_{r}}\right)_{i}=\left(\mathbf{ F}*\mathbf{b}*\mathbf{s}*\mathbf{D_{r}}\right)_{i}+\left(\mathbf{n}*\mathbf{s}* \mathbf{D_{r}}\right)_{i}. \tag{53}\]  
Figure 6: Pairings for calculating gradient angle differences. Figure 7 shows the windows for calculating the gradients, where the numbers within the pixels represent the pixel indices used to indicate the pixel locations in the Jacobian matrices below. In Figure 7a, the center pixel is located at 8 and the gradient angle difference is calculated for the pixels located at 5 and 11. In Figure 7b, the center pixel is located at 9 and the gradient angle difference is calculated for the pixels located at 5 and 13. Then, the Jacobian matrix \(\mathbf{J}_{g(i,j)}\) in Equation (50) when \(i=4\) and \(j=5\) is derived using \(\mathbf{D_{c}}\) and \(\mathbf{D_{r}}\). Moreover, the Jacobian matrix, \(\mathbf{J}_{g(i,j)}\) in Equation (50) when \(i=1\) and \(j=8\) is derived using \(\mathbf{D_{c}}\) and \(\mathbf{D_{r}}\). The correlation matrix \(\mathbf{R}_{i,j}\) in Equation (50) when \(i=4\) and \(j=5\) is derived as per Figure 7a and Equation (26). The correlation matrix \(\mathbf{R}_{i,j}\) in Equation (50) when \(i=1\) and \(j=8\) is derived as per Figure 7b and Equation (26). Thus, the dispersion of the vector of the gradients in Equation (50) when \(i=4\) and \(j=5\) is derived as follows:  
\[D\left\{ \begin{bmatrix}g_{\xi_{4}}\\ g_{\xi_{5}}\\ g_{\xi_{5}}\\ \end{bmatrix} \right\}=\frac{\sigma_{\mathbf{n_{s}}\mathbf{s}}^{2}}{64} \begin{bmatrix} P_{1}&0&P_{2}&0\\ 0&P_{1}&0&P_{3}\\ P_{2}&0&P_{1}&0\\ 0&P_{3}&0&P_{1}\\ \end{bmatrix}