## 2 Methods
### Phase Mask Design Based on Improved Particle Swarm Optimization  
If the range of velocity is too high, particles might fly past good solutions. If the value range of velocity is too small, particles may not explore sufficiently beyond locally good regions [15]. In brief, an inappropriate range of velocity is the factor that causes PSO to fall into a locally optimal solution. It is necessary to repeatedly test different velocity ranges to obtain the ideal optimal solution, which will greatly reduce the optimization efficiency of the algorithm.  
In order to improve the optimization efficiency of the algorithm, this paper cancels the setting of the velocity range in PSO and introduces the threshold T of Equation (4).  
The cubic phase mask parameter is limited by the threshold T in the optimization process. This measure can effectively prevent PSO from falling into the local optimal solution and ensure the quality of image restoration.  
Combined with the characteristics of PSO and the cubic phase mask optimization problem, the phase mask optimization algorithm flow based on improved PSO is shown in Figure 1.  
As shown in Figure 1, the specific process of the algorithm is as follows:  
Assign the population of particles \(D\) and the number of iterations \(I\).  
Initialize the initial position \(A\) of particles and the corresponding fitness \(S\). The initial \(\alpha_{d}\) is assigned to a random number, and the initial \(\alpha_{d}\) must satisfy Equation (4). Otherwise, the initial \(\alpha_{d}\) needs to be reinitialized until it satisfies Equation (4). \(s(\alpha_{d})\), the fitness of \(\alpha_{d}\), is computed by Equation (3).  
Initialize the initial velocity \(V\) of particles. The initial \(v_{d}\) is assigned to a random number. Initialize the initial local optimal solution \(A^{\rm local}\) of particles and the corresponding local optimal fitness \(S^{\rm local}\). Before the algorithm iteration begins, the local optimal solution \(\alpha_{d}^{\rm local}\) is equal to the initial \(\alpha_{d}\) of step 2. Therefore, \(A^{\rm local}=A\) and \(S^{\rm local}=S\).  
Initialize the initial global optimal solution \(\alpha^{\rm global}\) of particles and the corresponding global optimal fitness \(s(\alpha^{\rm local})\). The initial global optimal solution \(\alpha^{\rm global}\) is equal to \(\alpha_{d}^{\rm local}\), which corresponds to the minimum initial fitness \(s(\alpha_{d})\). The global optimal fitness \(s(\alpha^{\rm global})\) is equal to the minimum initial fitness \(s(\alpha_{d})\).  
For each iteration, Equations (5) and (6) are used to update \(\alpha_{d}\) and \(v_{d}\), and then threshold T is used to evaluate whether \(\alpha_{d}\) is reasonable. Take the location \(\alpha_{d}\) of the \(d\)th particle as an example. \(\alpha_{d}\) should not be less than zero, and it should satisfy Equation (4). If \(\alpha_{d}<0\), then \(\alpha_{d}=0\). If \(\alpha_{d}\) does not satisfy Equation (4), this \(\alpha_{d}\) remains unchanged until it is updated next time using Equations (5) and (6).  
Update the local optimal solution \(\alpha_{d}^{\rm local}\) and the corresponding local optimal fitness \(s(\alpha_{d}^{\rm local})\). Replace \(\alpha_{d}^{\rm local}\) with \(\alpha_{d}\) only if \(s(\alpha_{d})\) of the current iteration number is less than the previous one \(s(\alpha_{d}^{\rm local})\). Meanwhile, the arrays of \(A^{\rm local}\) and \(\alpha_{d}^{\rm local}\) will be updated.  
Figure 1: Flow diagram of phase mask design based on improved PSO.  
Update the global optimal \(\alpha^{\text{global}}\) and the global optimal fitness \(s(\alpha^{\text{global}})\). Replace \(\alpha^{\text{global}}\) and \(s(\alpha^{\text{global}})\) with \(\alpha^{\text{local}}_{d}\) and \(s(\alpha^{\text{local}}_{d})\), respectively, only if the current \(s(\alpha^{\text{local}}_{d})\) is less than the previous \(s(\alpha^{\text{global}})\).  
The global optimum cubic parameter \(\alpha^{\text{global}}\) will be obtained after \(I\) iterations.