A Real-Time Image Encryption Method of Networked Inverted Pendulum Visual Servo Control System

In the real-time control of networked inverted pendulum visual servo control system (NIPVSCS), how to achieve safe and efficient image transmission is an important and challenging problem. Generally, the inverted pendulum images are directly transmitted via the network, while these images are not secure because they may be attacked by the hacker. To solve the problem, a fast image encryption method by combining image scaling and improved self-diffusion image encryption (ISDIE) algorithm is firstly proposed, which is employed to encrypt the captured images after they are scaled. +e security performance of the proposed algorithm, the characteristics of different delays, and the control performance of the NIPVSCS are then analyzed. Finally, simulation and real-time control experiments confirm the feasibility and effectiveness of the proposed method.


Introduction
Networked inverted pendulum system is a typical experimental platform to verify control theory and algorithms in the automatic control field [1][2][3][4]. In the recent years, with the rapid development of visual technique, visual sensors (e.g., the industrial camera) are gradually integrated into industrial control systems for detection and control [5][6][7][8].
To provide theoretical and technical support for visual servo real-time control, networked inverted pendulum visual servo control system (NIPVSCS) has been constructed and real-time H ∞ control method has also been proposed [9]. e network brings convenience to the transmission of visual images; however, these images also face various cyber attacks. In the NIPVSCSs, there exist not only the attacks on visual images but also the attacks on nonvision information. Here, this paper focuses on the security of the images because the attack on the image will reduce the image reliability (i.e., integrity and authenticity) and then cause the inaccurate and incomplete state and control information [9,10], leading to system performance degradation or even instability.
To improve the security of the image, the image encryption provides a possible path. However, unlike the nonreal-time image encryption (e.g., the image encryption algorithms for health information exchange and enterprise remote audit), the image must be encrypted and decrypted quickly to guarantee the stable operation of the NIPVSCS. erefore, the current image encryption algorithms cannot be employed directly, and the novel image encryption algorithms need to be developed in term of two requirements: (1) the processing speed of the image encryption and decryption algorithms must be very fast and (2) the image encryption and decryption algorithms must be robustness against the attacks.
To solve the abovementioned problems, this paper proposes a fast image encryption method of the NIPVSCS. e main contributions include (1) A fast encryption method by combining the image scaling and an ISDIE algorithm is proposed to achieve secure and efficient transmission of the images. (2) e security performance of the proposed algorithm, the characteristics of different delays, and the control performance of the NIPVSCS are analyzed. Simulation and real-time control experiments show that the proposed method has good encryption and decryption effects and good robustness against the image noise attacks and shear attacks, while meeting real-time requirements of the NIPVSCS.

Related Work
e previous works on the NIPVSCS and the image encryption will be reviewed, and the unique features of this paper are discussed.

Real-Time Control of the NIPVSCS.
e NIPVSCS is the system where the images of the inverted pendulum are captured by visual sensors and the images are then transmitted to the image processing unit via the network, followed by the state information extracted from these images. e obtained state information is then used to achieve realtime control, which is attached to delay constraints including network-induced delay and image processing computational delay. Furthermore, some methods are proposed to overcome these two delays. For example, the finite-time H ∞ stability analysis of uncertain network-based control systems under varying network delay was studied [11]. e stability analysis of the NCSs with the fixed time delay was discussed [12], and a new approach to the suboptimal control of nonlinear time-delay systems was presented [13]. In [14,15], the time-varying delay and image processing computational delay are considered, and a closed-loop control system model is established and H ∞ control strategy is used to achieve the stable of the control system. However, the abovementioned studies did not consider the image security (e.g., the leakage or corruption of information). In the NIPVSCS, since the state information is included in the images, it is crucial to protect these images.
In this paper, an NIPVSCS equipped with an image encryption unit is proposed to address the problem of image security. e control performance of the NIPVSCS is also analyzed under cyber attacks.

Image Encryption Algorithm.
e image encryption algorithms, a common technique for image security, are usually used to protect image information from illegal acquisition. Recently, some image encryption algorithms have been developed. For example, according to the DNA encryption algorithm and the double-chaotic system, an image encryption-then-transmission system was presented [16]. An encryption method based on interleaved computergenerated holograms displayed by a spatial light modulator was proposed [17]. A hybrid image encryption scheme based on block compressive sensing was developed [18]. e image was encrypted by adopting the image encryption algorithm based on logistic map [19,20]. However, the above proposed approaches induce the long encryption calculation delay that cannot meet the real-time requirements of the NIPVSCS.
In this paper, a fast image encryption method is developed to improve the security of the image and achieve real-time control of the NIPVSCS. e process of the fast image encryption method by combining image scaling and the ISDIE algorithm is provided and its security is then analyzed by simulation and real-time experiments.

The Proposed Framework
An image scaling and encryption unit is added to the preestablished NIPVSCS [21]. Figure 1 outlines the system framework that contains two parts: Part 1 is the NIPVSCS; Part 2 is the proposed fast encryption method combining image scaling and the ISDIE algorithm.
3.1. Part 1: e NIPVSCS. As can be seen from the left part of Figure 1, the NIPVSCS consists of the inverted pendulum (containing a cart, a swing rod, and a slide), the visual sensing devices (containing Aca640-120 gm industrial camera and a light source), the image scaling and encryption unit, the controller (containing a motion control card), and the actuator (containing servo driver and servo motor). e operation of the NIPVSCS starts from the move of the swing rod. e real-time moving image of the inverted pendulum captured by the industrial camera is sent to the image scaling and encryption unit. In this unit, as shown in the right part of Figure 1, the inverted pendulum image is firstly scaled to reduce the amount of the image data, and the scaled image is then encrypted with an ISDIE algorithm to ensure image transmission security. Moreover, it can be seen from the right part of Figure 1 that the pixel values of each row of the image are confused to obtain a row confusing image, and the pixel values of each column of the image are confused to obtain a column confusing image, by implementing image encryption. Returning to the left part of Figure 1, the encrypted image is sent to the remote image processing unit through a network. In the remote image processing unit, the encrypted image is decrypted, and the state information of the cart and the pendulum is then extracted by using a series of image processing methods [22][23][24][25], which will be sent to the controller. Finally, the actuator processes the corresponding control signals to achieve real-time stable control of the NIPVSCS. Remark 1. Different from most previous research studies only verified in simulations, the new NIPVSCS is based on a real experimental platform that can be used to validate the theoretical methods. Moreover, compared with the NIPVSCS in [21], two new units are added into the new NIPVSCS, i.e., the image scaling and encryption unit and the remote image processing unit.

Part 2: e Fast Image Encrytion Method
3.2.1. Image Scaling. Due to the large amount of inverted pendulum image data, long delays will be generated during network transmission and image encryption/decryption. To solve these problems, a method of interpolation scaling is used. Specifically, before the image is encrypted and transmitted, the inverted pendulum image is scaled down to reduce the amount of image data. is is shown in the right part of Figure 1. e image scaling can be expressed as the 2 Complexity pixel position transformation followed by the calculation of pixel values, which will be given in the following.
(1) Pixel Position Transformation. Let (srcx, srcy) and (dstx, dsty) to be the pixel coordinates of the original inverted pendulum image and the scaled image, respectively. e formula of pixel position transformation is where srccols and dstcols are the number of columns of the original image and the scaled image, respectively; srcrows and dstrows are the number of rows of the original image and the scaled image, respectively; and dstcols/srccols and dstrows/srcrows are the image scaling ratio in the horizontal direction and the vertical direction, respectively. e principle of scaling is shown in Figure 2.

Remark 2.
To conveniently calculate the state information of the inverted pendulum in the scaled image, the equal scaling method is adopted, i.e., the same scaling ratio is taken in the horizontal and vertical directions, respectively.

Remark 3.
To meet the real-time requirements of the NIPVSCS, we need to scale the image to a certain ratio before processing the inverted pendulum image to reduce the data amount of the original image. However, if the image scaling ratio is very small, it will lose a lot of image information, resulting in system performance degradation or even instability. erefore, it is a trade-off between the image scaling ratio and system performance.
(2) Calculation of Pixel Values. To explain clearly, the gray values as a special case of the pixel values are concentrated. In Figure 2, the gray value of the coordinate (x, y) in the scaled image is that of the coordinate (x + Δx, y + Δy) in the original image. However, since the coordinates of the pixel point are often integers and Δx and Δy could be nonintegers, the gray value of (x + Δx, y + Δy) may not be directly obtained. erefore, the bilinear interpolation method [26,27] is used to calculate the gray value when the image is scaled, as shown in Figure 3.
In Figure 3, f(x, y) represents the gray value of the coordinate (x, y). Two linear equations hold as follows: erefore, the gray value of (x + Δx, y + Δy) can be calculated by

ISDIE Algorithm.
e ISDIE algorithm includes two parts: the row confusion and column confusion. Before illustrating the ISDIE algorithm, M × N is the size of the inverted pendulum image, and P i,j is the pixel value at the ith row and jth column in the inverted pendulum image, where 1 ≤ i ≤ M and 1 ≤ j ≤ N. In addition, we give the number t k to the kth inverted pendulum image frame, where t k ≥ k. e ISDIE algorithm starts from the calculation of a regulation parameter T by using the number t k of the kth inverted pendulum image frame.
Step 1: record the number of the each inverted pendulum image frame to obtain the regulation parameter T, and it is calculated by where the divisor is set as 1000. e following are the procedures of row confusion and column confusion.
(1) Row confusion: Step 2: to generate a pseudorandom state value as an encryption key, the logistic map [20,21] is used as follows: where x i ∈ (0, 1) and μ ∈ (1,4]. In this paper, x 0 � 0.19940730 and μ � 3.999999 are set to guarantee the randomness of the state value.
Step 3: then, x i is used to generate other two different row numbers m and n by where ⌈ · ⌉ is the ceil function and ⌊ · ⌋ is the floor function and mod is a MOD function. To ensure that both m and n are different from i, the operations need to be further done as follows.
Step 4: furthermore, m and n are used to confuse the current ith row by where s � 1, . . . , N and ⊕ is the boolean operator of xor.
Step 5: to achieve the "one time and one secret" of the encryption algorithm, the chaotic map value needs to be updated by where x i + T donates the decimal part of x i + T.
Step 6: from the 1st row to the Nth row, the loop through Steps 2-6 to encrypt the inverted pendulum image in the row direction. (2) Column confusion: After the row confusion is completed, two changes on the procedure of row confusion can lead to that of column confusion: (i) change i as j in (6)- (8) and (10); (ii) then, change (9) as where r � 1, . . . , M. Finally, the whole inverted pendulum image is encrypted in the row and column directions.  e traditional image encryption algorithms often take too long time to encrypt/decrypt the image so that the real-time requirement of the NIPVSCS could not be satisfied. In the context of the problem, by modifying the model of the image encryption algorithm in [21], the ISDIE algorithm is developed in this paper. To validate the efficiency of the ISDIE algorithm, the real-time experiments of the NIPVSCS running the above two algorithms are separately performed, whose results are shown in Table 1. From Table 1, it can be seen that the encryption time of the ISDIE algorithm is less than that of the algorithm in [21]. In this sense, the ISDIE algorithm is more suitable for the NIPVSCS. e experimental environment is Visual Studio 2010 and OpenCV2.4.11 with Intel Core i3-2120 CPU @ 3.30 GHz and 8.00 G RAM on Window XP.

Remark 5.
Considering the insecurity issues of the network (e.g., information loss and information disclosure), the serial number of the inverted pendulum images, which are unrelated to the contents of the image, are adopted to update the encryption key. Using this technology with different keys, the ISDIE algorithm can resist the plaintext-choosing attack and recover the core information when the encrypted images are corrupted by image noise attacks or shear attacks.
Furthermore, the ISDIE Algorithm 1 can be summarized as follows.
For the received encrypted image, decryption and encryption are inverse processes, and the decryption process is as follows.
(1) Column decryption: Step 1: to generate a pseudorandom state value as an encryption key, the logistic maps are used as (6). To accurately decrypt the image, x 0 � 0.19940730 and μ � 3.999999 are set to guarantee the randomness of the state value.
Step 2: create two auxiliary sequences and initialize them to 0, and the sequence is represented as follows: Step 3: fill the auxiliary sequence with if jj � j, then jj � j mod N + 1 and if kk � j, then kk � imod N + 1. Furthermore, j j � jj and k j � kk.
Step 4: to achieve the "one time and one secret" of the encryption algorithm, the chaotic map value needs to be updated by where x j + T} denotes the decimal part of x j + T and the value of T is the same as the value of T in Step 1.
Step 5: from column 1 to column N, the loop steps 1-4 to fill the auxiliary sequence.
Step 7: from the Nth column to the 1st column, the loop through Step 6 decrypts the inverted pendulum image in the column direction.

(2) Row decryption
After the column decryption is completed, two changes on the procedure of columns decryption can lead to that of rows decryption: (i) change j as i in (12)-(16); (ii) then, change (17) as where j � 1, . . . , N. Finally, the whole inverted pendulum image is decrypted in the row and column directions.

Security Analysis of the ISDIE Algorithm.
e security of the ISDIE algorithm mainly involves two aspects, i.e., key confidentiality and image robustness. e former strives for the attackers unavailable to the original key. e latter focuses on the decryption robustness against the attacks. e detailed analysis is discussed as below.

Analysis of Key Confidentiality.
In the context of key confidentiality, three types of common attacks are considered. e first is the brute-force attacks, which attempts to traverse all possible keys for the intercepted ciphertext. e second, which can be viewed as an improvement of the first, adopts the statistical methods to obtain the distribution characteristics of the ciphertext so that the amount of searching messages or keys is reduced. Going further than both the above attacks, the plaintext is used for the comparison with the ciphertext in the third type of the attack.
(1) Brute-Force Attacks. To cope with brute-force attacks, the key used to encrypt the inverted pendulum image requires a sufficiently large key space and high sensitivity to key changes. In this paper, a test is carried out to prove that the Complexity ISDIE algorithm can meet the above two requirements. In our test, three decrypted images using different keys infinitely close to the initial one are obtained in Figure 4. As can be seen in Figure 4, the key is hypersensitive in the decryption process and the key space of the encryption algorithm is more than 10 56 . erefore, the space is large enough to resist brute-force attacks.
(2) Statistical Attacks. To quantify the ability of coping with statistical attacks, the histogram of the images, the correlation of the pixels, and information entropy are adopted from different perspectives. e histogram of the images is to describe the quality distribution characteristics [28]. e histograms of the original and encrypted images are shown in Figure 5. As can see from Figure 5(a), the gray-scale distribution of the original image is nonuniform and the characteristics peaks are clear. Conversely, the histogram of the encrypted image is uniform enough, as shown in Figure 5(b). is confirms the excellent property of resisting the statistical attack of the ISDIE algorithm. e correlation of the pixels represents the randomness of the gray level. e correlation coefficients c xy of each pair can be calculated by where x and y denote the values of two adjacent pixels in the image: where N denotes the number of pairs of adjacent pixels. e correlation of the encrypted and original image is shown in Figure 6 and Table 2. e correlation of the original is high and close to 1. In contrast, the correlation of the encrypted image is low and close to 0, which indicates that encrypted pixels are distributed randomly.
Information entropy is used to reflect the randomness and unpredictability of the image gray value. e inverted pendulum image is 256 gray level and the ideally result should be 8. If the information entropy is closer to 8, the randomness is better. Table 2 shows the information entropy at different image scaling ratios. From Table 2, it is known that entropies are close to 8, so the proposed algorithm has a good property of information entropy.
(3) Differential Attacks. Two indicators, the Number of Pixels Change Rate (NPCR) and the Unified Average Changing Intensity (UACI), are used to measure the ability of resisting differential attack. e ideal values of NPCR and UACI are 99.61% and 33.46%, respectively [16,29], and the real result values of the ideal image encryption algorithm should be close to the ideal values. ey can be calculated by where C 1 (i, j) and C 2 (i, j) denote the gray value of two images, D is a matrix, and when C 1 (i, j) � C 2 (i, j), then D(i, j) � 0 or D(i, j) � 1, and M and N are the width and height of the inverted pendulum image, respectively.
To compare the performance, we randomly change the gray value of one pixel of the inverted plaintext image and repeat it 500 times. e NPCR and UACI are obtained, as shown in Figure 7, by the proposed algorithm, where it can be found that the proposed scheme can resist differential attack effectively.

Input: e original inverted pendulum image
Output: e encrypted image (1) l ⟵ 1 to k with the stepsize of 1 do T ⟵ mod( k l�1 t l , 1000) (2) For i ⟵ 1 to M with the stepsize of 1 do For s ⟵ 1 to N with the stepsize of 1 do P i,s � P i,s ⊕P m,s ⊕P n,s end for (8) x i ⟵ x i + T (9) End for (10) For j ⟵ 1 to N with the stepsize of 1 do (11) x For r ⟵ 1 to M with the stepsize of 1 do P r,j � P r,j ⊕P r,m ⊕P r,n end for (15) x j ⟵ x j + T (16) End for ALGORITHM 1: ISDIE algorithm. 6 Complexity

Analysis of Image Robustness.
e above confirms the key confidentiality of ICDIE algorithm. Next, we will take into account the security issues about the disrupted image.
Specifically, in the NIPVSCS, the images are vulnerable to the common image noise and shear attacks. erefore, the image encryption algorithms for the NIPVSCS must be able

Delay Analysis of the Proposed Fast Encryption Method
Used in the NIPVSCS. In the NIPVSCS, the delay is a key factor affecting system stability [11]. In this paper, the NIPVSCS delays are mainly composed of network transmission delay, image encryption and decryption delay, and image processing computational delay. To analyze the delays of the NIPVSCS, real-time statistics on network transmission delay and image encryption and decryption computational delay under different image scaling ratios are firstly obtained, and then the total system delay in the NIPVSCS under different image scaling ratios is calculated.

Network Transmission Delay under Different Image
Scaling Ratios. To obtain the network transmission delay, 2000 image frames are transmitted under different image scaling ratios in the NIPVSCS. e delay of each image frame is recorded and finally taken as an average. e results are shown in Table 3.
From Table 3, it can be seen that network transmission delay gradually decreases as the image scaling ratio decreases.
is shows that scaling the inverted pendulum image can effectively reduce network transmission delay in the NIPVSCS.

Image Encryption and Decryption
Delay under Different Image Scaling Ratios. e time of the inverted pendulum image encryption and decryption under different image scaling ratios is recorded in Figure 9. It can be seen that the encryption and decryption delay decreases as the image scaling ratio decreases.

Total System Delay under Different Image Scaling
Ratios. We denote d k ∈ [d, d] by the total delay from the visual sensor to the controller, where d and d are, respectively, the lower and upper bounds of d k . We record d k under different image scaling ratios in Figure 10 and d and d in Table 4.
From Figure 10 and Table 4, it can be seen that the lower and upper bounds of the total delay decreases as the image scaling ratio decreases, respectively. In Table 4, d is lower than the real-time requirement of the NIPVSCS when the image scaling ratio is 30%, 40%, 50%, and 70%.

Secure Control Analysis of the Proposed Fast Encryption
Method Used in the NIPVSCS. From [11,14], it is known that the NIPVSCS will be unstable when the upper bound of the total delay is greater than or equal to 38 ms in real-time control environment. To analyze the feasibility of the   proposed fast encryption method in the NIPVSCS, the realtime control experiment is firstly carried out under no attack. e result is shown in Figure 11. Figure 11 shows that the cart position and the pendulum angle fluctuate in a very small range when the image scaling ratio is 70%, 50%, and 40%, while the NIPVSCS is stable. However, the system control curve is diverging (i.e., the NIPVSCS is unstable) when the image scaling ratio is 30%. e distinction between the theoretical and real-time results may be caused by three aspects: (i) the difference of the linear model and nonlinear model of the plant; (ii) as the image scaling decreases, the image processing errors gradually increase; (iii) the unknown noise being overlooked. In the practical applications, a larger image scaling ratio should be selected to achieve real-time control when the delay requirements of system stability control are met.
Next, to verify the robustness of the ISDIE algorithm against image noise and shear attack, some real-time control experiments under the noise attack and shear attack are carried out, respectively. In this experiment, the image is scaled to 50%. e results are shown in Figure 12. As can be seen from Figure 12, the NIPVSCS can still remain stable even if the image is disrupted by image noise attacks. is  shows the good robustness of the ISDIE algorithm against image noise attack NIPVSCS.

Conclusions
is paper addresses the problem of safe and efficient transmission of image in the NIPVSCS. Specifically, we have developed a fast encryption method combining image scaling and ISDIE algorithm, where the captured images are encrypted after they are scaled. We have evaluated our method by using the simulation and real-time experiments. e proposed method can guarantee the key confidentiality and image robustness and meet the real-time control requirements of the NIPVSCS with some certain image scaling ratio. However, the scaled inverted pendulum image will reduce image quality to some extent and cause image processing errors. erefore, considering the effect of image processing error caused by image scaling on the stability of the NIPVSCS is a very valuable future work. Moreover, the fast encryption method can be successfully used for a fast    motion control system, i.e., NIPVSCS security and stability control, which can further provide technical support for remote vision robot control, aircraft control, and other applications.

Data Availability
e experimental data used to support the findings of this study have not been made available since these data are related to the personal privacy of each volunteer involved in the experiment.

Conflicts of Interest
e authors declare that there are no conflicts of interest.