# SNR Analysis for Quantitative Comparison of Line Detection Methods
## 3 Method--SNR of ED and SD for Line Detection
### Derivation of SNRs  
In the following section, the SNRs of ED-based and SD-based line detections are derived using the signal strengths quantified in Section 3.2 and the amount of noise resulting from the smoothing and convolution of specific kernels described in Section 3.3. To make the calculation simple, the normal direction of lines to be detected is assumed to be aligned in the column direction in the following derivations. To detect edge pixels at the boundaries of a line, its SNR for the first derivative in the normal direction is derived from Equations (11) and (31) as follows:  
\[\text{SNR}\Big{(}\text{edge}_{\mathbf{D_{c}}}\Big{)}=\frac{\mathbf{F_{b*s}^{ \prime}}|_{x=L-\frac{\omega}{2}}}{\sigma_{\mathbf{n_{s}s+D_{c}}}}. \tag{35}\]  
Similarly, the edge SNR for the second derivative in the normal direction can be derived from Equations (12) and (34). However, in this study, the second derivative of the edge profile model is assumed to be positive at \(x=L-\frac{\omega}{2}-1\). Thus, the max(\(\cdot\)) operation is applied to suppress the negative signals and the edge SNR for the second derivative in the normal direction is derived as follows:  
\[\text{SNR}\Big{(}\text{edge}_{\mathbf{D_{cc}}}\Big{)}=\frac{\text{max}( \mathbf{F_{b*s}^{\prime}}|_{x=L-\frac{\omega}{2}-1},0)}{\sigma_{\mathbf{n_{s}s +D_{c}}}}. \tag{36}\]Given that the edge detection is performed based on combining the first and second derivatives in this study, the SNRs for both the derivatives are combined into the measure \(\text{SNR}_{\text{C}}(\text{edge})\) as follows:  
\[\text{SNR}_{\text{C}}(\text{edge})=\sqrt{\text{SNR}\Big{(}\text{edge}_{\mathbf{ D}_{\text{c}}}\Big{)}\cdot\text{SNR}\Big{(}\text{edge}_{\mathbf{D}_{\text{c}}} \Big{)}}. \tag{37}\]  
The SNR of the SD-based line detection for the first derivative in the normal direction can be derived from Equations (13) and (31) as follows:  
\[\text{SNR}(\text{line}_{\mathbf{D}_{\text{c}}})=\frac{\mathbf{F}_{\mathbf{b \ast s}}^{\prime}|_{x=L-1}}{\sigma_{\mathbf{n\ast s\ast D_{\text{c}}}}}. \tag{38}\]  
The SNR of SD-based line detection for the second derivative in the normal direction can be derived from Equations (14) and (34) as follows:  
\[\text{SNR}(\text{line}_{\mathbf{D}_{\text{c}}})=-\frac{\mathbf{F}_{\mathbf{b \ast s}}^{\prime\prime}|_{x=L}}{\sigma_{\mathbf{n\ast s\ast D_{\text{c}}}}}. \tag{39}\]  
Then, because the SD-based line detection is considered to be performed based on combining the first and second derivatives in this study, the SNRs of both the derivatives are combined into the measure \(\text{SNR}_{\text{C}}(\text{line}_{\text{SD}})\) as follows:  
\[\text{SNR}_{\text{C}}(\text{line}_{\text{SD}})=\sqrt{\text{SNR}(\text{line}_ {\mathbf{D}_{\text{c}}})\cdot\text{SNR}(\text{line}_{\mathbf{D}_{\text{c}}} )}, \tag{40}\]  
where the subscript SD in \(\text{SNR}_{\text{C}}(\text{line}_{\text{SD}})\) represents the SNR measure for the SD-based line detection so that it can be distinguished from that of the SGAD-based line detection. With the increase in sizes of blurring and smoothing, the signals tend to mix with their neighborhood signals and degenerate. Based on this rationale, in this study, a penalty function is introduced to measure the degeneration of signals with the increase in the sizes of blurring and smoothing. However, as line width increases, the degeneration of signal owing to blurring and smoothing decreases. Accordingly, the penalty function is modeled as follows:  
\[p(\sigma_{b},\sigma_{s},w)=w^{\lambda}\Big{(}\sigma_{b}^{2}+\sigma_{s}^{2} \Big{)}^{-1}, \tag{41}\]  
where \(\lambda\) is the power factor applied to line width, \(w\), so that it can reflect the decrease of degeneration effect of signal strength because of blurring and smoothing. From a set of brief experiments, the value of \(\lambda\) was set to 0.3 in this study.