n
XXX
′′′
,...,
21
 are regenerated. The regenerated 
particles all come from the original particle set 
n
XXX ,...,
21
, in which the large particles 
generated by the weights generate more new 
particles, and the particles having the smaller 
weights correspond to fewer new particles. 
5)  State transfer 
At the next moment, the particles are updated, 
that is, 
i
X
′
 becomes 
i
X
′′
. Since the probability that 
the state transition from 
i
X
′
 to 
i
X
′′
 can be obtained 
from the state matrix is 
)(
1−kk
xxp
, the probability 
of changing from 
i
X
′
 to 
i
X
′′
 is equal to 
)(
1−kk
xxp
. 
6)  Repeat 2 to 5. 
In the experiment, the number of particles was 
selected as 200. The particle filter algorithm of this 
paper also adopts the method of manually selecting 
the tracking target. First, the initial frame is 
displayed, and a rectangle, that is, the ship feature 
search window containing the ship's target is 
selected by using the selection box, and the ship's 
edge is cut as far as possible, and right-cut. Use the 
[temp,rect]=imcrop(I) format to cut, the image 
matrix of the ship model is saved in the temp 
variable, and then a histogram is calculated for the 
variable; the initial position coordinates of the ship 
are stored in the rect variable for calculation The 
center coordinates of the ship. 
3.3 Error Analysis 
In this paper, the distance between the tracking 
center point and the actual movement center point is 
calculated to calculate the error of comparing the 
two algorithms. The center point of the actual 
movement uses the manual selection method, writes 
a program, selects 9 frames, and determines the 
coordinates of the center point; then uses a 
polynomial fitting method to perform 6 fittings to fit 
the actual motion trajectory; then it calculates the 
two tracks separately. The error between the curve 
and the trajectory is measured by the error and 
variance of the average per frame. The error 
calculation result shows the MATLAB running 
screenshot, as shown in Table 1. 
Table 1 Comparison of tracking errors. 
  Average per frame error (pixels)  Average  gap  between  two 
algorithms per frame (pixels) 
Particle filter method  3.7212  5.7782 
Mean shift method  2.3213 
From the above tracking results, it can be seen 
that both algorithms have jitter in the tracking 
process, but the overall trend is correct, and the 
mean error using the mean shift method is smaller 
than the particle filter method, and the difference 
between the two methods does not exceed 6 pixels. 
3.4 Real-time Analysis 
Use the tic and toc commands to output the total 
running time of the program. The results are shown 
in Table 2. 
Table 2 Runtime Comparison. 
Tracking algorithm  Running time (s) 
Particle filter algorithm  48.151951 
Mean shift algorithm  115.003216 
It can be seen that the operation time of the 
particle filter algorithm is far less than the mean shift 
algorithm, and the real-time performance is better. 
This aspect is the reason for the algorithm, and on 
the other hand, it is the reason for the design of the 
program itself. 
3.5 Effect of Particle Number on Particle 
Filtering Tracking 
Set the number of particles to 100, 200, 500, 1000, 
and 2000, and observe the effect on the program.