# A Line Segment Detector for Space Target Images Robust to Complex Illumination
## 2 Methods
### Anchor Map Extraction Method Combined with Improved Otsu  
To further improve the robustness of the line detection under complex illumination, an adaptive image segmentation method based on the Otsu algorithm is introduced. The traditional two-dimensional Otsu algorithm has limitations in processing images with salt-and-pepper noise and uneven illumination. An improved two-dimensional histogram construction strategy is proposed to improve the extraction of the anchor map. Suppose \(f\) is an image represented in \(L\) gray value with \(M\) rows and \(N\) columns. Let \(A\) be the corresponding mean image. The gray level of pixels in \(A\) is calculated by:  
\[A(x,y)=\sum_{\widetilde{x}=x-(k-1)/2}^{x+(k-1)/2}\sum_{\widetilde{y}=y-(k-1)/2 }^{y+(k-1)/2}f(\widetilde{x},\widetilde{y}) \tag{5}\]  
where, \(A(x,y)\) and \(f(x,y)\) represent the gray level of the pixel at \((x,y)\) in \(A\) and \(f\), respectively. \(k\) represents the size of the filter, and the value of \(k\) is set to be 3 in our work. To reduce the complexity, two-dimensional tuples are used to simplify the calculation [44]. Let \(f(x,y)=i\), \(A(x,y)=j\), both of which form the tuple \(G(x,y)\). Then, the tuple contains the gray level of any pixel and its corresponding neighborhood mean gray information. Suppose \(n_{ij}\) is the number of occurrences of pixel \((x,y)\) in the histogram. Thus, the two-dimensional joint probability function \(P_{ij}\) is obtained as:  
\[P_{ij}=\frac{n_{ij}}{M\times N} \tag{6}\]  
where \(x,y\in[0,L-1]\),\(n_{ij}\in[0,M\times N]\) and \(\sum\limits_{i}\sum\limits_{j}P_{ij}=1\). Given a threshold pair \((s,t)\) consisting of gray threshold \(s\) and neighborhood mean gray threshold \(t\). The two-dimensional histogram shown in Figure 3 is divided into four areas \(A\), \(B\), \(C\), and \(D\) representing the background, edge, target, and noise. For the space target images, the gray value of the pixel inside the target is roughly the same as the neighborhood mean gray level, and so is the gray value of the spatial background. However, the gray values at the edges of the target and the noise are different. For a given threshold pair \((s,t)\), image pixels can be divided into two groups, background \(T_{b}\) and objects \(T_{o}\). Their occurrence probabilities can be expressed as:  
\[\omega_{b}=P(T_{b})=\sum\limits_{i=1}^{s}\sum\limits_{j=1}^{t}P_{ij} \tag{7}\]  
\[\omega_{o}=P(T_{o})=\sum\limits_{i=s}^{L-1}\sum\limits_{j=t}^{L-1}P_{ij} \tag{8}\]  
where the mean vectors \(\delta_{b}\) and \(\delta_{o}\) corresponding to \(T_{b}\) and \(T_{o}\) can be expressed as:  
\[\delta_{b}=\left(\delta_{bi},\delta_{bj}\right)^{T}=\left(\sum\limits_{i=1}^{ s}\sum\limits_{j=1}^{t}\frac{iP_{ij}}{\omega_{b}},\sum\limits_{i=1}^{s}\sum \limits_{j=1}^{t}\frac{jP_{ij}}{\omega_{b}}\right)^{T} \tag{9}\]  
\[\delta_{\rm O}=\left(\delta_{Oi},\delta_{Oj}\right)^{T}=\left(\sum\limits_{i= s}^{L-1}\sum\limits_{j=t}^{L-1}\frac{iP_{ij}}{\omega_{o}},\sum\limits_{i=s}^{L-1} \sum\limits_{j=t}^{L-1}\frac{jP_{ij}}{\omega_{o}}\right)^{T} \tag{10}\]  
Due to the assumption that the occurrence of image data away from the diagonal of the 2D histogram is negligible [45], we can obtain the following approximate expression:  
\[\omega_{b}+\omega_{o}\approx 1,\delta_{L}=\omega_{b}\delta_{b}+\omega_{o} \delta_{o} \tag{11}\]  
The between-class variance of the two-dimensional Otsu algorithm can be defined as follows:  
\[\sigma_{B}=\sum\limits_{k=0}^{1}\omega_{k}[(\delta_{k}-\delta_{T})(\delta_{k }-\delta_{T})^{T}] \tag{12}\]  
Figure 3: Planar projection of two-dimensional gray histogram.