# Line-Detection Based on the Sum of Gradient Angle Differences
## 3 Proposed Line-Detection Method
### Line Model  
In image processing, blur and noise are always non-negligible because of the limitations of camera lens systems. Studies have previously adopted the approach that any real image \(\mathbf{I}\) can be modeled as a base signal \(\mathbf{F}\) convolved with blur \(\mathbf{b}\) and noise \(\mathbf{n}\)[27; 28; 29; 30; 31; 32; 33; 34; 35], as follows:  
\[\mathbf{I}=\mathbf{F}*\mathbf{b}+\mathbf{n}, \tag{1}\]  
where \(*\) represents the convolution operator. Although a more complete blur model with blurring patterns in edge neighborhoods was proposed in [36], the present study employed the image formation model described in (1) for simplifying experiments.  
In this study, line profile is modeled in terms of width \(w\) and contrast \(k\), as shown in Figure 1. Although a more general line model has been proposed previously [18], which models a line with different contrasts on either side, the derivation here uses the simpler model shown in Figure 1 because it simplifies subsequent tests, and most line features have similar contrasts on either side.  
From Figure 1, the one-dimensional line signal is modeled as follows:  
\[\mathbf{F}(x)=\begin{cases}h+k,&\text{if }|x-L|<\frac{w}{2};\\ h,&\text{otherwise}\end{cases} \tag{2}\]  
where \(L\) is the coordinate of the line center.  
The following one-dimensional Gaussian blur is introduced to consider the blur effects that occur during image formation:  
\[\mathbf{b}(t)=\frac{1}{\sqrt{2\pi\sigma_{b}}}e^{-\frac{t^{2}}{2\sigma_{b}^{2} }}, \tag{3}\]  
where \(\sigma_{b}\) is the blurring factor.  
Figure 2 shows an exaggerated version of the blur function \(k\cdot\exp(-\frac{(t-x)^{2}}{2\sigma_{b}^{2}})\) centered at an arbitrary location \(x\). Thus, the intensity at \(x\) after blurring is given as follows:  
\[\begin{split}\mathbf{F_{b}}(x)&=(\mathbf{F}*\mathbf{ b})(x)=\int_{x-\frac{w}{2}-L}^{x+\frac{w}{2}-L}\frac{k}{\sigma_{b}\sqrt{2\pi}}e^{- \frac{t^{2}}{2\sigma_{b}^{2}}}dt,\\ &=\frac{k}{2}\big{[}\text{erf}\big{(}\frac{x+\frac{w}{2}-L}{ \sigma_{b}\sqrt{2}}\big{)}-\text{erf}\big{(}\frac{x-\frac{w}{2}-L}{\sigma_{b} \sqrt{2}}\big{)}\big{]},\end{split} \tag{4}\]  
where \(\text{erf}(\cdot)\) is the error function.  
For denoising, a certain amount of smoothing is invariably required. Image smoothing is typically performed with a kernel defined by a two-dimensional Gaussian function, which can be described as follows:  
\[\mathbf{s}(u,v)=\frac{1}{2\pi\sigma_{s}^{2}}e^{-\frac{u^{2}+p^{2}}{2\sigma_{s} ^{2}}}, \tag{5}\]  
where \(\sigma_{s}\) is the smoothing factor. The corresponding one-dimensional smoothing function can be written as follows:  
\[\mathbf{s}(u)=\frac{1}{\sqrt{2\pi\sigma_{s}}}e^{-\frac{x^{2}}{2\sigma_{s}^{2} }}. \tag{6}\]  
Figure 1: One-dimensional line profile model used in current study.  
Figure 2: Gaussian blur for one-dimensional line model.  
Then, by applying the convolution of the smoothing function \(\mathbf{s}\) to the original image, the smoothed image \(\mathbf{I_{s}}\) can be generated as follows:  
\[\mathbf{I_{s}}=\mathbf{I}*\mathbf{s}=(\mathbf{F}*\mathbf{b}+\mathbf{n})*\mathbf{ s}=\mathbf{F}*\mathbf{b}*\mathbf{s}+\mathbf{n}*\mathbf{s}. \tag{7}\]  
Thus, after the convolutions of blurring and smoothing, the original line signal in (2) is transformed according to [37] as follows:  
\[\mathbf{F_{bs}}(x)=(\mathbf{F}*\mathbf{b}*\mathbf{s})(x)=(\mathbf{F_{b}}* \mathbf{s})(x)=\int_{x-\frac{\pi}{2}-L}^{x+\frac{\pi}{2}-L}\frac{k}{\sqrt{2\pi (\sigma_{b}^{2}+\sigma_{s}^{2})}}e^{-\frac{l^{2}}{2(\sigma_{b}^{2}+\sigma_{s} ^{2})}}dt. \tag{8}\]