# Accurate Tracking Algorithm for Cluster Targets in Multispectral Infrared Images
## 3 Methods
### Local Segmentation of Double-Threshold Images  
Mask R-CNN [14] is an instance segmentation algorithm, and the region of interest (ROI) is used as a network branch of the deep convolution neural network to realize the instance segmentation of the target image. To preserve the accuracy of the target spatial location coordinates, the Mask R-CNN network replaces the ROIPool operation with the ROIAlign operation. ROIAlign can be used to correct the misplaced layer of spatial quantization feature extraction. The bilinear difference keeps the spatial position accuracy between the input network and the output network constant and corresponds to the coordinate value of the ROI bin. The dependency between the judgment class (Class) and the output mask (MASK) is minimized, and the prediction of the binary mask, with the average binary cross-entropy loss for each target, is realized separately, which reduces the competitiveness among the classes and improves the efficiency of image segmentation. Based on the Mask R-CNN network structure, the network depth and width are optimized, and transfer learning is carried out. The parameters and network model are obtained by calculating the segmentation accuracy of the different layers and different convolution cores. Finally, the optimal network model is determined as a PigNet network structure, and two improvements to the Mask R-CNN network structure are made in terms of the convolution layer and class number:  
1. For different target regions in the image, the Mask R-CNN network is changed from 69 convolution layers to 12 layers in the fourth stage, which can reduce the level of feature loss and the amount of convolution computation. 2. The number of classes in the last convolution layer of the mask branch of the Mask R-CNN network is optimized and adjusted to the PigNet class and background class. The structure is shown in Figure 1.  
A PigNet network structure [15] consists of 5 stages and 44 convolution layers. All convolution layers adopt a residual learning structure. Each arc consists of 3 convolution layers, and 1 \(\times\) 1 \(\times\) 64 layers represent convolution layers with a 1 \(\times\) 1 convolution nucleus and 64 channels. The residual learning structure reduces the number of parameters to a great extent, which simplifies the calculation and keeps the spatial position accuracy of the target unchanged. Through the arc part of the network diagram, the residual learning structure transmits the input information directly to the following layers and also partially reduces the feature loss [16]. The residual learning structure can also reduce the sliding step size of each convolution layer from 2 pixels to 1/4 while increasing the number of output channels to 2048. In the structure of the PigNet backbone network, two kinds of feature extraction processes are involved: on the one hand, the network model 4 conv12 convolution layer output map is analyzed and processed through the candidate region network (RPN), and the required feature information is extracted; on the other hand, it propagates forward to generate the feature map. RPN can then quickly select regions of interest. The loss function (\(F\)) of the PigNet network is mainly composed of three parts: classification error (\(F_{s}\)), detection error (\(F_{b}\)), and segmentation error (\(F_{k}\)). The formula is as follows:  
\[F=F_{s}+F_{b}+F_{k} \tag{4}\]In Formula (4), \(F_{8}\) and \(F_{b}\) represent the processing of the fully connected layer that is used to predict the regression box coordinates of the category and the target space for all the areas of interest. \(F_{k}\) represents segmentation and assigns a mask to the target image for each area of interest. To calculate the loss function of region segmentation, only the relative entropy error of the pig class can be taken into account. To avoid competition between classes, the relative entropy error of the pig class is calculated without considering the background class.