1 Introduction

In recent years, digital networks have evolved significantly and have become unavoidable for modern communication. The images transmitted on these networks are particular data because of their large amount of information. As a result, a lot of research has been done on these images to prevent access by illegal users and attackers. The purpose of image encryption (Es-Sabry et al. 2018a, b) is to convert the original image into another image that cannot be interpreted; it is essential that no one is able to decipher the image without the appropriate decryption key. It has been found that traditional encryption schemes are not suitable for image encryption due to the strong correlation between the pixels in the image as well as the data capacity which is huge; this is why algorithms like AES and DES are no longer used in this field, since the key space is not large enough which seriously affects the confidentiality of the information network, so they take a lot of time in computing phase.

Due to the good properties of chaotic encryption, such as sensitivity to initial conditions and system parameters, pseudo-random property, non-periodicity and topological transitivity, many chaos-based image encryption methods have recently been proposed and have been widely used in several fields such as biology (Lesne 2006), electrical engineering (Liu and Lu 2010), physics (Weidenmuller and Mitchell 2009) and complex networks (Lu et al. 2012), not to mention its easy implementation and speed, which makes it very useful for the communication of images in real time. Chaotic maps can be categorized into one-dimensional (1D) chaotic maps and high-dimensional (HD) chaotic maps. 1D chaotic maps usually contain one variable and some parameters, such as, the Gaussian, Logistic, Sinus and Tent maps. These maps are characterized by the simplicity of their structures and their chaotic orbits. With the development of chaotic signal estimation technologies, when little information is extracted, their chaotic orbits can be estimated (Arroyo et al. 2008; Ling et al. 1999) and their parameters and initial values can be predicted (Wu et al. 2004). These weaknesses limit their applications in many fields of security. For example, when 1D chaotic maps are used in image encryption, several encryption algorithms have been reported as unsecured (Arroyo et al. 2008; Skrobek 2007).

Compared to 1D chaotic maps, HD chaotic maps usually have more complex structures and better chaotic performance. These make their chaotic orbits much more difficult to predict. However, their hardware implementations are relatively complex and expensive. Therefore, developing a chaotic map with excellent chaotic performance and a low implementation cost becomes significative.

On the other hand, there is another encryption system based on the random generation of numbers such as:

  • True random number generators (TRNGs).

  • Pseudo-random number generators (PRNGs).

  • Chaotic random number generators (CRNGs).

The first category (TRNGs) is based on the use of unpredictable and non-deterministic sources such as natural processes or physical phenomena, so it is impossible to predict the next number, knowing that the previous numbers are known. For this reason, TRNGs are particularly useful in cryptography and especially in the production of keys. The second category (PRNGs) is the algorithmic generators of numbers that have the appearance of random but with periodic digit sequences, nevertheless, their results are predictable. Good random number generators produce very long sequences that seem random, in the sense that no efficient algorithm can guess the next number according to the prefix of the sequence. The third category (CRNGs) is based on the chaotic phenomenon; it is a multiparametric system; these parameters must be refined to improve its performances, although they are periodic but by applying spatiotemporal techniques, their period can last several years, so practically inaccessible.

The authors, in Zhang et al. 2005, use a discrete exponential chaotic map in order to permute the images pixels; after that, they use the exclusive OR (XOR) operation in time domain. In Li et al. 2009, a new image encryption scheme was proposed using two chaotic logistic maps which were used with an external secret key of 80 bits. The scheme updates the secret key after encrypting each block of image pixels. The authors suggested in Fridrich 1997, a chaotic image encryption method in time domain. All the pixels are moved using a 2D chaotic map and their values are altered sequentially. In Hwang et al. 2007, the authors proposed an image copyright protection scheme using the computational integral imaging (CII) technique, in which the 3D watermark information is embedded into the DWT domain. The 3D watermark plain image can be reconstructed using a CIIR technique. This scheme is highly robust because of the data redundancy of the elemental images. However, in the watermark extraction process, CIIR is a pixel superposition reconstruction method. The resolution of the reconstructed 3D plain image is dramatically degraded as the magnification factor increases. In Wang et al. 2006, the authors proposed a fully digital encryption system based on extended Fractal Fourier Transform (FRT) and digital holography technique. The parameters of the extended FRT gave an enhancement on security compared with the conventional FRT. The input image was extended fractional Fourier transformed two times and encrypted by use of a random phase mask in the extended FRT encryption system. By use of an interference with a wave from another phase mask, the data were encrypted again and recorded as a digital hologram. The decryption key could also be recorded as the key hologram as described in the following section. The parameters, the random phase code and the key hologram form the keys to the encrypted image. The authors developed in Piao et al. 2009, an image encryption scheme based on integral imaging and pixel scrambling techniques. In the scheme, the input image is first recorded using the CII technique and the obtained elemental images are scrambled by a pixel scrambling technique. In the reconstruction process, the image is reconstructed by the CIIR technique. This method is a highly secure and robust encoding system. However, it incurs resolution degradation problems. The authors in Singh and Sinha 2008 proposed a method for image encryption using Fractal Fourier Transform (FRT) and chaos. The image to be encrypted was FRT two times, and the random phase masks generated using chaos functions were placed in the intermediate planes. The chaos functions had been used to generate the chaotic random phase masks (CRPM). The comparison of the mean square errors (MSE) and signal-to-noise ratio (SNR) between the decrypted image and the input image for correct order of FRT and incorrect order of FRT using these chaos functions had been done.

The rest of this work is organized as follows: The second part presents the proposed method. The experimental results and the analysis of the performance of the method are covered in the third part. In the last part, a conclusion of this work is presented.

1.1 Proposed method

Our method is based on use of two 16 × 16 matrices which will be used to encrypt the original image. Each matrix is composed of different values between 0 and 255 and is generated randomly except for the first value of the first matrix which is calculated from the three channels (red, green and blue) of the original image (Fig. 1). Figure 2 represent a flowchart that shows the different steps to encrypt a color image (Fig. 3).

Fig. 1
figure 1

16 × 16 matrix containing values between 0 and 255

Fig. 2
figure 2

Proposed method flowchart

Fig. 3
figure 3

Decomposition of the color image on three channels and extraction of the decimal matrices

The encryption operation of the color image requires to encrypt each image extracted from the three channels and then merge them, which will give us an encrypted color image at the output.

Given a color image to be encrypted, the first step is to decompose the color image into three channels, red channel, green channel and blue channel; then, we will extract the decimal value matrix for each channel (Fig. 3); these values are between 0 and 255; for each channel, we will calculate the sum of all pixels modulo 255; then, we will use the floor function to extract the greatest integer less than or equal the average of the values obtained; the result will be an integer between 0 and 255; after that, we will put this value in the first cell of the first matrix, the rest of the cells of the matrix will be filled by different values generated randomly between 0 and 255. The same procedure will be applied for all the cells of the second matrix.

The calculation of the first cell of the first matrix according to the pixels of the original image will be justified in the experimentation part.

Figure 3 shows an example of 16 pixels matrix extracted from a 256 × 256 color image after decomposing it into three channels.

After performing the generation operation of the two matrices, decomposing the color image into three channels and extracting the decimal values matrix for each channel, we proceed to the encryption operation.

The values of each matrix are encrypted by digraph (two-digit sequence). For example, if we want to encrypt the digraph . We look for the number in the matrix 1, the number in the matrix 2, and then we look in these matrices for the numbers that complete the rectangle; in our example, Fig. 4, the number located in the matrix 1 and the number located in the matrix 2. The digraph is encrypted in digraph , because by convention, one of the two encrypted digits is on the same column as the digit of the original matrix. If both digits are in the same column, their inversion form will be the encrypted digraph. For example, becomes (Fig. 5).

Fig. 4
figure 4

Encryption operation of the digraph located in different columns

Fig. 5
figure 5

Encryption operation of the digraph located in the same columns

The problem is that this method is vulnerable to cryptanalytic attacks; each digraph has only one form of encryption (Fig. 6), which will greatly reduce the number of tests of a cryptanalytic brute force attack based on frequency analysis of digraphs.

Fig. 6
figure 6

Encryption operation of a 4 × 4 matrix

In the example, we applied our method on the 16 pixels extracted from the red channel of the example (Fig. 3); if we analyze the results obtained, we note that the digraph is repeated three times and digraph repeats itself twice. So, with a cryptanalytic brute force attack based on the frequency analysis of the digraphs, we will obtain the following results (Table 1).

Table 1 Results obtained for each type of attack

The results obtained in the table are calculated as follows:

We have a 4 × 4 size matrix that contains integers between 0 and 255; so the matrix contains 16 cells; each cell can take 256 values, and therefore a brute force attack will test 25616 possibilities at worst case to find the original matrix; however, if we take into account the repeated digraphs, we will eliminate them since they will take the same value as that of the first occurrence, so an attack of brute force cryptanalytic will test 25610 possibilities; these results show that there is a large difference in the number of possibilities between an attack of the brute force and a brute force cryptanalytic attack based on the frequency analysis of the digraphs. So, to make our method invulnerable for this type of attack, we will add a second phase of encryption based on the use of right circular shift of the binary matrix of the decimal values matrix obtained from the first phase of encryption; these values are encoded on 8 bits. The number of bits needed to make the circular shift must follow the following formula:

$$ N\left( X \right) = \left( {K_{1} + K_{2} + i\left( X \right) + j\left( X \right)} \right) mod\, 8 $$
(1)

With \( N \) is a function that calculates the number of bits needed to make the rotation, \( X \) represents a binary value, \( i \) and \( j \) are two functions that return, respectively, the row and column index of the \( X \) value, \( K_{1} \) and \( K_{2} \) are calculated from the 16 × 16 encryption matrices, and they are extremely important since any changes made at the keys (two matrices) will completely change the encrypted image. These values are calculated from the following formulas.

$$ K_{1} = \left( {\mathop \sum \limits_{i = 0}^{15} \mathop \sum \limits_{j = 0}^{15} M_{ij}^{1} \times \left( {i + j} \right)} \right) mod\; 8 $$
(2)
$$ K_{2} = \left( {\mathop \sum \limits_{i = 0}^{15} \mathop \sum \limits_{j = 0}^{15} M_{ij}^{2} \times \left( {i + j} \right)} \right) mod\; 8 $$
(3)

With \( M_{ij}^{1} \), the value of the ith line and the jth column of the first matrix, and \( M_{ij}^{2} \) the value of the ith line and the jth column of the second matrix.

In Fig. 7, we applied the second encryption phase based on the right circular shift of the bits with \( K_{1} = 1 \) and \( K_{2} = 6 \); these values are obtained by applying Eqs. (2) and (3) on the matrices of Fig. 4. We note that the digraph which was repeated three times before this phase has no longer the same encrypted form at the output and the same for the digraph ; therefore, any cryptanalytic attack based on the frequency analysis of the digraphs will no longer have any influence on the image decryption.

Fig. 7
figure 7

Right circular shift of a 4 × 4 matrix

2 Experimental results and performance analysis

To say that an encryption system is good, it must resist most attacks that exist in the field such as statistical attacks, differential attacks as well as different attacks of brute force; that is why, we have measured the strength of our proposed method and its resistance against the various attacks mentioned above.

To do this, we took eight color images with different sizes (256 × 256, 512 × 512 and 1024 × 1024); we applied our own encryption system on these images using java programming language.

The performance of our proposed algorithm is justified based on several criteria which will be explained at length in the next sections as well as the comparison with other methods.

2.1 Histogram analysis

The first criterion consists in analyzing histograms of the original color images and those images encrypted with our own algorithm and make a comparison between them in terms of the distribution of the pixels for each channel (red, green and blue).

From Figs. 8, 9, 10, 11, 12, 13, 14, 15 and 16 it is noted that not only the encrypted images histograms are completely different from those of the original images, but also the pixels distribution is almost uniform; hence, our method can resist any statistical attacks and finally increases the protection of the information included in the images.

Fig. 8
figure 8

a0 Lena image, a1 Red histogram of Lena image, a2 Green histogram of Lena image, a3 Blue histogram of Lena image, a4 Encrypted Lena image, a5 Red histogram of encrypted Lena image, a6 Green histogram of encrypted Lena image, a7 Blue histogram of encrypted Lena image (color figure online)

Fig. 9
figure 9

b0 Baboon image, b1 Red histogram of Baboon image, b2 Green histogram of Baboon image, b3 Blue histogram of Baboon image, b4 Encrypted Baboon image, b5 Red histogram of encrypted Baboon image, b6 Green histogram of encrypted Baboon image, b7 Blue histogram of encrypted Baboon image (color figure online)

Fig. 10
figure 10

c0 Fruits image, c1 Red histogram of Fruits image, c2 Green histogram of Fruits image, c3 Blue histogram of Fruits image, c4 Encrypted Fruits image, c5 Red histogram of encrypted Fruits image, c6 Green histogram of encrypted Fruits image, c7 Blue histogram of encrypted Fruits image (color figure online)

Fig. 11
figure 11

d0 Airplane image, d1 Red histogram of Airplane image, d2 Green histogram of Airplane image, d3 Blue histogram of Airplane image, d4 Encrypted Airplane image, d5 Red histogram of encrypted Airplane image, d6 Green histogram of encrypted Airplane image, d7 Blue histogram of encrypted Airplane image (color figure online)

Fig. 12
figure 12

e0 Bird image, e1 Red histogram of Bird image, e2 Green histogram of Bird image, e3 Blue histogram of Bird image, e4 Encrypted Bird image, e5 Red histogram of encrypted Bird image, e6 Green histogram of encrypted Bird image, e7 Blue histogram of encrypted Bird image (color figure online)

Fig. 13
figure 13

f0 Lake image, f1 Red histogram of Lake image, f2 Green histogram of Lake image, f3 Blue histogram of Lake image, f4 Encrypted Lake image, f5 Red histogram of encrypted Lake image, f6 Green histogram of encrypted Lake image, f7 Blue histogram of encrypted Lake image (color figure online)

Fig. 14
figure 14

g0 Mountain image, g1 Red histogram of Mountain image, g2 Green histogram of Mountain image, g3 Blue histogram of Mountain image, g4 Encrypted Mountain image, g5 Red histogram of encrypted Mountain image, g6 Green histogram of encrypted Mountain image, g7 Blue histogram of encrypted Mountain image (color figure online)

Fig. 15
figure 15

h0 Flowers image, h1 Red histogram of Flowers image, h2 Green histogram of Flowers image, h3 Blue histogram of Flowers image, h4 Encrypted Flowers image, h5 Red histogram of encrypted Flowers image, h6 Green histogram of encrypted Flowers image, h7 Blue histogram of encrypted Flowers image (color figure online)

Fig. 16
figure 16

n0 Train image, n1 Red histogram of Train image, n2 Green histogram of Train image, n3 Blue histogram of Train image, n4 Encrypted Train image, n5 Red histogram of encrypted Train image, n6 Green histogram of encrypted Train image, n7 Blue histogram of encrypted Train image (color figure online)

2.2 Correlation analysis of two adjacent pixels

The correlation coefficient of adjacent pixels is an important internal information of the image; the statistical attacks use this kind of information to decrypt images; therefore, a good encryption system must get rid of this information by minimizing the correlation coefficient as much as possible.

To do this, we took 5000 pairs of randomly selected adjacent pixels from the original image and the encrypted image along three directions (horizontal, vertical and diagonal) for each of the three channels (red, green and blue).

In this test, the calculation is applied to the images of Figs. 8, 9, 10 and 11 using the following equations:

$$ r_{xy} = \frac{{Cov\left( {x,y} \right)}}{{\sqrt {D_{x} } \sqrt {D_{y} } }} $$
(4)
$$ Cov\left( {x,y} \right) = \frac{1}{N}\mathop \sum \limits_{i = 1}^{N} \left( {x_{i} - E_{x} } \right)\left( {y_{i} - E_{y} } \right) $$
(5)
$$ D_{x} = \frac{1}{N}\mathop \sum \limits_{i = 1}^{N} \left( {x_{i} - E_{x} } \right)^{2} $$
(6)
$$ E_{x} = \frac{1}{N}\mathop \sum \limits_{i = 1}^{N} x_{i} $$
(7)

With \( N \) represents the number of pixels of the original image.

The table below shows the results obtained after calculating the correlation coefficient; Figs. 17, 18 and 19 show the correlation distribution of the pairs of adjacent pixels in the three channels (red, green and blue) and following the three directions (horizontal, vertical and diagonal).

Fig. 17
figure 17

Pixels distribution in the horizontal direction of Lena image: i0 Original red channel, i1 Original green channel, i2 Original blue channel, i3 Encrypted red channel, i4 Encrypted green channel, i5 Encrypted blue channel (color figure online)

Fig. 18
figure 18

Pixels distribution in the vertical direction of Lena image: j0 Original red channel, j1 Original green channel, j2 Original blue channel, j3 Encrypted red channel, j4 Encrypted green channel, j5 Encrypted blue channel (color figure online)

Fig. 19
figure 19

Pixels distribution in the diagonal direction of Lena image: k0 Original red channel, k1 Original green channel, k2 Original blue channel, k3 Encrypted red channel, k4 Encrypted green channel, k5 Encrypted blue channel (color figure online)

We note that the correlation coefficient (CC) in the three channels (red, green and blue) including the three directions (horizontal, vertical and diagonal) takes values close to 1 in the case of original images. On the other hand, it takes values close to 0 in the case of encrypted images, which means that the degree of dependence between the two adjacent pixels is very strong before the application of our method, and this dependence is destroyed after having applied our encryption method (Table 2).

Table 2 Correlation coefficient of original images and encrypted images

Figures 17, 18 and 19 show the distribution of pixels in three channels (red, green and blue) and following three directions (horizontal, vertical and diagonal) of the Lena image. We can see that the distribution before the application of our method follows a line, which shows that the correlation is strong between the pixels. On the other hand, this correlation becomes weak after applying our approach, which means that the proposed method gives good results. The figures show that the pixels are scattered everywhere.

Table 3 represents the correlation coefficients (CC) obtained by our approach compared with method of Tong et al. (2009), method of Borujeni and Eshghi (2011), method of Wang and Guo (2014), method of Hua (Hua et al. 2015) and method of Tong et al. (2015).

Table 3 CC comparison of two adjacent pixels of our method with other methods

Since we worked on three channels (red, green and blue), we took the average for each channel following each direction (horizontal, vertical and diagonal); these values are calculated by applying our method on Lena image (Fig. 8).

The results show that the correlation existing between the adjacent pixels has been destroyed by our algorithm, which shows the performance of our approach compared to other methods.

2.3 Correlations between original and encrypted images

After having made the visual test by analyzing the histograms of original images and encrypted images for each channel (red, green and blue) and after calculating the correlation coefficient of two adjacent pixels, we will now calculate the correlation coefficient (CC) for each channel of the original image with that of the encrypted image by applying the following formula:

$$ {\text{CC}} = \frac{{\mathop \sum \nolimits_{i = 1}^{M} \mathop \sum \nolimits_{j = 1}^{N} \left( {A_{ij} - \bar{A}} \right)\left( {B_{ij} - \bar{B}} \right)}}{{\sqrt {\mathop \sum \nolimits_{i = 1}^{M} \mathop \sum \nolimits_{j = 1}^{N} \left( {A_{ij} - \bar{A}} \right)^{2} } \sqrt {\mathop \sum \nolimits_{i = 1}^{M} \mathop \sum \nolimits_{j = 1}^{N} \left( {B_{ij} - \bar{B}} \right)^{2} } }} $$
(8)
$$ \bar{A} = \frac{1}{M \times N}\mathop \sum \limits_{i = 1}^{M} \mathop \sum \limits_{j = 1}^{N} A_{ij} $$
(9)
$$ \bar{B} = \frac{1}{M \times N}\mathop \sum \limits_{i = 1}^{M} \mathop \sum \limits_{j = 1}^{N} B_{ij} $$
(10)

Where \( A \) represents the original image, \( B \) represents the encrypted image, \( \bar{A} \) and \( \bar{B} \) represent, respectively, the mean values of the elements of matrices \( A \) and \( B \), \( M \) and \( N \) represent, respectively, the height and the width of matrices \( A \) and \( B \).

Table 4 shows the different values obtained after calculating the correlation coefficient (CC) for each channel (red, green and blue) using Figs. 8, 9, 10, 11, 12, 13, 14 and 15; the fifth column contains the average value of the three channels for each image; this value is compared later with the value obtained by the Zhu method (Zhu 2012).

Table 4 CC comparison of our method with ZHU method

The results show the performance of our method in terms of the correlation between the original image and the encrypted image since the values are very close to 0; these values are better than those obtained by the Zhu method.

2.4 Resistance to differential attack

Sometimes the attackers just make a small change at a pixel of the original image to see the effect of this change on the encrypted image; a good encryption system must take into account these changes; after the change made, the encrypted image must be widely different than the other one before the change. To analyze the resistance of our approach against this type of attack, we measured the number of pixels changed by calculating the NPCR (Number of Changing Pixel Rate) and the UACI (Unified Averaged Changed Intensity) by applying the following formulas:

$$ {\text{NPCR}} = \frac{1}{M \times N}\mathop \sum \limits_{i = 1}^{M} \mathop \sum \limits_{j = 1}^{N} D\left( {i, j} \right) \times 100\% $$
(11)
$$ {\text{UACI}} = \frac{1}{M \times N}\mathop \sum \limits_{i = 1}^{M} \mathop \sum \limits_{j = 1}^{N} \frac{{\left| {C_{1} \left( {i,j} \right) - C_{2} \left( {i,j} \right)} \right|}}{255} \times 100\% $$
(12)
$$ D\left( {i, j} \right) = \left\{ {\begin{array}{*{20}c} {\begin{array}{*{20}c} {0,} & {if\, C_{1} \left( {i,j} \right) = C_{2} \left( {i,j} \right)} \\ \end{array} } \\ {\begin{array}{*{20}c} {1,} & {if\, C_{1} \left( {i,j} \right) \ne C_{2} \left( {i,j} \right)} \\ \end{array} } \\ \end{array} } \right. $$
(13)

With \( M \) and \( N \), respectively, representing the height and width of the encrypted image, \( C_{1} \) and \( C_{2} \) are the encrypted images with a small difference at one pixel for each channel (red, green and blue) of the original image. To say that our approach is resistant to differential attacks, the NPCR and UACI measures must be large enough. Table 5 shows the values obtained by applying our approach on Lena image and Baboon image and compared them with those obtained by the Norouzi method (Norouzi et al. 2013) and Tong method (Tong et al. 2015).

Table 5 Sensitivity of our proposed method for a single pixel change of the original image

To say that a method is resistant against differential attacks, the values of NPCR and UACI must be, respectively, greater than 99.6% and 33.4%; these values are justified (Es-Sabry et al. 2018b) by Eqs. (14) and (15).

$$ {\text{NPCR}}_{E} = \left( {1 - 2^{ - n} } \right) \times 100\% $$
(14)
$$ {\text{UACI}}_{E} = \frac{1}{{2^{2n} }}\frac{{\mathop \sum \nolimits_{i = 1}^{{2^{n} - 1}} i\left( {i + 1} \right)}}{{2^{n} - 1}} \times 100\% $$
(15)

Where \( n \) represent the number of bits needed to encode a pixel, which is coded on 8 bits, since the calculation is done for each channel (red, green and blue). And therefore, \( {\text{NPCR}}_{E} = 99.6094\% \) and \( {\text{UACI}}_{E} = 33.4635\% \).

The same thing for the key, if a small change made in the key (Matrix1, Matrix2), that will completely change the encrypted image; so we can say that the encryption system is sensitive to the change of the key. In our case, we used the Lena image with size of 256 × 256, and it was encrypted with the two keys (Matrix1, Matrix2) (Fig. 4). Then, we took the first matrix and we switched the last two values located at the right bottom of our matrix (2, 81); then, we encrypted the Lena image with the new keys (Matrix3 which is Matrix1 modified and Matrix2).

After calculating the NPCR and UACI measurements, we notice that the results obtained by our method are good (Table 6) and better than those obtained by Tong et al. (2015), which means our method is more efficient than Thong method.

Table 6 Sensitivity of our proposed method for a single pixel change of one of the keys

Figure 20 shows the decryption result of the Lena image with the initial key (Matrix1, Matrix2) and with the modified key (Matrix3, Matrix2). After making a small change at a single pixel of Matrix1, we notice that the decryption operation failed completely.

Fig. 20
figure 20

l0 Lena image, l1 Encryption of Lena Image with key (Matrix1, Matrix2), l2 Decryption of Lena Image with key (Matrix1, Matrix2), l3 Decryption of Lena Image with key (Matrix3, Matrix2) (color figure online)

2.5 Entropy analysis

Entropy is one of the most notable features for measuring the randomness of the image encryption algorithm. To calculate entropy information, we use the following formula.

$$ H\left( s \right) = \mathop \sum \limits_{i = 0}^{{2^{n} - 1}} P\left( {s_{i} } \right)\log_{2} \left[ {P\left( {s_{i} } \right)} \right] $$
(16)

With \( P\left( {s_{i} } \right) \) is the probability of occurrence for each \( s_{i} \), \( 2^{n} \) is the total number of states of the information source. For a perfect random information source with \( 2^{n} \) states, the entropy should be equal to \( n \).

In our case, the computation is done for each channel (red, green and blue), so the number of states is \( 2^{n} = 256 \), and consequently an ideal entropy is \( n = 8 \).

Table 7 shows the different entropy values obtained for each of Figs. 8, 9, 10 and 11. These values are very close to the ideal value 8, which means that our method is resistant against the entropy attacks.

Table 7 Parameters of the encryption and decryption quality

2.6 MSE and peak signal-to-noise ratio analysis

The last two parameters to evaluate the reliability of our algorithm are the MSE (Mean Square Error) and the PSNR (Peak Signal-to-Noise Ratio). The first criterion (MSE) gives the margin of error between the original image and the encrypted image and is calculated using the following formula.

$$ {\text{MSE}} = \frac{1}{M \times N}\mathop \sum \limits_{i = 1}^{M} \mathop \sum \limits_{j = 1}^{N} \left( {A_{ij} - B_{ij} } \right)^{2} $$
(17)

With \( A \) represents the original image, \( B \) represents the encrypted image, \( M \) and \( N \), respectively, represent the height and width of the images \( A \) and \( B \). The security of the encrypted image increases with an increase in the MSE value.

The encrypted image quality is evaluated using the second criterion (PSNR), which is calculated using the following formula.

$$ {\text{PSNR}} = 10 \times \log_{10} \left( {\frac{{I_{\text{Max}}^{2} }}{\text{MSE}}} \right) $$
(18)

Where \( I_{\text{Max}} \) represents the maximum value of a pixel of the image. The PSNR value should be small, which means a big difference between the original image and the encrypted image.

The calculations are made for the four images in Figs. 8, 9, 10 and 11. Table 7 represents the values obtained for each channel (red, green and blue). From the results presented in this table, we notice that the values of the MSE are very large. On the other hand, the PSNR values are very small. So, we can say that our approach gives good results, which shows that the encrypted image is well secured.

After performing the decryption operation, the calculations were made again to evaluate the decryption quality by also calculating the CC (Correlation Coefficient) for each image and for each channel (red, green and blue). The MSE is 0, the CC is 1 and the PSNR tends to infinity (Table 7), which means that the decrypted image and the original image are identical. Therefore, we can conclude that our method gives a high precision.

3 Conclusion

In this paper, we proposed a new method that encrypts color images in a very secure way. The method is based on the random numbers generation of two matrices with size of 16 × 16 containing different integers between 0 and 255. Then, we applied a right circular shift according to a function that takes into account the values of the two matrices as well as their position (row and column), the original image pixels and the keys values. The resistance of our method against statistical attacks, differential attacks and entropy attack has been proved. Our method has great sensitivity in terms of a single pixel change of the original image as well as the values of one of the two keys; the NPCR and UACI measurements justify this sensitivity. The decryption operation is similar in a reverse manner to that of encryption; the decryption quality is perfect and is justified by the measures of CC, MSE and PSNR.