# Multiscale Feature-Based Infrared Ship Detection
## 2 Materials and Methods
### Candidate-Region Extraction Based on Grayscale and Edge Features  
The images of the sea surface area excluding the sky and land are shown in Figure 5a, where the sea surface background occupies most of the pixels in the image and the ship target area is relatively small. There is a significant difference in grayscale distribution between the ship and the background. As is shown in Figure 5b, the histogram of the image of the sea surface area exhibits the distinct characteristics of a unimodal distribution, and the pixels of the sea surface background occupy most of the area. The maximum entropy method [18] can calculate the segmentation threshold based on the intra-class grayscale probability of pixels, which can determine a reasonable segmentation threshold for the histogram with unimodal distribution and improve the segmentation effect when there exists significant contrast between the target and the background. However, this method involves multiple logarithmic operations when calculating the entropy values of the foreground and background, resulting in a time complexity of O(N\({}^{2}\)). In the case where the grayscale level of the image is 256, a total of 256\({}^{2}\) or 65,536 logarithmic operations are required. According to fractal theory, both entropy and correlation can be utilized to measure images; however, the time complexity of the latter is only O(N), meaning that when the grayscale of the image is 256, only 256 \(\times\) 2 or 512 logarithmic operations are required. Therefore, correlation is employed here as a substitute replacing the entropy used to determine coarse segmentation [19]. Assuming that the sea surface area image has the number of rows \(H\) and the number of columns \(W\) and that the number of occurrences of the grayscale \(i\) in the histogram is \(h_{i}\), the probability \(p_{i}\) of each grayscale can be calculated as:  
\[p_{i}=h_{i}/(H\cdot W) \tag{7}\]  
Using the threshold \(T\) to split the image into background class \(B\) and foreground class \(O\), the probability of foreground class and background class can be written as:  
\[\omega_{o}(T)=\sum_{i=T+1}^{256}p_{i}, \tag{8}\]  
\[\omega_{b}(T)=\sum_{i=1}^{T}p_{i}=1-\omega_{o} \tag{9}\]  
Figure 5: (**a**) Image and (**b**) histogram of the sea surface area. Supposing that \(X=\{x_{0},\,x_{1},\,x_{2},..\}\) is a set of discrete random variables where \(p_{i}\) represents the probability of the variable \(x_{i}\), the correlation of \(X\) can be defined as  
\[C(X)=-\ln\sum_{i\geq 0}{p_{i}}^{2}, \tag{10}\]  
The sum of the correlations of the foreground and background after the segmentation, and the optimal segmentation threshold selection criterion, can be written as:  
\[C(T)=-\ln\sum_{i=1}^{T}{(\frac{p_{i}}{\omega_{b}(T)})}^{2}-\ln\sum_{T+1}^{256}{ (\frac{p_{i}}{\omega_{o}(T)})}^{2}, \tag{11}\]  
\[T=\arg\max_{1\leq T\leq 256}\{C(T)\} \tag{12}\]  
Therefore, a coarsely segmented image can be obtained by using the following Equation (13):  
\[BW_{MC}(i,j)=\left\{ \begin{array}{ll}1,&I(i,j)>T\\ 0,&otherwise\end{array} \right. \tag{13}\]  
Since the coarse segmentation based on Equations (11)-(13) only takes grayscale features into consideration and ignores spatial information, it may result in the presence of significant clutter and isolated noise in the segmented image, as shown in Figure 6b. Taking into account the fact that ships in sea surface scenarios are generally closed connected regions with discernible edge contours, edge features can be adopted to further improve segmentation results. Here, we choose the Robert operator (Equation (14)), which allows us to calculate the cross gradient and extract the edge profile in the sea surface image; the edge feature image is calculated according to the following Equation (15):  
\[Robert_{45^{*}}= \begin{pmatrix}0&-1\\ 1&0\end{pmatrix} ,\quad Robert_{135^{*}}= \begin{pmatrix}-1&0\\ 0&1\end{pmatrix}