2.1. Theoretical Analysis of Wavefront Coding Systems
The DoF in object space corresponds to the depth of focus in image space. Consequently, a wavefront coding system that extends DoF in the object space is insensitive to the defocus in the image space. A cubic phase mask is a classic example applied in wavefront coding systems to extend the DoF. The one-dimensional cubic phase mask
is analyzed as an example for simplicity, which can be described as
where
, in the range of −1 to 1, is the coordinate of the phase mask and
is the cubic parameter of the phase mask. The pupil function, which ignores all optical aberrations but defocus, can be described as
where
is the defocus aberration and
is the imaginary unit. The modulation transfer function (MTF), an image quality evaluation method, is used to evaluate the defocus insensitivity [
9] of wavefront coding systems. MTF curves with different defocus aberrations will be coincident if the wavefront coding system is ideally defocus-insensitive. Consequently, the coincidence of MTF curves with different defocus aberrations is used as a merit function to evaluate the defocus insensitivity of the system.
where
is the spatial frequency and
is zero. However, wavefront coding systems suffer from a trade-off between defocus insensitivity and imaging quality [
10]. To ensure imaging quality, the system should satisfy
where the threshold
is 0.15 in this study [
11].
2.2. Theoretical Analysis of PSO
Particle swarm optimization (PSO) [
7,
8] was proposed as a nonlinear optimization algorithm. With the rapid development of artificial intelligence and deep learning, PSO has a wide range of applications in many fields, such as the design of semiconductor lasers [
12], intelligence-bearing fault diagnosis [
13], and water quality monitoring [
14].
PSO was applied to optimize the cubic phase mask of the wavefront coding system in this study. In this article, PSO is based on the standard “GBEST” version, which is the original form of PSO. The population of particles
is the sum of particles. The parameter of cubic phase mask parameter in Equation (1) is denoted as
, representing the position of the
th particle in the particles. Then, the position of the current particles can be denoted as an array
Array is updated with each iteration. denotes the number of iterations in PSO. is the best location obtained so far by any particle in the population.
The fitness
, the distance between the desired solution and the
th particle, is the coincidence consistency of the MTF curves in Equation (3). Ideally,
is equal to zero when the
th particle is the desired solution. Equation (4) is the constraint on the solution space. The fitness of the current particles can be denoted as array
Velocity is an important parameter of PSO.
is described as the
th particle velocity. The velocity represents the particle’s ability to explore the solution space. The velocity of the current particles can be denoted as array
The local optimal solution
is the best location of the
th particle so far. The local optimal solution of the current particles can be denoted as the array
In a similar way, the local optimal fitness of the current particles can be denoted as the array
The global optimal fitness is .
The locations and velocities are related to the experience, which is determined by the locations and velocities of all particles before their last move. They are updated after each iteration by these formulas [
7,
15]:
where
is a function of generating a random number between 0 and 1, setting the acceleration constants
and
[
7,
15].
2.3. 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 of Equation (4).
The cubic phase mask parameter is limited by the threshold 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 and the number of iterations .
Initialize the initial position of particles and the corresponding fitness . The initial is assigned to a random number, and the initial must satisfy Equation (4). Otherwise, the initial needs to be reinitialized until it satisfies Equation (4). , the fitness of , is computed by Equation (3).
Initialize the initial velocity of particles. The initial is assigned to a random number.
Initialize the initial local optimal solution of particles and the corresponding local optimal fitness . Before the algorithm iteration begins, the local optimal solution is equal to the initial of step 2. Therefore, and .
Initialize the initial global optimal solution of particles and the corresponding global optimal fitness . The initial global optimal solution is equal to , which corresponds to the minimum initial fitness . The global optimal fitness is equal to the minimum initial fitness .
For each iteration, Equations (5) and (6) are used to update and , and then threshold is used to evaluate whether is reasonable. Take the location of the th particle as an example. should not be less than zero, and it should satisfy Equation (4). If , then . If does not satisfy Equation (4), this remains unchanged until it is updated next time using Equations (5) and (6).
Update the local optimal solution and the corresponding local optimal fitness . Replace with only if of the current iteration number is less than the previous one . Meanwhile, the arrays of and will be updated.
Update the global optimal and the global optimal fitness . Replace and with and , respectively, only if the current is less than the previous .
The global optimum cubic parameter will be obtained after iterations.