Single-Objective Particle Swarm Optimization-Based Chaotic Image Encryption Scheme

: High security has always been the ultimate goal of image encryption, and the closer the ciphertext image is to the true random number, the higher the security. Aiming at popular chaotic image encryption methods, particle swarm optimization (PSO) is studied to select the parameters and initial values of chaotic systems so that the chaotic sequence has higher entropy. Different from the other PSO-based image encryption methods, the proposed method takes the parameters and initial values of the chaotic system as particles instead of encrypted images, which makes it have lower complexity and therefore easier to be applied in real-time scenarios. To validate the optimization framework, this paper designs a new image encryption scheme. The algorithm mainly includes key selection, chaotic sequence preprocessing, block scrambling, expansion, confusion, and diffusion. The key is selected by PSO and brought into the chaotic map, and the generated chaotic sequence is preprocessed. Based on block theory, a new intrablock and interblock scrambling method is designed, which is combined with image expansion to encrypt the image. Subsequently, the confusion and diffusion framework is used as the last step of the encryption process, including row confusion diffusion and column confusion diffusion, which makes security go a step further. Several experimental tests manifest that the scenario has good encryption performance and higher security compared with some popular image encryption methods.


Introduction
Over the years, with the improvement of science and technology and the rapid increase in Internet usage, a great quantity of data has been produced, and data dissemination has increased significantly on various networks. It can be clearly observed that multimedia data, especially digital images, have been increasing sharply. However, the authenticity, integrity and security of these massive amounts of data have become important challenges for users and institutions that process these data. Techniques such as steganography and image encryption are feasible methods to solve the security problem of digital image transmission [1][2][3]. Among all the technical means to provide image security, the encryption scheme is a traditional, efficient, and practical method.
The properties of chaos theory, such as pseudorandomness and sensitivity to the initial value [18][19][20], are consistent with the requirements of cryptography. The initial value sensitivity of the chaotic map corresponds to the key sensitivity required by cryptography. The mixing properties and topology of chaos are consistent with the diffusion and scrambling characteristics in the encryption process. Chaos signals are very suitable for designing image encryption schemes. Many scholars apply chaos theory to the design of encryption and decryption algorithms [21][22][23][24][25]. Therefore, the field has come a long way since chaotic signals were used for image encryption in the last century.
When using chaotic systems for encryption, both one and high-dimensional chaotic systems are available. 1D chaotic maps, such as logistic, sine and tent maps, have simple chaotic orbits and relatively few parameters [26,27]. Zhou et al. [28] created a model capable of generating multiple 1D chaotic maps and enforced secure image encryption. Kumar et al. [29] utilized a 1D logistic map for encryption and used pseudorandom numbers in the encryption process to improve the anti-attack ability. Many scholars have proposed high-dimensional chaotic systems. Hua et al. [30] proposed a 2D chaotic model, which enhanced the nonlinearity and randomness of 2D chaotic sequences. Wang et al. [31] created a 2D-SCLMS system with a larger chaotic range for image encryption. Luo et al. [32] created a novel encryption scenario based on logistic and Baker maps. In addition, various chaotic systems, such as 2D sine logistic modulation map, nonadjacent coupled map lattices, reverse 2-dimensional chaotic map, and Chen system, have been used for the image encryption domain [33][34][35][36][37].
A general chaotic image encryption algorithm usually consists of two main parts: diffusion and confusion. Fridrich proposed a framework of confusion and diffusion for encryption on the basis of chaos theory in 1998 [38]. Under this framework, many image encryption algorithms have been proposed [39,40]. Certainly, to better scramble images, block theory is often used in image encryption methods. Murugan et al. [41] created a chaotic encryption scenario based on confusion and diffusion of chaotic map blocks. Wang et al. [42] used block theory and divided it into two sections: interblock scramble and intrablock scramble. Image expansion is also a process of encryption, which can add random numbers to the image, making the image more resistant to selective plaintext attacks. Zhao et al. [37] also expanded the plaintext image under the framework of confusion and diffusion and achieved good encryption effect.
An optimization-based encryption scenario is also emerging, which optimizes the information attributes of the cipher image by choosing a suitable fitness function to obtain an optimized encryption effect. With the optimization scheme, the correlation coefficient or information entropy (IE) of the ciphertext image approaches the standard number, thereby greatly reducing the amount of useful information embodied in the encrypted image. To achieve the optimal encryption effect, some optimization algorithms, such as PSO, are usually applied to image encryption scenarios. Sabarinath et al. [43] studied an image encryption scenario using an improved PSO algorithm. The method involves Arnold transformation and then uses a key generated from an improved PSO to disrupt the pixel locations in each block of the encrypted image. Musheer et al. [44] created an encryption scenario based on PSO and a logistic map. The optimization objective is to minimize the correlation coefficient of the encrypted image; therefore, the optimal ciphertext image is searched. Wang et al. [45] studied the image encryption scheme based on multi-objective PSO and applied DNA coding and 1D logistic map. The objective function of PSO is the correlation coefficient and information entropy. For the above PSO algorithm for image encryption, named cipher image-based PSO (CIPSO), the statistical characteristics of the ciphertext image are used as the optimization objective to acquire the final ciphertext image in which many rounds of encryption are performed. However, because the PSO is used in every cipher image, encryption algorithms are inevitably iterated many times which makes the algorithm unsuitable for real-time requirements, especially under large data image encryption conditions. Different from the above CIPSO image encryption ideas, a novel framework is proposed to use the population-based particle swarm optimization algorithm in the paper. Because the chaotic performances of chaotic systems only depend on their initial values and systematic parameters, if we acquire the optimized parameters and initial values for one chaotic map, it can be applied to chaotic encryption for any image. In addition, to decrease the complexity of applying the PSO algorithm, in the proposed framework, for the logistic chaotic system, only the information entropy of the sequences generated by the chaotic map is taken as the variable of the optimal objective function. The encryption steps in this paper include chaotic sequence preprocessing, expansion, block scrambling, confusion and diffusion. Our proposed encryption algorithm does not require multiple encryption processes, so it is faster than the CIPSO methods. This allows the chaotic system to have better properties in encrypting images and producing encryption results.
The innovations of the paper are as follows: (1) The optimization framework solves the dependence of chaotic systems on initial values and parameters. The framework can be applied in any chaotic system except the 2D logistic chaotic system. (2) A novel encryption method is proposed, especially the intra block scrambling process, which is a novel scrambling method.
This paper also has certain shortcomings. For example, the correlation between the encryption scheme and the plaintext image is not close, and it cannot achieve a good ability to resist differential attacks. This requires us to strengthen the algorithm's ability to resist differential attacks in future research.
The contents of the remaining sections are arranged as follows. Section 2 introduces the related work used in the encryption process, including the chaotic system, image scrambling methods and image expansion method. Section 3 designs the PSO scheme and the process of finding the optimized solution. Section 4 demonstrates the novel encryption scenario. Section 5 describes the corresponding decryption process. Section 6 presents the simulation results and security analysis of the encryption scenario, which can prove the usability of the newly proposed algorithm. Section 7 gives the discussion results of the paper. Section 8 is the conclusion.

Related Work
In this section, we briefly introduce the chaotic map and related encryption methods that will be used in the new encryption scheme.

Block Scrambling
This paper applies block theory to scramble images, which aims to make the lower correlation between adjacent pixels and strong robustness resist statistical attacks. This consists of two portions. Specifically, intrablock scrambling traverses the pixel matrix in squares to reduce the correlation between pixels; interblock scrambling performs block exchange according to the chaotic sequence. To improve performance, the number of image blocks designed is 16. Sixteen subblocks of equal size are divided by the image in the experiment. One of the chaotic sequences determines the interblock scrambling method. Then, the chaotic sequence is converted to a positive integer sequence, and interblock scrambling is applied to the image blocks according to the rules of ordering. An example of a 3 × 3 matrix is presented in Figure 1. Sixteen subblocks of equal size are divided by the image in the experiment. One of the chaotic sequences determines the interblock scrambling method. Then, the chaotic sequence is converted to a positive integer sequence, and interblock scrambling is applied to the image blocks according to the rules of ordering. An example of a 3 × 3 matrix is presented in Figure 1.

Intrablock Scrambling
Intrablock scrambling realizes the messing of pixels in each block. This scrambling method traverses each pixel from the inside to the outside by drawing a square. First, the pixel values are extracted starting in the middle of the image subblock, and after one round of drawing, the number of rows and columns are reduced by one. Then, a new round of square drawing is started until the end of each pixel value of the traversal subblock. Each obtained pixel value is sequentially stored in a 1D sequence and finally converted into a 2D pixel block matrix of the same size as the subblock. For example, this paper uses a 4 × 4 matrix to explain the method in Figure 2.

Image Expansion
Image expansion adds random numbers to the image matrix to ensure that different ciphertext images can be obtained by encrypting the image twice under the same key value, which increases the algorithm's resistance to selective plaintext attacks. Specifically, this is explained as follows:

Intrablock Scrambling
Intrablock scrambling realizes the messing of pixels in each block. This scrambling method traverses each pixel from the inside to the outside by drawing a square. First, the pixel values are extracted starting in the middle of the image subblock, and after one round of drawing, the number of rows and columns are reduced by one. Then, a new round of square drawing is started until the end of each pixel value of the traversal subblock. Each obtained pixel value is sequentially stored in a 1D sequence and finally converted into a 2D pixel block matrix of the same size as the subblock. For example, this paper uses a 4 × 4 matrix to explain the method in Figure 2. Sixteen subblocks of equal size are divided by the image in the experiment. One of the chaotic sequences determines the interblock scrambling method. Then, the chaotic sequence is converted to a positive integer sequence, and interblock scrambling is applied to the image blocks according to the rules of ordering. An example of a 3 × 3 matrix is presented in Figure 1.

Intrablock Scrambling
Intrablock scrambling realizes the messing of pixels in each block. This scrambling method traverses each pixel from the inside to the outside by drawing a square. First, the pixel values are extracted starting in the middle of the image subblock, and after one round of drawing, the number of rows and columns are reduced by one. Then, a new round of square drawing is started until the end of each pixel value of the traversal subblock. Each obtained pixel value is sequentially stored in a 1D sequence and finally converted into a 2D pixel block matrix of the same size as the subblock. For example, this paper uses a 4 × 4 matrix to explain the method in Figure 2.

Image Expansion
Image expansion adds random numbers to the image matrix to ensure that different ciphertext images can be obtained by encrypting the image twice under the same key value, which increases the algorithm's resistance to selective plaintext attacks. Specifically, this is explained as follows:

Image Expansion
Image expansion adds random numbers to the image matrix to ensure that different ciphertext images can be obtained by encrypting the image twice under the same key value, which increases the algorithm's resistance to selective plaintext attacks. Specifically, this is explained as follows: (1) Generate two random matrices R 0 and R 1 , where the sizes of R 0 and R 1 are 4 × (N + 4) and M × 4, respectively. (2) Add the first two columns of R 1 to the leftmost side of the original image and add the last two columns of R 1 to the rightmost part of the original image.
(3) The first two lines of R 0 are added to the top line of the changed image, and the last two lines of R 0 are added to the bottom line of the changed image.
Therefore, the image expansion is completed, and the expanded image size is (M + 4) × (N + 4). Take the matrix 4 × 4 as an example in Figure 3. (1) Generate two random matrices R0 and R1, where the sizes of R0 and R1 are 4 × (N + 4) and M × 4, respectively.
(2) Add the first two columns of R1 to the leftmost side of the original image and add the last two columns of R1 to the rightmost part of the original image.
(3) The first two lines of R0 are added to the top line of the changed image, and the last two lines of R0 are added to the bottom line of the changed image.
Therefore, the image expansion is completed, and the expanded image size is (M + 4) × (N + 4). Take the matrix 4 × 4 as an example in Figure 3.

PSO
PSO was created by Eberhart and Kennedy in 1995 [46,47]. PSO is a population-based optimization technique that is an optimization algorithm for population intelligence in the field of computer intelligence [48]. Suppose a flock of birds forage randomly in a large field. How then to explain, no birds know where the food is in the field, but they only know the distance from the food. One of the most effective ways to find food is to hang out with the birds that are closest to the food site. PSO has the advantages of intuitive process, simplicity and easy realization. It is applied in many fields, for example, function optimization, signal processing, neural networks and so on. The specific operation of the algorithm is described.
The PSO algorithm first needs to initialize a group of particles R = {x1, x2, …, xN} in the feasible solution space s, where the number of particles is assumed to be N and the objective function f is established. Each particle corresponds to an objective function f(xi) and iterates by updating the velocity vi(t) and position xi(t) of the particle. During the iteration, the individual extremum Pbest and the group extremum Gbest of the particle are recorded to find the particle that can make the objective function f(x) reach the best.

PSO
PSO was created by Eberhart and Kennedy in 1995 [46,47]. PSO is a population-based optimization technique that is an optimization algorithm for population intelligence in the field of computer intelligence [48]. Suppose a flock of birds forage randomly in a large field. How then to explain, no birds know where the food is in the field, but they only know the distance from the food. One of the most effective ways to find food is to hang out with the birds that are closest to the food site. PSO has the advantages of intuitive process, simplicity and easy realization. It is applied in many fields, for example, function optimization, signal processing, neural networks and so on. The specific operation of the algorithm is described.
The PSO algorithm first needs to initialize a group of particles R = {x 1 , x 2 , . . . , x N } in the feasible solution space s, where the number of particles is assumed to be N and the objective function f is established. Each particle corresponds to an objective function f (x i ) and iterates by updating the velocity v i (t) and position x i (t) of the particle. During the iteration, the individual extremum Pbest and the group extremum Gbest of the particle are recorded to find the particle that can make the objective function f (x) reach the best.
Particles have only two attributes: velocity v i (t) and position x i (t). v i (t) represents the speed of movement and x i (t) represents the direction of movement. The expressions for the update iteration of particle velocity v i (t) and position where ω is the inertia weight. r 1 , r 2 ∈ [0, 1] are random vectors. c 1 and c 2 are constants. Normally, there are certain restrictions on the velocity and position used for iterative updates, such as velocity and position within the interval [V min , V max ], [X min , X max ], respectively.

The Newly Proposed Parameter Selection of the Chaotic Map Algorithm
The PSO scheme is used to find the optimized parameter values of the 2D logistic map. Therefore, we must determine the optimization objective of PSO algorithm.
IE is an efficient quota to appraise the randomness of sequences, which is expected to produce a better image encryption effect when the chaotic sequence used in image encryption has a higher IE. Therefore, IE is an appropriate objective function for optimization problems. The optimization scheme is introduced in detail below.
The gray value of the image is generally an integer between [0, 255], and the chaotic sequences are used for image confusion and diffusion after preprocessing. To finally make the pixels of the obtained cipher image still in the range of [0, 255], the chaotic sequences {x n }, {y n } generated by Equation (1) are transformed into sequences of integers in the interval [0, 255] according to Equation (3).
Entropy is a quantification method of the average amount of information possessed by the information source, which can be used to assess the degree of disorder of the map. For the information source, the expression is Equation (4).
where M is the number of signals. Herein, M = 255. s i ∈ s, p is the probability. The IE of a true random source is 8 [49]. The 2D logistic map generates two sequences, each of which has its corresponding entropy, in this case two objective functions. To facilitate the calculation, a simple method is introduced to establish an overall objective function f (x) [50], which is represented as where α and β are constants that represent the weights of the two subobjective functions f 1 (x) and f 2 (x). The two subobjective functions in this paper are equally important for the overall objective function, namely, α = β = 0.5. The specific expression of the overall objective function is shown in Equation (6).
where α 1 and α 2 are constants representing the weights of the two parts. α 1 = α 2 = 0.5. In the PSO algorithm, the initial particle population and the initial velocity are chosen randomly. Because the 2D logistic map has two initial values x 0 and y 0 and four initial parameters µ 1 , µ 2 , λ 1 , and λ 2 , the dimensionality of each particle is six dimensions, among x 0 ∈ (0, 1), y 0 ∈ (0, 1), µ 1 ∈ (2.75, 3.4], µ 2 ∈ (2.75, 3.45], λ 1 ∈ (0.15, 0.21] and λ 2 ∈ (0.13, 0.15]. The velocity and position of each particle are iterated, and the particle corresponding to the overall objective function generated is the optimized initial values and parameters sought. The initial particle swarm and initial velocity are randomly selected, so the optimized initial values and parameters generated by the PSO algorithm are different each time in Algorithm 1.

Algorithm 1 PSO framework
Input: 2D Logistic map, initial values x 0 , y 0 , initial parameters µ 1 , µ 2 , λ 1 , λ 2 , initial dimensions, number of particles, velocity, position, and iterations t, and maximum iterations T. Output: optimized particle 1: for each iteration 2: for each particle 3: for each dimension 4: Iterative 2D Logistic map according to Equation (1)  5: Calculate the entropy of the sequence {x n } according to Equations (3) and (4)  6: Calculate the entropy of the sequence {y n } according to Equations (3) and (4)  7: Calculate the overall objective function f (x) according to Equation (6)  8: if f (x) > Gbest_val 9: The particle corresponding to the overall objective function is the current optimized particle 10: end 11: if t < T 12: Update the speed v i according to Equation (2)  13: Update the position x i according to Equation (2)  14: if x i exceeds the value range of the chaotic system 15: x i = x i−1 16: end 17: end 18: Repeat steps 4 through 17 until the iteration is complete 19: The global optimum is the optimized particle 20: end 21: end 22: end Note: The process of particle swarm iteration (steps 14-16) limits the range of particles, i.e., the range of motion of particles cannot exceed the parameter range required by the chaotic map.

Image Encryption
The image encryption process mainly includes key selection, chaotic sequence preprocessing, block scrambling, expansion, confusion and diffusion. The detailed explanation is: PSO is utilized to select the optimized key for encryption. Chaotic sequence preprocessing makes the sequence more random. Block scrambling is divided into intra block and inter block scrambling, which reduces the correlation and provides better protection against statistical attacks. The expansion step adds random numbers to the original image so that each encryption obtains a different ciphertext image, which can better resist selective plaintext attacks. Confusion and diffusion complicate the relationship between ciphertext and keys, making it difficult for an adversary to decrypt from a ciphertext image, which further enhances the resistance of the scenario. The encryption flowchart drawn according to the above description is shown in Figure 4.

Key Selection
The optimized values x0, y0, μ1, μ2, λ1 and λ2 generated by the PSO algorithm are used as the keys for the 2D logistic map. To avoid transient effects, the first two hundred points are discarded, and Equation (1)

Key Selection
The optimized values x 0 , y 0 , µ 1 , µ 2 , λ 1 and λ 2 generated by the PSO algorithm are used as the keys for the 2D logistic map. To avoid transient effects, the first two hundred points are discarded, and Equation (1) is used to generate two chaotic sequences {x n }, {y n }, which are of length MN.

Chaotic Sequence Preprocessing
The two chaotic sequences {x n }, {y n } are preprocessed according to Equation (7).

Image Scrambling
(1) The 16 subblocks B(i), i = 1,2, . . . ,16 of the same size are divided by the original image P 1 , and the last 16 numbers of the sequence x(i) are taken to compose a sequence D(i). Then, it is transformed into an integer sequence S(i). The obtained integer sequence S(i) is sorted, and interblock scrambling is achieved according to Equation (8).

Image Expansion
Two random matrices R 0 and R 1 are generated, where the sizes of R 0 and R 1 are 4 × (N + 4) and M × 4, respectively. Expand image P 2 according to the method shown in Section 2.3 to form an expanded image P 3 .

Confusion and Diffusion of Row
First, calculate the new row index r(i) = ceil (x 1 (i) × (M + 4)) using x 1 (i), and then compare row i with row indexes r(i).
Second, the parameter k 11 , k 12 is calculated using x 1 (i). Third, perform a bitwise XOR operation on the expansion image P 3 with parameter k 11 , k 12 .
Fifth, the first and last columns of P 31 are calculated to obtain P 4 .
Sixth, the other columns of P 31 and P 4 are calculated.

Confusion and Diffusion of the Column
The confusion and diffusion of columns are similar to the rows', except that sequence y 1 (i) is used instead of sequence x 1 (i). The specific calculation procedure is presented in Algorithm 2.

Image Decryption
Decryption is the process of decrypting the ciphertext image according to the reverse step of the encryption process. From the encryption algorithm in Section 4, we get that the decryption steps are the inverse of confusion and diffusion, expansion, and block scrambling. The decryption key is the encryption key, so the decrypted image can be obtained correctly. The decryption flowchart corresponding to the encryption flowchart is shown in Figure 5.

Image Decryption
Decryption is the process of decrypting the ciphertext image according to the reverse step of the encryption process. From the encryption algorithm in Section 4, we get that the decryption steps are the inverse of confusion and diffusion, expansion, and block scrambling. The decryption key is the encryption key, so the decrypted image can be obtained correctly. The decryption flowchart corresponding to the encryption flowchart is shown in Figure 5. Step 1: The two optimized initial values x0 and y0 and four optimized system parameters μ1, μ2, λ1 and λ2 generated by the PSO algorithm are used as the security keys of the 2D logistic map, and the sequence {xn}, {yn} is generated by iterative Equation (1).
Step 2: The random sequence {xn}, {yn} generated by the 2D logistic map can obtain the preprocessed sequences x1(i) and y1(i) according to Equation (7). Image P4 is acquired by executing the reverse operation of confusion and diffusion of the column on encrypted image P5 according to sequence y1(i).
Step 3: Image P3 is acquired by executing the reverse operation of confusion and diffusion of the row on image P4 according to sequence x1(i).
Step 4: Delete the first two lines and the last two lines of image P3 in turn and then delete the first two columns and the last two columns to obtain image P2. Step 1: The two optimized initial values x 0 and y 0 and four optimized system parameters µ 1 , µ 2 , λ 1 and λ 2 generated by the PSO algorithm are used as the security keys of the 2D logistic map, and the sequence {x n }, {y n } is generated by iterative Equation (1).
Step 2: The random sequence {x n }, {y n } generated by the 2D logistic map can obtain the preprocessed sequences x 1 (i) and y 1 (i) according to Equation (7). Image P 4 is acquired by executing the reverse operation of confusion and diffusion of the column on encrypted image P 5 according to sequence y 1 (i).
Step 3: Image P 3 is acquired by executing the reverse operation of confusion and diffusion of the row on image P 4 according to sequence x 1 (i).
Step 4: Delete the first two lines and the last two lines of image P 3 in turn and then delete the first two columns and the last two columns to obtain image P 2 .
Step 5: Image P 2 is partitioned into 16 subblocks of the same size. The sequence t is calculated according to Equation (9), and the inverse of the block-internal scrambling is executed for each subblock.
Step 6: According to the sequence S(i), the inverse of the interblock operation is performed on each subblock, and then the 16 subblocks are combined to obtain the plain image P 1 .

Experimental Environment
In order to simulate the encryption scheme and verify the performance of the algorithm, all experiments are conducted on a PC with AMD Ryzen 2.00 GHz CPU, 8 G RAM, and 1 TB hard disk with Window 10 Ultimate system. This experiment is operated by MATLAB R2020a software.

Simulation Results
To verify the effect of encryption, the simulation experiments are presented in Figure 6. It presents the plain, ciphertext and corresponding decrypted images of "Lena", "Cameraman", "7.1.02" and "Boat" respectively. All the ciphertext images resemble noise images, and no information can be obtained, which demonstrates that the encryption achieves good results, and all the encrypted images can achieve correct decryption. rithm, all experiments are conducted on a PC with AMD Ryzen 2.00 GHz CPU, 8 G RAM, and 1 TB hard disk with Window 10 Ultimate system. This experiment is operated by MATLAB R2020a software.

Simulation Results
To verify the effect of encryption, the simulation experiments are presented in Figure  6. It presents the plain, ciphertext and corresponding decrypted images of "Lena", "Cameraman", "7.1.02" and "Boat" respectively. All the ciphertext images resemble noise images, and no information can be obtained, which demonstrates that the encryption achieves good results, and all the encrypted images can achieve correct decryption.

Running Time
To demonstrate the utility of the scenario, the running time is presented in Table 1. The running time is acceptable, which demonstrates that the scheme is practical.

Key Space Analysis
The PSO algorithm generates optimized initial values x0 and y0 and parameters μ1, μ2, λ1 and λ2. Therefore, x0, y0, μ1, μ2, λ1, and λ2 are both keys. It is presumed that the calculation accuracy is 10 −14 , and the total key space 10 14×6 = 10 84 ≫ 2 100 ; that is, it is sufficiently large, which offers strong resistance to violent attacks.

Running Time
To demonstrate the utility of the scenario, the running time is presented in Table 1. The running time is acceptable, which demonstrates that the scheme is practical.

Key Sensitivity Analysis
The more sensitive the scheme is to the key value, the better and more secure the algorithm is. Figure 7 takes the "Lena" as an example for illustration. When any key changes by 10 −14 , the decrypted image resembles noise, which demonstrates that the scheme is key sensitive.

Key Space Analysis
The PSO algorithm generates optimized initial values x0 and y0 and parameters μ1, μ2, λ1 and λ2. Therefore, x0, y0, μ1, μ2, λ1, and λ2 are both keys. It is presumed that the calculation accuracy is 10 −14 , and the total key space 10 14×6 = 10 84 ≫ 2 100 ; that is, it is sufficiently large, which offers strong resistance to violent attacks.

Key Sensitivity Analysis
The more sensitive the scheme is to the key value, the better and more secure the algorithm is. Figure 7 takes the "Lena" as an example for illustration. When any key changes by 10 −14 , the decrypted image resembles noise, which demonstrates that the scheme is key sensitive.  To test the sensitivity of the scheme to the key, the unified average change intensity (UACI) and the number of pixel change rate (NPCR) are adopted [51], and their expressions are where C 1 and C 2 are two different ciphertext images. When the NPCR > NPCR* α , the NPCR passes the test. When the UACI is between [UACI* − α , UACI* + α ], the UACI passes the test [52]. NPCR and UACI statistical tests on key sensitivity are shown in Tables 2 and 3.  The histogram indicates the pixel value distribution [53]. The more uniform the histogram of the ciphertext image, the less image information is displayed. Figure 8 presents the histogram of the original and cipher images of "Lena" and "Boat". The histograms of the ciphertext images are similarly uniformly distributed, indicating that the scenario is very good.  The histogram indicates the pixel value distribution [53]. The more uniform the histogram of the ciphertext image, the less image information is displayed. Figure 8 presents the histogram of the original and cipher images of "Lena" and "Boat". The histograms of the ciphertext images are similarly uniformly distributed, indicating that the scenario is very good.

Chi-Square Analysis
Chi-square is a quantitative indicator that can be utilized to appraise the ability of an algorithm to resist statistical attacks. Its expression is where υi is the frequency occupied by i. υ0 = MN/256. The chi-square value of all test images is enumerated in Table 4. The chi-square of the original image is larger, while the chisquare of the encrypted image is lower than 293.2478 [54], which indicates that the scheme can resist statistical attacks.

Chi-Square Analysis
Chi-square is a quantitative indicator that can be utilized to appraise the ability of an algorithm to resist statistical attacks. Its expression is where υ i is the frequency occupied by i. υ 0 = MN/256. The chi-square value of all test images is enumerated in Table 4. The chi-square of the original image is larger, while the chi-square of the encrypted image is lower than 293.2478 [54], which indicates that the scheme can resist statistical attacks. The correlation between adjacent pixels of the ciphertext image is smaller, and the more resistant it is to statistical analysis attacks. The correlation coefficients [55] are calculated by Equation (18).
where x and y express the adjacent pixel values of the image and ρ xy represents the correlation coefficient.
In this paper, we select 10,000 pairs of adjacent pixels in the horizontal (H), vertical (V) and diagonal (D) directions for the original and encrypted images of "Lena". The plaintext image is close to the diagonal direction in all three directions, while the points in all directions of the ciphertext image are randomly distributed throughout the data range in Figure 9, which demonstrates that the scheme greatly reduces the original image correlation. The correlation coefficients of all original images are close to 1, while the encrypted images are close to 0 in Table 5, indicating that the scheme is good and can effectively resist statistical attacks.   The correlation coefficients of all original images are close to 1, while the encrypted images are close to 0 in Table 5, indicating that the scheme is good and can effectively resist statistical attacks. The IE expresses the degree of random distribution of an image and is often called Shannon entropy, which is expressed as Equation (4). A higher IE indicates a more random image pixel distribution. The IE of the test image is presented in Table 6. The IE of the ciphertext images of the new scenario is closer to 8 and outperforms the values of other algorithms, which demonstrates that the scenario is better. LIE can represent the randomness of local images. To accurately evaluate the randomness of the local image in the ciphertext image, the LIE is used.
In Equation (19), k is randomly selected for the number of subimages after image segmentation. T B randomly selects the number of pixels in the subimage. S expresses the encrypted image. H(S i ) expresses the IE of S i . Specifically, we choose k = 30 and T B = 1936. When the confidence interval is 0.001, the LIE belongs to the interval (7.901901305, 7.903037329) [56]. We take these four images as examples in Table 7. Four images passed the test, which explains why the randomness of the local image is good.

Cropping Attack
To evaluate the anti-interference capability of the encryption scenario under a cropping attack. Cropping attacks of different strengths are used on the encrypted images. A cropping attack is performed by setting a portion of the pixel block value of the encrypted image to 0 and decrypting it. The decrypted images under different cropping strengths are shown in Figure 10. The new encryption scenario can recover the encrypted image to a certain extent from clipping attacks, which demonstrates that the scenario is robust and resistant to cropping attacks.
In Equation (19), k is randomly selected for the number of subimages after image segmentation. TB randomly selects the number of pixels in the subimage. S expresses the encrypted image. H(Si) expresses the IE of Si. Specifically, we choose k = 30 and TB = 1936. When the confidence interval is 0.001, the LIE belongs to the interval (7.901901305, 7.903037329) [56]. We take these four images as examples in Table 7. Four images passed the test, which explains why the randomness of the local image is good. To evaluate the anti-interference capability of the encryption scenario under a cropping attack. Cropping attacks of different strengths are used on the encrypted images. A cropping attack is performed by setting a portion of the pixel block value of the encrypted image to 0 and decrypting it. The decrypted images under different cropping strengths are shown in Figure 10. The new encryption scenario can recover the encrypted image to a certain extent from clipping attacks, which demonstrates that the scenario is robust and resistant to cropping attacks.

Noise Attack
Images are affected by various noises during transmission over the Internet, which have an impact on decrypted images. To qualitatively test the resistance in noisy environments, we add different strengths of salt and pepper noise (SPN) to the encrypted images. The noise strength is set to 0.005, 0.01 and 0.05 in order. The results of the noise resistance test of the encryption algorithm are presented in Figure 11. Some content of the original image can still be seen from the decrypted image after adding different strengths of noise to the ciphertext image. This indicates that the new scenario can resist noise attacks of a certain strength. Thus, the scenario is secure and resistant to noise attacks.

Noise Attack
Images are affected by various noises during transmission over the Internet, which have an impact on decrypted images. To qualitatively test the resistance in noisy environments, we add different strengths of salt and pepper noise (SPN) to the encrypted images. The noise strength is set to 0.005, 0.01 and 0.05 in order. The results of the noise resistance test of the encryption algorithm are presented in Figure 11. Some content of the original image can still be seen from the decrypted image after adding different strengths of noise to the ciphertext image. This indicates that the new scenario can resist noise attacks of a certain strength. Thus, the scenario is secure and resistant to noise attacks.

The Influence of the PSO Algorithm on Image Encryption
The objective function of PSO is composed of the information entropy of two chaotic sequences. To better explain the impact of the optimized initial values and parameters obtained by PSO on image encryption, we stochastically choose two different sets of initial values and parameters, denoted as value 1 and value 2. Different indicators of "Lena" are compared in Table 8. The indicators under the optimized initial values and parameters are better than others. This shows that a chaotic map is conducive to image encryption to achieve better results under the optimized initial values and parameters acquired by the PSO algorithm.

The Influence of the PSO Algorithm on Image Encryption
The objective function of PSO is composed of the information entropy of two chaotic sequences. To better explain the impact of the optimized initial values and parameters obtained by PSO on image encryption, we stochastically choose two different sets of initial values and parameters, denoted as value 1 and value 2. Different indicators of "Lena" are compared in Table 8. The indicators under the optimized initial values and parameters are better than others. This shows that a chaotic map is conducive to image encryption to achieve better results under the optimized initial values and parameters acquired by the PSO algorithm.

Discussion
The chaotic image encryption scheme based on PSO algorithm proposed in this paper can resist various attacks, in addition to demonstrating security and timeliness. However, it also has certain limitations. Since the optimized initial value and parameters of the chaotic map are generated by the PSO algorithm, the key has no correlation with the plaintext image, so that the encryption result will not change greatly due to the change of the pixels in the plaintext image. This requires us to improve the relevance of the algorithm to plaintext images in future research.

Conclusions
The PSO framework is proposed to seek the optimized initial values and optimized parameters of chaotic systems and is then used for encryption by a special chaotic map. The objective function of PSO is composed of the IE of the chaotic sequences. The optimized initial values and parameters can make the chaotic sequences more similar to the random sequence, which is beneficial to the encryption to achieve better results. In the process of encryption, the methods of scrambling, expansion, confusion and diffusion are used in this paper. In the scrambling process, different block scrambling methods are adopted in this paper, which immensely decreases the correlation of the ciphertext image and improves the ability of the image to resist statistical attack analysis. For the confusion and diffusion framework, this paper adopts operations on rows and columns, respectively, which further improves the resistance of the scenario. The simulation analysis of the new scenario shows that the scheme achieves good results in image encryption, especially the maximum IE is 7.9994, which is closer to 8 compared with other scenarios. In addition, the scenario also has the ability to resist various attacks, and the key sensitivity is extremely high. The UACI and NPCR of the sensitivity test are only slightly different from the standard value. All tests demonstrate that the security of the new scenario has been significantly improved.
In the future, we intend to further explore the optimization scenario of image encryption to achieve a better encryption effect. In addition, we should further study the encryption scheme of images so that encryption may see a greater breakthrough in terms of security and practicability.

Conflicts of Interest:
The authors declare that they have no known competing financial interests or personal relationships that could have appeared to influence the work reported in this paper.