An Image Encryption Algorithm Based on Random Hamiltonian Path

In graph theory, Hamiltonian path refers to the path that visits each vertex exactly once. In this paper, we designed a method to generate random Hamiltonian path within digital images, which is equivalent to permutation in image encryption. By these means, building a Hamiltonian path across bit planes can shuffle the distribution of the pixel’s bits. Furthermore, a similar thought can be applied for the substitution of pixel’s grey levels. To ensure the randomness of the generated Hamiltonian path, an adjusted Bernoulli map is proposed. By adopting these novel techniques, a bit-level image encryption scheme was devised. Evaluation of simulation results proves that the proposed scheme reached fair performance. In addition, a common flaw in calculating correlation coefficients of adjacent pixels was pinpointed by us. After enhancement, correlation coefficient becomes a stricter criterion for image encryption algorithms.


Introduction
When computers and the internet came on the scene, here came the era of information, accompanied by the formidable challenge of information security. Among complicated information, the vivid multimedia information is preferred by people, especially digital images. Consequently, such information involves both collective interests and personal interests. For instance, images of military affairs are related to the safety of whole country. Privacy and copyright of images influence everyone's peace of mind. To protect the rights of image's owners, methods like steganography, watermarking, and encryption are frequently utilized [1]. Among these techniques, encryption is a direct and thorough means. Nowadays, image encryption is an inviting and fruitful field, and many imaginative image encryption algorithms are proposed.
One picture is worth more than ten thousand words, and there indeed are tens of thousands of pixels in a digital image. To encrypt the bulk data of images, traditional cryptosystems are not efficient enough. Among specific image encryption schemes, the permutation-diffusion structure is widely used. Essentially, permutation is to rearrange image pixels on different dimensions. In [2], 2D CMT (chaotic magic transform) was proposed for permutation. In [3], image scrambling was performed by a parametric 2D Sudoku matrix. In [4], horizontal and vertical wave lines were utilized to realize row rotation and column rotation. This is also a 2D method. In [5], spatial permutation was performed on a 3D bit matrix by using orthogonal Latin cubes. Moreover, file-based algorithms like [6] deem images as 1D binary files when realizing permutation. Considering the features of bit distribution in digital images, encryption schemes [7,8] with bit-level permutation are proposed.
Sometimes, the permutation phase is accompanied by a sort operation, such as [2]. However, time complexity of sorting is usually nonlinear. To obtain high efficiency, the additional operation should be avoided. Regarding an image as a 1D pixel array, permutation can be depicted as an arrangement of pixels, which is represented in the bijective map from plain image to permuted image. If we connect the pixels by order of the arrangement, all the pixels are traversed exactly once. Deeming pixels as the vertices of a graph, such a path of traversing is known as a Hamiltonian path in graph theory. Conversely, a Hamiltonian path corresponds to an arrangement of permutations. Following this thought, the method of building Hamiltonian path is equal to a permutation scheme. As a Hamiltonian path can be generated without sort operation, the corresponding permutation algorithm has the advantage of efficiency. In cryptography, substitution is a classical method of cipher schemes. To substitute pixel's grey value, arrangement of all the possible grey levels is requisite. Hence, the thought of random Hamiltonian path is also suitable for the substitution of grey levels.
It is common knowledge that chaotic systems have conspicuous advantages for cryptosystems. High dimension chaotic systems possess complex chaotic behavior, while 1D chaotic systems are convenient for implementation. Under synthetical consideration, some combined chaotic maps have been explored in recent encryption schemes [2,[9][10][11][12]. Just resembling the series-parallel connection of resistors in circuits, these chaotic maps are a combination or adjustment of the original chaotic maps. Multiple chaotic maps can be coupled as CML (chaotic map lattice) [13,14]. By these means, chaotic behavior is magnified, leading to better chaotic performance. In this paper, a new chaotic map was also explored.
There are some innovative works in this paper: • A method of building a random Hamiltonian path within digital images was designed, which is equivalent to permutation. On this basis, bit-level permutation of high efficiency was achieved.

•
Following the thought of the random Hamiltonian path, arrays for grey levels' substitution can be generated.

•
An adjusted Bernoulli map is proposed, which is suitable for image encryption schemes.

•
The ambiguous definition of diagonal direction is normalized to two orthogonal directions when calculating correlation coefficients.
The rest of this paper is organized as following: Section 2 explains the Hamiltonian path and the procedures to generate such paths within images. Section 3 expounds the adjusted Bernoulli map. In Section 4 the proposed scheme is thoroughly introduced. The results of simulation experiments are exhibited in Section 5. Section 6 is the summary of the entire paper.

Hamiltonian Path
As was mentioned earlier, the scheme of generating a random Hamiltonian path is tantamount to permutation. In this section, the relevant theories are presented, while the method of generating a Hamiltonian path is proposed.

Basic Theory of Hamiltonian Path
Graph theory is a classical branch of mathematics. The term graph refers to the figures composed by points and the connecting lines between the points. Commonly, the points are called vertices, and the lines are called edges. The definition of graph is G = (V, E). Here V is a nonempty set of finite vertices and the set of edges E = {(x, y)|x, y ∈ V}. If the vertex pair (x, y) in E is ordered, the graph is named a direct graph. Otherwise, it is named an undirected graph.
In an undirected graph, a path P is a sequence of vertices v 1 v 2 . . . v k , and there exists anedge between each of the vertex pairs v i v i+1 . The k is the number of vertices that P contains, in other words, the length of P.
There are two special categories of path, Euler path and Hamiltonian path. Euler path refers to the paths that traverse each edge once and only once. A famous instance is the problem of Konigsberg bridges [15]. In 1736, Leonhard Euler had proved that there is no solution for the problem. This is known as the beginning of graph theory. Hamiltonian path refers to the paths that traverse each node Entropy 2020, 22, 73 3 of 18 once and only once, or an arrangement of all vertices in which every adjacent vertex pair is connected by at least one edge. The problem of Hamiltonian path can be traced back to 1859, when Willian Hamilton talked about a mathematical game: traverse all the vertices of a dodecahedron and pass by the vertices exactly once. Figure 1 is the graphic illustration of the two famous problems.  Figure 1 is the graphic illustration of the two famous problems.
(a) (b) Graphs are generally intricate. The problem of finding a Hamiltonian path is a nondeterministic polynomial complete problem (NP-C problem), one of the most burdensome challenges in mathematics [16][17][18][19]. Off the beaten track, DNA computing [20] and light-based computers [21] have been developed to solve this problem efficiently. However, generating a Hamiltonian path within digital images can be much easier.

Hamiltonian Path Within Digital Images
For an undirected graph of N vertices, there are, at most, N × (N + 1)/2 edges. Under this condition, any two vertices are connected by an edge. Such a graph is called a complete graph. Some instances of complete graphs are shown in Figure 2. The complete graphs with three nodes, four nodes, and five nodes are shown in Figure 2a-c, respectively. There are varieties of theorems to measure whether there are Hamiltonian paths in a graph. One of the theorems is as below: Dirac theorem: In a graph G of N vertices, if for each vertex vi there always is d(vi) ≥ N/2, then at least one Hamiltonian path exists in G.
The d(vi), otherwise called the degree of vi, represents the quantity of edges connected with vi. Graphs are generally intricate. The problem of finding a Hamiltonian path is a nondeterministic polynomial complete problem (NP-C problem), one of the most burdensome challenges in mathematics [16][17][18][19]. Off the beaten track, DNA computing [20] and light-based computers [21] have been developed to solve this problem efficiently. However, generating a Hamiltonian path within digital images can be much easier.

Hamiltonian Path Within Digital Images
For an undirected graph of N vertices, there are, at most, N × (N + 1)/2 edges. Under this condition, any two vertices are connected by an edge. Such a graph is called a complete graph. Some instances of complete graphs are shown in Figure 2. The complete graphs with three nodes, four nodes, and five nodes are shown in Figure 2a-c, respectively. Graphs are generally intricate. The problem of finding a Hamiltonian path is a nondeterministic polynomial complete problem (NP-C problem), one of the most burdensome challenges in mathematics [16][17][18][19]. Off the beaten track, DNA computing [20] and light-based computers [21] have been developed to solve this problem efficiently. However, generating a Hamiltonian path within digital images can be much easier.

Hamiltonian Path Within Digital Images
For an undirected graph of N vertices, there are, at most, N × (N + 1)/2 edges. Under this condition, any two vertices are connected by an edge. Such a graph is called a complete graph. Some instances of complete graphs are shown in Figure 2. The complete graphs with three nodes, four nodes, and five nodes are shown in Figure 2a-c, respectively. There are varieties of theorems to measure whether there are Hamiltonian paths in a graph. One of the theorems is as below: Dirac theorem: In a graph G of N vertices, if for each vertex vi there always is d(vi) ≥ N/2, then at least one Hamiltonian path exists in G.
The d(vi), otherwise called the degree of vi, represents the quantity of edges connected with vi.  There are varieties of theorems to measure whether there are Hamiltonian paths in a graph. One of the theorems is as below: Dirac theorem: In a graph G of N vertices, if for each vertex v i there always is d(v i ) ≥ N/2, then at least one Hamiltonian path exists in G.
The d(v i ), otherwise called the degree of v i , represents the quantity of edges connected with v i . In our scheme, digital images were regarded as complete graphs. Hereof, the pixels are the vertices, and there is an edge between every two pixels. According to Dirac theorem, there always exist Hamiltonian paths in such graphs.
To build a Hamiltonian path within an image, pixels are divided into two parts. One is composed by the pixels that have been added into the path. The other one is composed by the rest of the pixels. Firstly, a pixel is chosen to be the path's outset. Then, the other pixels are added to the path one by one. If the image's size is M × N and its pixels are {P 1 , P 2 , . . . , P M×N }, this progress can be generalized as the following steps: Step 1: Choose a pixel from {P 1 , P 2 , . . . , P M×N } and put it in the position of P M×N .
Step 2: Choose a pixel from {P 1 , P 2 , . . . , P M×N-1 } and put it in the position of P M×N-1 .
Step M×N-1: Choose a pixel from {P 1 , P 2 } and put it in the position of P 2 .
In the above process, pixels that have been added into the path are insulated at the back of image's pixel array. Among the whole image, these pixels are deemed as permutated pixels. The complete process is shown in Figure 3. Figure 4 illustrates the generated Hamiltonian path from a graph perspective. In our scheme, digital images were regarded as complete graphs. Hereof, the pixels are the vertices, and there is an edge between every two pixels. According to Dirac theorem, there always exist Hamiltonian paths in such graphs.
To build a Hamiltonian path within an image, pixels are divided into two parts. One is composed by the pixels that have been added into the path. The other one is composed by the rest of the pixels. Firstly, a pixel is chosen to be the path's outset. Then, the other pixels are added to the path one by one. If the image's size is M×N and its pixels are {P1, P2, …, PM×N}, this progress can be generalized as the following steps: Step 1: Choose a pixel from {P1, P2, …, PM×N} and put it in the position of PM×N.
Step 2: Choose a pixel from {P1, P2, …, PM×N-1} and put it in the position of PM×N-1.
Step 3: Choose a pixel from {P1, P2, …, PM×N-2} and put it in the position of PM×N-2. … Step M×N-1: Choose a pixel from {P1, P2} and put it in the position of P2.
In the above process, pixels that have been added into the path are insulated at the back of image's pixel array. Among the whole image, these pixels are deemed as permutated pixels. The complete process is shown in Figure 3. Figure 4 illustrates the generated Hamiltonian path from a graph perspective.    In our scheme, digital images were regarded as complete graphs. Hereof, the pixels are the vertices, and there is an edge between every two pixels. According to Dirac theorem, there always exist Hamiltonian paths in such graphs.
To build a Hamiltonian path within an image, pixels are divided into two parts. One is composed by the pixels that have been added into the path. The other one is composed by the rest of the pixels. Firstly, a pixel is chosen to be the path's outset. Then, the other pixels are added to the path one by one. If the image's size is M×N and its pixels are {P1, P2, …, PM×N}, this progress can be generalized as the following steps: Step 1: Choose a pixel from {P1, P2, …, PM×N} and put it in the position of PM×N.
Step 2: Choose a pixel from {P1, P2, …, PM×N-1} and put it in the position of PM×N-1.
Step 3: Choose a pixel from {P1, P2, …, PM×N-2} and put it in the position of PM×N-2. … Step M×N-1: Choose a pixel from {P1, P2} and put it in the position of P2.
In the above process, pixels that have been added into the path are insulated at the back of image's pixel array. Among the whole image, these pixels are deemed as permutated pixels. The complete process is shown in Figure 3. Figure 4 illustrates the generated Hamiltonian path from a graph perspective.

Hamiltonian Path across Bit Planes
In [7], the intrinsic features of bit distribution in digital images were revealed. Higher bits of pixels hold higher weight of an image's information, and there are strong correlations among the higher bit planes. In the instance of Figure 5, the 8th bit plane and the 7th bit plane tend to have opposite values. These features shall not be neglected in a secure cryptosystem.

Hamiltonian Path across Bit Planes
In [7], the intrinsic features of bit distribution in digital images were revealed. Higher bits of pixels hold higher weight of an image's information, and there are strong correlations among the higher bit planes. In the instance of Figure 5, the 8th bit plane and the 7th bit plane tend to have opposite values. These features shall not be neglected in a secure cryptosystem. To build a Hamiltonian path across bit planes, the strategy of [7] was extended to greyscale images in this paper. By these means, a plain image of size M × N is expanded to 2M × 2N. All the bit planes of a plain image's pixels were placed to the 1st bit plane and the 2nd bit plane of the expanded image's pixels. After generating a Hamiltonian path, the bit planes were restored, and a permutated image of size M×N was formed. The whole procedure can be generalized into Figure 6.   To build a Hamiltonian path across bit planes, the strategy of [7] was extended to greyscale images in this paper. By these means, a plain image of size M × N is expanded to 2M × 2N. All the bit planes of a plain image's pixels were placed to the 1st bit plane and the 2nd bit plane of the expanded image's pixels. After generating a Hamiltonian path, the bit planes were restored, and a permutated image of size M × N was formed. The whole procedure can be generalized into Figure 6.

Hamiltonian Path across Bit Planes
In [7], the intrinsic features of bit distribution in digital images were revealed. Higher bits of pixels hold higher weight of an image's information, and there are strong correlations among the higher bit planes. In the instance of Figure 5, the 8th bit plane and the 7th bit plane tend to have opposite values. These features shall not be neglected in a secure cryptosystem. To build a Hamiltonian path across bit planes, the strategy of [7] was extended to greyscale images in this paper. By these means, a plain image of size M × N is expanded to 2M × 2N. All the bit planes of a plain image's pixels were placed to the 1st bit plane and the 2nd bit plane of the expanded image's pixels. After generating a Hamiltonian path, the bit planes were restored, and a permutated image of size M×N was formed. The whole procedure can be generalized into Figure 6.

Adjusted Bernoulli Map
To ensure the randomness of the Hamiltonian path, chaotic maps can serve as pseudo random number generators. Theoretically, any 1D chaotic map is compatible. In this section, an adjusted Bernoulli map is proposed.

Bernoulli Map
The original definition of Bernoulli map [22,23] is given by: (1) The piecewise linear property of a Bernoulli map is demonstrated in Figure 8. When implemented into discrete computer systems, the map resembles bit shifting of floating numbers. Such degradation means that the original Bernoulli map is seldom applied to encryption algorithms directly.

Adjusted Bernoulli Map
To ensure the randomness of the Hamiltonian path, chaotic maps can serve as pseudo random number generators. Theoretically, any 1D chaotic map is compatible. In this section, an adjusted Bernoulli map is proposed.

Bernoulli Map
The original definition of Bernoulli map [22,23] is given by: The piecewise linear property of a Bernoulli map is demonstrated in Figure 8. When implemented into discrete computer systems, the map resembles bit shifting of floating numbers. Such degradation means that the original Bernoulli map is seldom applied to encryption algorithms directly.

Adjusted Bernoulli Map
To ensure the randomness of the Hamiltonian path, chaotic maps can serve as pseudo random number generators. Theoretically, any 1D chaotic map is compatible. In this section, an adjusted Bernoulli map is proposed.

Bernoulli Map
The original definition of Bernoulli map [22,23] is given by: (1) The piecewise linear property of a Bernoulli map is demonstrated in Figure 8. When implemented into discrete computer systems, the map resembles bit shifting of floating numbers. Such degradation means that the original Bernoulli map is seldom applied to encryption algorithms directly.

Adjusted Bernoulli Map
To amplify the limited nonlinear property of original Bernoulli map, cascaded modulus operations are adopted in the adjusted Bernoulli map (ABM).
The parameters α and β can be many of the floating-point numbers that are bigger than two. Though the multiplication operation is linear in mathematics, the multiplication operation in computer systems involves the conversion between decimal number and binary number. The ABM possesses fair chaotic behavior in practice, especially when the parameters α and β are random. Owing to the finite precision of computers, the ABM does not work well when its parameters are big numbers, and special values such as 2 N and 10 N should be avoided. Here the N is the set of natural numbers. Part of the parameters' value range is shown in Figure 9.

Adjusted Bernoulli Map
To amplify the limited nonlinear property of original Bernoulli map, cascaded modulus operations are adopted in the adjusted Bernoulli map (ABM).
The parameters α and β can be many of the floating-point numbers that are bigger than two. Though the multiplication operation is linear in mathematics, the multiplication operation in computer systems involves the conversion between decimal number and binary number. The ABM possesses fair chaotic behavior in practice, especially when the parameters α and β are random. Owing to the finite precision of computers, the ABM does not work well when its parameters are big numbers, and special values such as 2 N and 10 N should be avoided. Here the N is the set of natural numbers. Part of the parameters' value range is shown in Figure 9. To examine the randomness of the pseudo-random numbers generated by the ABM, the NIST SP800-22 test suite [24] was utilized. In our experiment, 300 bitstreams of length 10 6 were generated and tested. The α = 10.45678 and β = 10.123 in these bitstreams. The initial value of x was increased by 0.0033, ranging from 0.001 to 0.991. The test results are listed in Table 1.  To examine the randomness of the pseudo-random numbers generated by the ABM, the NIST SP800-22 test suite [24] was utilized. In our experiment, 300 bitstreams of length 10 6 were generated and tested. The α = 10.45678 and β = 10.123 in these bitstreams. The initial value of x was increased by 0.0033, ranging from 0.001 to 0.991. The test results are listed in Table 1.

Proposed Scheme
After the progress of Section 2, a bit-level permutation was completed. To obtain fair diffusion properties, XOR operations were performed on pixels, and their grey values were substituted dynamically. The whole encryption scheme is detailed in this section.

Encryption Algorithm
As is illustrated in Figure 10, the whole cryptosystem is handled by ABM. The inputs of the algorithm are the plain image P of size M × N and the parameters of ABM. The output is the cipher image C. After the progress of Section 2, a bit-level permutation was completed. To obtain fair diffusion properties, XOR operations were performed on pixels, and their grey values were substituted dynamically. The whole encryption scheme is detailed in this section.

Encryption Algorithm
As is illustrated in Figure 10 The whole encryption process is as below: Step 1: Read in P. Iterate ABM to avoid transient effect.
Step 2: Decompose P's bit planes. Make a montage of these bit planes to obtain an image B of size 2M×2N.
Step 2: Decompose P's bit planes. Make a montage of these bit planes to obtain an image B of size 2M × 2N.
Step 3: (3) Step 4: Merge the decomposed bit planes to obtain the permutated image H of size M × N.
Step 10: Save H as the C.

Discussion
In Step 2, Step 3, and Step 4, the permutation phase that works on a bit-level was performed. According to the method of building a Hamiltonian path, two arrays were generated for grey value's substitution in Step 5, 6, and 7. The arrays were arrangements of integers from 0 to 255, in accordance with pixel's grey levels. As the arrays were randomly generated, there were 256! ≈ 8.578 × 10 506 possible arrangements. In this way, the modification of plain images could be amplified and transmitted in Step 8 and Step 9, causing an avalanche effect.

Decryption Algorithm
The decryption algorithm is the reverse progress of the encryption algorithm, as can be seen from Figure 11. Step 8: For i = 1, 2, …, M × N − 1, use Equation (7) to diffuse H's pixel Hi+1. Here, ai is the pseudo random number generated by ABM.
Step 10: Save H as the C.

Discussion
In Step 2, Step 3, and Step 4, the permutation phase that works on a bit-level was performed. According to the method of building a Hamiltonian path, two arrays were generated for grey value's substitution in Step 5, 6, and 7. The arrays were arrangements of integers from 0 to 255, in accordance with pixel's grey levels. As the arrays were randomly generated, there were 256! ≈ 8.578 × 10 506 possible arrangements. In this way, the modification of plain images could be amplified and transmitted in Step 8 and Step 9, causing an avalanche effect.

Decryption Algorithm
The decryption algorithm is the reverse progress of the encryption algorithm, as can be seen from Figure 11. In the encryption process, the substitution is realized by arrays S and T. The reverse operation of substitution needs the inverse map of S and T, which can be generated by Equation (9).
In the encryption process, the substitution is realized by arrays S and T. The reverse operation of substitution needs the inverse map of S and T, which can be generated by Equation (9).

Simulation Experiments
To check the performance of the proposed scheme, the results of simulation experiments were evaluated by several criteria in this section. Our experimental environment was a desktop PC with 64-bit Windows 10 OS, Intel i7-2600 CPU, and 8GB RAM. The programming language was C++, and the developing environments were Visual Studio 2019 and OpenCV 4.1.0. The test images were chosen from SIPI image database [25].

Secret Key Analysis
Secret key is an indispensable component of a cryptosystem. The key space is suggested to be no less than 2 100 [26]. The secret keys of the proposed scheme are parameters of ABM. In our simulation experiment, the data type of the keys was double precision floating point numbers. According to IEEE 754 standard, each key occupies 8 Bytes and owns significant digit of 52 bits. The structure of secret key is as shown in Figure 12, and the key space is bigger than 2 100 . In the formula, i = 255, 254, …, 2, 1, 0. The S' and T' are the inverse maps of S and T, respectively.

Simulation Experiments
To check the performance of the proposed scheme, the results of simulation experiments were evaluated by several criteria in this section. Our experimental environment was a desktop PC with 64-bit Windows 10 OS, Intel i7-2600 CPU, and 8GB RAM. The programming language was C++, and the developing environments were Visual Studio 2019 and OpenCV 4.1.0. The test images were chosen from SIPI image database [25].

Secret Key Analysis
Secret key is an indispensable component of a cryptosystem. The key space is suggested to be no less than 2 100 [26]. The secret keys of the proposed scheme are parameters of ABM. In our simulation experiment, the data type of the keys was double precision floating point numbers. According to IEEE 754 standard, each key occupies 8 Bytes and owns significant digit of 52 bits. The structure of secret key is as shown in Figure 12, and the key space is bigger than 2 100 . To examine the key sensitivity in the encryption process and decryption process, a strict test for bit change rate-NBCR (the number of bit change rate) [27]-was utilized: In the above formula, C1 and C2 are two images of size M × N and bit-depth d. Ham(C1,C2) represents the Hamming distance between C1 and C2; in other words, the number of different bits between the two images. The calculation results of NBCR should be close to 50%, which indicates that around 50% of the bits are different between C1 and C2.
In our work, three groups of modified keys were set as the illegal keys. These illegal keys are utilized to encrypt the plain images in the encryption process and decrypt the cipher images in the decryption process. The obtained encrypted images and decrypted images were made in comparison with the original plain images and cipher images. The NBCRs are listed in Table 2.  To examine the key sensitivity in the encryption process and decryption process, a strict test for bit change rate-NBCR (the number of bit change rate) [27]-was utilized: In the above formula, C 1 and C 2 are two images of size M × N and bit-depth d. Ham(C 1 ,C 2 ) represents the Hamming distance between C 1 and C 2 ; in other words, the number of different bits between the two images. The calculation results of NBCR should be close to 50%, which indicates that around 50% of the bits are different between C 1 and C 2 .
In our work, three groups of modified keys were set as the illegal keys. These illegal keys are utilized to encrypt the plain images in the encryption process and decrypt the cipher images in the decryption process. The obtained encrypted images and decrypted images were made in comparison with the original plain images and cipher images. The NBCRs are listed in Table 2.

Histograms
The histogram is the foundation of various spatial image processing techniques, e.g., image enhancement. Moreover, the inherent information of histograms is useful in image compression and segmentation. For an image of size M × N and bit-depth d, the histogram is a discrete function: Here i = 0, 1, 2, . . . , 2 d − 1, q i is the pixels' quantity of grey value r i . The variance of histogram can be calculated by Equation (12).
The µ h is the arithmetic mean value of q i . The histogram of a cipher image should be relatively uniform. After encryption, the variance of an image's histogram should be reduced. In Table 3, the variance of several images' histograms are listed. In practice, histograms are often normalized by Equation (13).
After normalization, p(r i ) represents the emergence probability of the ith grey value. The normalized histograms of plain images and cipher images are shown in Figure 13.
After normalization, p(ri) represents the emergence probability of the ith grey value. The normalized histograms of plain images and cipher images are shown in Figure 13.

Information Entropy
Information entropy was proposed by C. E. Shannon, which is a measurement of information's randomness. For a digital image, it is hard to predict the content if its information entropy is high. The calculation formula of information entropy is as shown in Equation (14). Here, the p(r i ) is identical to Equation (13).
The ideal value of a cipher image's information entropy is its bit-depth d. In Table 4, the information entropy of plain images and cipher images are listed.

Differential Attack
To resist differential attacks, tiny modification in plain images should cause massive changes in the cipher image. This is known as diffusion property in cryptography. NPCR (number of pixel change rate) and UACI (unified averaged changed intensity) are two common indicators for an algorithm's ability of resisting differential attacks [29]. If C 1 and C 2 are two images of size M × N and bit-depth d, then Here, In our experiment, the plain image boat of size 512 × 512 was utilized for evaluating the diffusion effect. Some pixels were chosen in the image, and the last bit of these pixels were reversed, respectively. Then, the modified images were encrypted. As can be seen from Table 5, the NPCRs and UACIs were close to theoretical values after two encryption rounds.

Correlation Coefficients
Plain images usually are redundant in the spatial domain, which means that adjacent pixels are highly correlated. Whereas, in cipher images, such a correlation should be broken. To measure the correlation between adjacent pixels, we calculated correlation coefficients as below: The x and y are pixel vectors of the same length. The µ x and µ y are their arithmetic mean values, and the σ x and σ y are their standard deviations. The range of correlation coefficients is [−1, 1]. If x and y are not correlated, r xy shall be close to 0.
Commonly, the adjacent pixels of three directions are calculated, respectively horizontal, vertical, and diagonal. Whereas, there exist two orthogonal diagonal directions in 2D matrices of pixels-the principal diagonal direction (from upper-left to lower-right) and the minor diagonal direction (from upper-right to lower-left). For instance, in a pixel block p 1 p 2 p 3 p 4 , p 1 and p 4 are adjacent in the principal diagonal direction, while p 2 and p 3 are adjacent in the minor diagonal direction. In the field of image encryption, the definition of diagonal direction is usually ambiguous. However, the two diagonal directions are nonequivalent for some image processing techniques and image encryption algorithms [30][31][32][33][34]. Under the extreme circumstances in Figures 14 and 15  For all the plain images and cipher images in our experiments, correlation coefficients of 10,000 adjacent pixel pairs in each of the four directions were calculated. The results are listed in Table 6. For all the plain images and cipher images in our experiments, correlation coefficients of 10,000 adjacent pixel pairs in each of the four directions were calculated. The results are listed in Table 6.

Efficiency
In the proposed scheme, bit-level permutation is performed in linear time complexity. Meanwhile, the diffusion phase is also linear. If the encrypted image is of size M × N, the algorithm's time complexity is O(MN). The time complexity of the algorithm in [4] is also O(MN). However, our bit-level scheme is slower than the pixel-level scheme of [4]. In [2], permutation was companied by sorting operation. Thus, the scheme's efficiency was related to the adopted sorting algorithm. In [28], the algorithm's time complexity is O (MN(M + N)). The comparison between these algorithms' efficiency is presented in Table 7.

Conclusions
In this paper, a 1D adjusted Bernoulli map is proposed, which is suitable for encryption systems. Based on the new chaotic map, an innovative image encryption algorithm was designed. The permutation phase was realized by generating a random Hamiltonian path, which was performed across different bit planes. Then, the idea of random Hamiltonian path was extended for substitution of grey levels in the diffusion phase. Various criterions indicate that our scheme had a pretty good performance. Besides, for measuring the correlation of adjacent pixels more reasonably, both the principal diagonal direction and the minor diagonal direction are involved when calculating correlation coefficients.