# On-Board Ship Detection in Micro-Nano Satellite Based on Deep Learning and COTS Component
## 2 On-Board Ship Detection Based on Deep Learning
### Bigger-Left Non-Maximum Suppression  
The output of the trained network will produce a large number of overlapping detection boxes, and the traditional algorithms usually adopt the NMS method to remove the redundancy. The NMS method is used to calculate the IoU overlap of two boxes according to the score of the detection boxes one by one. If the IoU overlap is greater than the threshold, the detection box with lower score will be removed. If the IoU overlap is less than the threshold, the two detection boxes will be retained. As shown in Figure 4, the NMS method can remove a lot of overlapping boxes. If the box with high score cover the ship target incompletely, it will lead to the target patch only contains parts of ships, which influences the further recognition and analysis for ground users.  
To reduce incomplete target patches, we use the method of BL-NMS. Algorithm 1 illustrates the process of BL-NMS in detail. Firstly, the traditional NMS method is employed to calculate the IoU overlap of two detection boxes. Then if the IoU overlap is greater than the threshold, the detection box with high score will be updated to a larger detection box that can fully contain the two detection boxes. Finally the detection boxes can contain more target areas to ensure that the target will not be truncated when all detection boxes are refined by BL-NMS. Figure 4 shows the results of different NMS methods. The target patches by BL-NMS have a better coverage of ships than the target patches by NMS. In this paper, we choose 0.3 as the threshold of BL-NMS.  
Figure 4: The results of different Non-Maximum Suppression (NMS) methods. **(a)** The small slice of input image. **(b)** The detection result of the network with many overlapping boxes. **(c)** The detection result of traditional NMS. **(d)** The target patch extracted by traditional NMS. **(e)** The detection result of Bigger-Left Non-Maximum Suppression (BL-NMS). **(f)** The target patch extracted by BL-NMS.  
```
0:
1:\(\textbf{B}=\{\text{b}_{1},\text{...,}\text{b}_{N}\},\textbf{S}=\{\text{s}_{1}, \text{...,}\text{s}_{N}\},\textbf{B}_{final}=\{\},\text{T},\)
2:\(\textbf{B}\) is the list of detection boxes before BL-NMS, and S is the list of detection scores of each boxes.
3:\(\textbf{B}_{final}\) is the list of detection boxes after BL-NMS, and T is the threshold of BL-NMS.
4: N is the number of detection boxes.
5:\(b_{i}=(x_{1},y_{1},\)\(x_{2},y_{2})\), where \((x_{1},y_{1})\) and \((x_{2},y_{2})\) denote the positions for top-left and bottom-right points of detection boxes.
6:while\(\textbf{B}\
eq\emptyset\)do
7:\(ind=argmax(\textbf{S})\)
8:\(b_{buf}=b_{ind}\), \(b_{bigger}=b_{ind}\)
9:\(\textbf{B}=\textbf{B}-b_{buf}\)
10:for\(b_{i}\) in Bdo
11:if IoU(\(b_{buf}\), \(b_{i}\)) \(\geq\) T then
12:\(\textbf{B}=\textbf{B}-b_{i}\), \(\textbf{S}=\textbf{S}-s_{i}\)
13:\(b_{bigger}=(min(b_{bigger}(x_{1}),b_{i}(x_{1})),min(b_{bigger}(y_{1}),b_{i} (y_{1}))\),
14:\(max(b_{bigger}(x_{2}),b_{i}(x_{2})),max(b_{bigger}(y_{2}),b_{i}(y_{2})))\)
15:\(\textbf{B}_{final}=\textbf{B}_{final}\bigcup b_{bigger}\)
16:endif
17:endfor
18:endwhile
19:return\(\textbf{B}_{final}\), S
```  
**Algorithm 1** Bigger-Left Non-Maximum Suppression (BL-NMS)