1 Introduction

With the development of multimedia information technology, information security issues are gradually put on the agenda. The image is one of the important tools of carrying information, it has been widely studied. The classic image processing is a relatively mature discipline. The study of quantum image processing begins with the establishment of the form of quantum image representation. For the classic image processing, the relevant technologies (e.g., image encryption, image geometric transformation, image enhancement, image compression) have developed quite mature [114]. Many classic image processing problems, such as image transformation, image security, are built on the basis of the representation of an image. Similarly, quantum image processing also needs to select a reasonable representation and storage method. At present, there is no uniform or universally accepted definition about the representation of quantum image. Existing representation basically draws on the classic image description method. That is, how to encode the pixel’s gray (color) and position, and describe it into a quantum superposition state.

In terms of quantum image representation, Yan et al. [29] has made a detailed analysis of the existing methods. At present, the main quantum image representation are as follows: (1) Quantum image representation based on Qubit Lattice [1517]. In this method, according to the different wavelength of the electromagnetic wave, the monochromatic electromagnetic wave is geometrically mapped and stored in the quantum state. (2) Quantum image representation based on quantum entanglement [18]. This method makes the corresponding pixels in the image by quantum entanglement. However, this method can only store and process the binary image, which limits the application of this method. (3) Flexible Representation of Quantum Images (FRQI) [1922]. In this method, the gray level and the position of the pixels are expressed as a normalized quantum superposition state, and a method for making such a quantum state is given. However, this method can only describe the monochrome gray level image. When describing a color image, need to use three qubits stored three color gray-scale information. (4) NEQR (novel enhanced quantum representation) [23]. By using this method, some classical image processing algorithms can be easily extended to quantum images. For these models, only in NEQR, the pixel color values are represented as basic state of qubits, rather than the probability amplitude of basic state, which eliminates the influence of measurement process and is currently the most ideal quantum image representing method. In addition, the video signal is another type of digital signal different from the digital image, and Yan et al. [30] gives the coding method of the video signal, which further enriches the emerging research field of quantum information processing.

Quantum image encryption is one of the important branches of quantum image processing. In an encryption scheme, the data are encrypted and transmitted by the sender in public environment, and it only can be decrypted by the designated receiver with the decryption key. Although the secret information can be detected by the attacker, he/she has no way to get it. As the quantum counterpart of classical encryption schemes, quantum image encryption has been developed rapidly in recent years. However, so far, the literatures in this direction are still relatively scarce. Based on quantum image geometric transformations, Zhou et al. [24] presented a quantum image encryption scheme. However, this encryption method does not follow the principle of quantum mechanics. In [25, 26], Yang et al. deeply studies the problem of quantum image encryption, and proposed an encryption scheme that can be run on future quantum computer. In Yang’s approach, the color information of each pixel is encoded by three qubits |r〉, |g〉, |b〉 that represent three primary colors of red, green, blue, respectively. However, the color values of the pixels are encoded with probability amplitude of qubits. By the influence of quantum states collapse, during the measurement, this method is difficult to obtain accurate pixel values. In view of this, we propose an novel color image encryption method. In our scheme, we use the NEQR model to represent the color image, in which 24 qubits are employed to represent the pixel gray scale values of each pixel. The encryption process is achieved by employing the controlled rotation gates. In the encrypted image, the color value of each pixel is a balanced superposition of 224 basic states. After measuring, the whole image is an uniform white noise, which does not provide any information. Although the encryption process is very simple, but the encryption effect is ideal.

The rest of this paper is organized as follows. The next section introduces the NEQR model, and then the represent and encryption method of color image are given in Section 2. In Section 3, we simply introduce the measurement of quantum image. In Section 4, we present the simulation results on the classical computer. Finally, a short conclusion is given in Section 5.

2 Novel Enhanced Quantum Representation (NEQR)

The NEQR have been proposed in [23]. While the FRQI encodes a gray-scale value of 8 bits in 1 qubit, the NEQR represents it in a binary string of 8 qubits. In the NEQR representation, the gray-scale image f(Y, X) with n × n pixels is expressed by the following equation.

$$\begin{array}{@{}rcl@{}} |I\rangle=\frac{1}{2^{n}}\sum\limits_{Y=0}^{2^{n}-1}\sum\limits_{X=0}^{2^{n}-1}|f(Y,X)\rangle|YX\rangle =\frac{1}{2^{n}}\sum\limits_{Y=0}^{2^{n}-1}\sum\limits_{X=0}^{2^{n}-1}\bigotimes\limits_{i=0}^{q-1}|C_{YX}^{i}\rangle|YX\rangle, \end{array} $$
(1)

where \(f(Y,X)=C_{YX}^{0}C_{YX}^{1}{\cdots } C_{YX}^{q-1}\), \(C_{YX}^{k}\in \{0,1\}, f(Y,X)\in \{0,1,\cdots ,2^{q-1}\}\).

In order to explain this scheme in detail, we use a small image with 2 × 2 pixels in Fig. 1 as an example image, and the following equation shows its NEQR representation, where the range of gray scale is from 0 to 255.

$$\begin{array}{@{}rcl@{}} \begin{array}{lcl} |I\rangle&=&0.5(|(0)_{\text{dec}}\rangle|00\rangle+|(100)_{\text{dec}}\rangle|01\rangle+|(200)_{\text{dec}}\rangle|10\rangle+|(255)_{\text{dec}}\rangle|11\rangle)\\ &=&0.5|(00000000)_{\text{bin}}\rangle|00\rangle+0.5|(01100100)_{\text{bin}}\rangle|01\rangle\\ &+&0.5|(11001000)_{\text{bin}}\rangle|10\rangle+0.5|(11111111)_{\text{bin}}\rangle|11\rangle. \end{array} \end{array} $$
(2)
Fig. 1
figure 1

2 × 2, 256-level image and its NEQR representation

3 Quantum Encryption Scheme for Color Image

As mentioned earlier, for a 2n × 2n image of the gray range of 0 ∼ 2q − 1, the q + 2n qubits are needed to represent it by NEQR. For a color image of gray scale range 0 ∼ 28 − 1, each primary color (R or G or B) needs 8 qubits. Therefore, for a 2n × 2n color image of gray scale range 0 ∼ 28 − 1, 24 + 2n qubits are need to represent it by NEQR. The specific implementation scheme of quantum encryption algorithm for color image is described as follows.

3.1 Preparation of NEQR-Based Quantum Image

First, we need to prepare 24 + 2n qubits in the state of |0〉. The tensor product of these 24 qubits is written as |0〉⊗(24+2n). Suppose that the binary number of the R,G,B values of pixel P(Y, X) is written as

$$\begin{array}{@{}rcl@{}} \begin{array}{lll} f(Y\!,\!X)&=&C_{Y\!\!X}^{R0}\!\cdots\!C_{Y\!\!X}^{R7}C_{Y\!\!X}^{G0}\!\cdots\!C_{Y\!\!X}^{G7}C_{Y\!\!X}^{B0}\!\cdots\!C_{Y\!\!X}^{B7}\\ &=&C_{Y\!\!X}^{0}\!\cdots\!C_{Y\!\!X}^{7}C_{Y\!\!X}^{8}\!\cdots\!C_{Y\!\!X}^{15}\!C_{Y\!\!X}^{16}\!\!\cdots\!C_{Y\!\!X}^{23}, \end{array} \end{array} $$
(3)

where \(C_{YX}^{i}\in \{0,1\}\), i = 0, 1, ⋯ , 23.

In NEQR, an important operator is U Y X , and the main work of U Y X is Ω Y X . This operator converts the R,G,B values of pixel P(Y, X) to quantum state |f(Y, X)〉 as shown in following equation, and its corresponding quantum circuit is shown in Fig. 2.

$$\begin{array}{@{}rcl@{}} {\Omega}_{YX}|0\rangle^{\otimes24}\,=\,\otimes_{i=0}^{23}({\Omega}_{YX}^{i}|0\rangle)\,=\,\otimes_{i=0}^{23}|0\oplus C_{YX}^{i}\rangle\,=\,\otimes_{i=0}^{23}|C_{YX}^{i}\rangle\,=\,|f(Y,X)\rangle. \end{array} $$
(4)
Fig. 2
figure 2

The black-box circuit of quantum operation Ω Y X , which transforms color value f(Y, X) into the quantum state |f(Y, X)〉 as in (4)

According to NEQR representation, a 2n × 2n color image can be described as follows.

$$\begin{array}{@{}rcl@{}} |{\Psi}_{0}\rangle=\frac{1}{2^{n}}\sum\limits_{Y=0}^{2^{n}-1}\sum\limits_{X=0}^{2^{n}-1}|f(Y,X)\rangle|YX\rangle =\frac{1}{2^{n}}\sum\limits_{Y=0}^{2^{n}-1}\sum\limits_{X=0}^{2^{n}-1}\otimes_{i=0}^{23}|C_{YX}^{i}\rangle|YX\rangle. \end{array} $$
(5)

Next, taking a 2 × 2 color image in Fig. 3 as an example, we introduce the specific implementation methods of NEQR image. In Fig. 3, the R,G,B values of the 4 pixels are: f(00)= [0,128,128], f(01)= [128,0,128], f(10)= [128,128,0], f(11)= [128,128,128]. To facilitate the description of the physical implementation of quantum image, we first introduce the concept of the quantum NOT gate and the controlled-NOT gate.

Fig. 3
figure 3

A color image of size of 2 × 2

Quantum NOT gate is a single qubit gate, it can be describe by the matrix \(X=\left (\begin {array}{cc}0~~&~~1\\1~~&~~0 \end {array}\right )\). This gate’s role in a single qubit is to flip the state of the qubit, namely, X|0〉 = |1〉, X|1〉 = |0〉. The controlled-NOT gate is a multi-qubits gate, the corresponding quantum circuits is shown in Fig. 4.

Fig. 4
figure 4

Quantum circuit of controlled-NOT gate

In Fig. 4, the first n qubits of |x 1〉, |x 2〉, ⋯, |x n 〉 are the control qubits, and the last one |φ〉 is the target qubit. The notation “⊕” on the |φ〉 denotes the quantum NOT gate. The notation “∙” on the control qubits indicates that the target qubit |φ〉 is controlled by this control qubit only when it lives in state |1〉. Similar, the notation “∘” on the control qubits indicates that the target qubit |φ〉 is controlled by this control qubit only when it lives in state |0〉. When and only when all control bits are satisfied with the control condition, the target qubit |φ〉 is flipped by quantum NOT gate [27].

As a matter of fact, the NEQR representation provides the interface of the color image from the classical domain to the quantum domain. Next, in order to explain the concrete realization method of a NEQR-based color image, taking the 2 × 2 color image in Fig. 3 as an example, the quantum circuit of transforming a classical image into a NEQR-based quantum image is given in Fig. 5.

Fig. 5
figure 5

Quantum circuit of transforming the classical image into the corresponding quantum version

In Fig. 5, |Ψ0〉 = |0〉⊗26, the |Ψ1〉 and the |Ψ2〉 are written as

$$\begin{array}{@{}rcl@{}} |{\Psi}_{1}\rangle&\,=\,&\frac{1}{2}\left( \sum\limits_{Y=0}^{1}\sum\limits_{X=0}^{1}|0\rangle^{24}\otimes|YX\rangle\right), \end{array} $$
(6)
$$\begin{array}{@{}rcl@{}} \begin{array}{lll} |{\Psi}_{2}\rangle&=&\frac{1}{2}(|00000000,10000000,10000000\rangle|00\rangle+\\ &&~~~|10000000,00000000,10000000\rangle|01\rangle+\\ &&~~~|10000000,10000000,00000000\rangle|10\rangle+\\ &&~~~|10000000,10000000,10000000\rangle|11\rangle). \end{array} \end{array} $$
(7)

The |Ψ2〉 in (7) is a NEQR-based quantum image corresponding to the 2 × 2 classical image in Fig. 3.

3.2 Encrypt Scheme of Quantum Color Image

According to NEQR, the R,G,B values of pixel P(Y, X) are stored in the basic state consisting of 24 qubits \(|C_{YX}^{0}\rangle ,|C_{YX}^{1}\rangle ,\cdots ,|C_{YX}^{23}\rangle \), rather than storing in the probability amplitude of the basic state. This basic state is a deterministic state without any randomness. The binary numbers of this basic state are the R,G,B values of the corresponding pixel, which is the advantage of NEQR. For example, the basic state |10000000,00000000,10000000〉 denote that the R,G,B values of R = 128, G = 0, B = 128.

In the encryption method proposed in this paper, all 24 qubits \(|C_{YX}^{0}\rangle ,|C_{YX}^{1}\rangle \), \(\cdots ,|C_{YX}^{23}\rangle \) are randomly rotated π/4 or − π/4. As a result, the color value of each pixel is no longer in a determined basic state, but in a balanced superposition state of containing 224 basic states. In this case, the color image is an uniform white noise which does not contain any information of the original image after it is measured. Next, we introduce the specific rotation method.

For a 2n × 2n color image, first, generate a random sequence of length 24 × 22n and values from the {−1, 1}.

$$\begin{array}{@{}rcl@{}} S=2*round(rand(2^{n},2^{n},24))-1, \end{array} $$
(8)

where the r a n d(n, m, p) is a MATLAB function which generates n × m × p random numbers uniformly distributed in the interval (0,1), and the round is a rounding function. In subsequent experiments, the specific version of MATLAB is 2014a.

It is worth noting that, the rand() function returns a pseudo-random number, not the true random number. This may lead to an inaccuracy of simulation process. Due to the lack of hardware devices that can generate truly random numbers, therefore, limited by the hardware environment, at present, we can only use the rand() function to simulate the performance of the proposed scheme, which is also the most commonly used method of other similar literatures.

A single qubit rotation gate is defined as

$$\begin{array}{@{}rcl@{}} R(\theta)=\left[\begin{array}{lr}\cos\theta ~&~ -\sin\theta\\\sin\theta ~&~ \cos\theta \end{array}\right]. \end{array} $$
(9)

Let \(R_{YX}^{i}=R(S(Y,X,i)\times {\pi }/4)\), \(\tilde {R}_{YX}=\otimes _{i=0}^{23}R_{YX}^{i}\), then

$$\begin{array}{@{}rcl@{}} \tilde{R}_{YX}(\otimes_{i=0}^{23}|C_{YX}^{i}\rangle)=\otimes_{i=0}^{23}(R_{YX}^{i}|C_{YX}^{i}\rangle)=\otimes_{i=0}^{23}|\hat{C}_{YX}^{i}\rangle. \end{array} $$
(10)

According to the principle of quantum computation, the controlled random rotation operator of color qubits of the pixel (Y, X) in the color image can be defined as follows.

$$\begin{array}{@{}rcl@{}} R_{YX}=\left( I^{\otimes24}\otimes\sum\limits_{j=0}^{2^{n}-1}\sum\limits_{i=0,ji\neq YX}^{2^{n}-1}|ji\rangle\langle ji|\right) +\tilde{R}_{YX}\otimes|YX\rangle\langle YX|. \end{array} $$
(11)

The rotation operator of the whole color image can be composed of 22n sub operator R Y X as follows.

$$\begin{array}{@{}rcl@{}} R=\prod\limits_{Y=0}^{2^{n}-1}\prod\limits_{X=0}^{2^{n}-1}R_{YX}. \end{array} $$
(12)

Taking the 2 × 2 color image in Fig. 3 as an example, the quantum circuit of performing random rotation is shown in Fig. 6.

Fig. 6
figure 6

Quantum circuit of performing random rotation of qubit \(C_{YX}^{i}, i=0, 1, {\cdots } , 23\)

3.3 Security of Encrypted Image

In our quantum encryption scheme, the security of the encrypted image is guaranteed by following two points.

  1. (1)

    For the color image after encryption, the color value of all pixels is no longer in the determined basic state, but in a balanced superposition state of 224 basic states.

Taking the first pixel in Fig. 3 as an example, the color value of this pixel is f(0, 0) = [0, 128, 128], the corresponding qubits’ basic state is |C 00〉 = |00000000,10000000,10000000〉. The rotation of these qubits is only 4 cases, namely, rotating \(|\!~C_{00}^{i}\rangle =|0\rangle \) through ± π/4, and rotating \(|C_{00}^{i}\rangle =|1\rangle \) through ± π/4. The specific rotation is as follows.

$$\begin{array}{@{}rcl@{}} &&|C_{00}^{i_{1}}\rangle=\left[\begin{array}{lr}\cos(\frac{{\pi}}{4})&~\!-\sin(\frac{{\pi}}{4})\\ \sin(\frac{{\pi}}{4})&~\!\cos(\frac{{\pi}}{4}) \end{array}\right]\!\!\!\left[\begin{array}{c}1\\0 \end{array}\right]=\frac{|0\rangle+|1\rangle}{\sqrt{2}}=|+\rangle, \end{array} $$
(13)
$$\begin{array}{@{}rcl@{}} &&|C_{00}^{i_{2}}\rangle=\left[\begin{array}{lr}\cos(-\frac{{\pi}}{4})&~\!-\sin(-\frac{{\pi}}{4})\\ \sin(-\frac{{\pi}}{4})&~\!\cos(-\frac{{\pi}}{4}) \end{array}\right]\!\!\!\left[\begin{array}{c}1\\0 \end{array}\right]=\frac{|0\rangle-|1\rangle}{\sqrt{2}}=|-\rangle, \end{array} $$
(14)
$$\begin{array}{@{}rcl@{}} &&|C_{00}^{i_{3}}\rangle=\left[\begin{array}{lr}\cos(\frac{{\pi}}{4})&~\!-\sin(\frac{{\pi}}{4})\\ \sin(\frac{{\pi}}{4})&~\!\cos(\frac{{\pi}}{4}) \end{array}\right]\!\!\!\left[\begin{array}{c}0\\1 \end{array}\right]=\frac{-|0\rangle+|1\rangle}{\sqrt{2}}=-|-\rangle, \end{array} $$
(15)
$$\begin{array}{@{}rcl@{}} &&|C_{00}^{i_{4}}\rangle=\left[\begin{array}{lr}\cos(-\frac{{\pi}}{4})&~\!-\sin(-\frac{{\pi}}{4})\\ \sin(-\frac{{\pi}}{4})&~\!\cos(-\frac{{\pi}}{4}) \end{array}\right]\!\!\!\left[\begin{array}{c}0\\1 \end{array}\right]=\frac{|0\rangle+|1\rangle}{\sqrt{2}}=|+\rangle. \end{array} $$
(16)

It can be known that, regardless of the situation, after the rotation, the \(|C_{00}^{i}\rangle \) is in a balanced (equal probability distribution) superposition state of |0〉 and |1〉. Therefore, after the rotation, the tensor product of 24 qubits is in an equilibrium (equal probability distribution) superposition of 224 basic states.

It is worth noting that, when the basic states \(|+\rangle =\frac {|0\rangle +|1\rangle }{\sqrt {2}}\) and \(|-\rangle =\frac {|0\rangle -|1\rangle }{\sqrt {2}}\) are used as measurement operators, the state represent the color value of a pixel is a determined basic state for the color encryption image. However, the proposed scheme is still secure. From (1316), after the encryption, the basic state |0〉 is transformed into |+〉 and |−〉 with equal probability, and the basic state |1〉 is also performed by the same transformation. In this case, each qubit has an error measurement probability of 50%. Therefore, the results are similar to those measured using basic states |0〉 and |1〉. Thus, the security of the encrypt scheme is only rely on class random function rand(n, m, p).

  1. (2)

    The key space is large enough.

In our quantum encryption scheme, the Key is a random arrangement of 2n × 2n × 24 = 3 × 22n+3 1 and -1. It can be seen, the size of the key space is \(2^{3\times 2^{2n}+3}\). Therefore, the encrypted image has a large key space, enough to resist brute force attacks of illegal users.

3.4 Decryption of Encrypted Image

Since the encryption strategy proposed in this paper is designed based on quantum computer, so all the operators are reversible and unitary, the inverse operator is its own conjugate transpose, and the decryption procedure is just the inverse of the encryption procedure. According to the reversibility of quantum computing, the decryption process can be achieved by employing the conjugate transpose of encryption operators. In this phase, the key is needed to decrypt the encrypted image. Our decryption procedure is briefly summarized as follows.

First of all, legitimate receiver gets the secret key S in (8) through sharing it with sender, and then he/she constructs the following rotation matrix

$$\begin{array}{@{}rcl@{}} \tilde{R}_{YX}=\bigotimes\limits_{i=0}^{23}\left[\begin{array}{lr}\cos(S(Y,X,i)\times{\pi}/4) ~&~ -\sin(S(Y,X,i)\times{\pi}/4)\\\sin(S(Y,X,i)\times{\pi}/4) ~&~ \cos(S(Y,X,i)\times{\pi}/4) \end{array}\right], \end{array} $$
(17)
$$\begin{array}{@{}rcl@{}} R_{YX}=\left( I^{\otimes24}\otimes\sum\limits_{j=0}^{2^{n}-1}\sum\limits_{i=0,ji\neq YX}^{2^{n}-1}|ji\rangle\langle ji|\right) +\tilde{R}_{YX}\otimes|YX\rangle\langle YX|. \end{array} $$
(18)

The decryption operation of encrypted image can be achieved by following unitary operator

$$\begin{array}{@{}rcl@{}} R=\left( \prod\limits_{Y=0}^{2^{n}-1}\prod\limits_{X=0}^{2^{n}-1}R_{YX}\right)^{\dag}, \end{array} $$
(19)

where R denotes the conjugate transpose R. Specifically, the decryption process can be described as |I d e c r y p t i o n = R|I e n c r y p t i o n .

3.5 Quantum Image Measurement

3.5.1 Measurement of Quantum Image after Decryption

According to the NEQR scheme, for the decrypted image, only the R,G,B values of every pixel are stored in the determined basic state of multi-qubits, and the position of the pixel is still stored in the superposition state with randomness. Therefore, each measurement will lead to the collapse of a quantum system, which makes the quantum superposition system collapse to a certain basic state. Thus, for each measurement, we can only get the information of one pixel corresponding to the collapsed basic state. Although the position of this pixel is random, the color value is accurate. This is the essence of NEQR is superior to FRQI. Hence, through the preparation of a large number of the same quantum superposition state, and then the measurement is carried out on the superposition states, as long as the number of prepared superposition states is enough, we can get the color value information of all pixels. Thus, we can realize the transformation of the quantum image to the classical image.

3.5.2 Measurement of Encrypted Image

For the encrypted image, the pixel position and its color value are all in an uniform quantum superposition state. Similar to the measurement of the decrypted image, for each measurement, we also can only get the information of one pixel corresponding to the collapsed basic state, However, the pixel position and its color value obtained at this time are random. In terms of the R,G,B values of every pixel, the probability of taking each value in the (0, 0, 0) ∼ (255, 255, 255) is equal to 2−24. Hence, the encrypted image becomes an uniform white noise after it is measured.

4 Simulation on Classical Computer

Herein, the simulations of the original image’s encryption and decryption are performed on a classical computer due to the condition that the physical quantum computer is not in our grasp right now. The simulations are demonstrated with a classical computer with Intel(R) Core(TM) i5-3470 CPU @ 3.20GHz 4.00GB RAM and 32-bit operating system. The simulations are based on linear algebra with complex vectors as quantum states and unitary matrices as unitary transforms using Matlab 7.8.0(R2009a).

In order to verify the performance of the proposed scheme, a more convincing scheme must be chosen as a comparison target. In this paper, the double encryption scheme in the time domain and frequency in [28] is chosen as the comparison scheme. The reason this scheme is chosen as a comparison target is that it has some outstanding advantages as follows. For encrypted image, the distribution of histogram is uniform, the chi-square value is considerably low, the mean square error of encrypted image is big enough, the correlation coefficients in all three directions are sufficiently small, and the total key length is large enough to resist any brute-force attack, et. al.

The first 8 color images used in the experiment are from following website: http://sipi.usc.edu/database/database.php, and the last 4 color images are from the Peking University and the Tsinghua University campus. For the first 8 images, each row and column contains 512 pixels. The sizes of the last 4 color images are 1024 × 759, 770 × 460, 1024 × 683, and 998 × 598, respectively.

4.1 Encryption Effect

The original images are shown in Fig. 7, and the corresponding encrypted images are shown in Fig. 8. The Decrypted images and the original images are exactly the same, so the display will not be repeated.

Fig. 7
figure 7

The original images

Fig. 8
figure 8

The encrypted images

In Fig. 8, the encrypted images are presented as random white noise, which suggests that, at least from a visual point of view alone, the encryption strategy proposed in this paper is effective.

4.2 Key Sensitivity Analysis

A desirable encryption scheme requires high sensitivity to the encryption keys. In order to test the sensitivity of the secret key, a method of randomly changing some element in encryption key is employed. Specifically, we randomly select respectively 10%, 20%, 30%, 40% of the secret key elements, and put these elements to their opposite number. Then the modified secret key is used to decrypt the encrypted images. The decrypted images are shown in Fig. 9.

Fig. 9
figure 9

The secret key sensitivity test, where the first column is the decrypted images by the secret key with 10% random components, the remainder analogy

To evaluate the quality of the color images restored from the encrypted images with the modified secret key, the RGB Peak Signal-to-Noise Ratio (RGB-PSNR) is used as defined below.

$$\begin{array}{@{}rcl@{}} PSNR=20\log_{10}\left( \frac{255}{\sqrt{\frac{1}{3mn}\sum\limits_{i=0}^{m-1}\sum\limits_{j=0}^{n-1}\sum\limits_{k=0}^{3} [I^{\prime}(i,j,k)-I(i,j,k)]^{2}}}\right), \end{array} $$
(20)

where I′(i, j) and I(i, j) denote the restored image and the original image, respectively, m and n are the number of pixels per row and column in an image.

After the comparison of our restored images I′ with the original images I, the RGB-PSNR values of 12 restored images are obtained as presented in Table 1.

Table 1 The RGB-PSNR values of 12 encrypted images and the restored images by the secret key with some random components

From Fig. 9, when the random components of secret key reaches 40%, the decryption image has become an uniform white noise without any visual information. From Table 1, when the random components of secret key reaches 40%, there is almost no difference in the peak signal to noise ratio of the decrypted image and the corresponding encrypted image, and when the random components of secret key reaches 10%, the peak signal to noise ratio of the decrypted image is only about 12. Through the test, it is proved that the correct image can be reconstructed only when the decryption key and the encryption key match accurately. Due to the key space of proposed method is very big, unless someone has obtained in advance the correct secret key, it is almost impossible to accurately restore the original image.

4.3 Correlation Analysis of Adjacent Pixels

In ordinary image having definite visual content, each pixel is highly correlated with its adjacent pixels. The good encryption approach should produce the cipher image with no such correlation in the adjacent pixels (correlation coefficient ≈ 0). To quantify and compare the correlations of adjacent pixels in the original image and its encrypted version, we also calculated the correlation coefficient R x y of adjacent pixels of the original image and its encrypted version by the following equation.

$$\begin{array}{@{}rcl@{}} R_{R}(x_{R},y_{R})=\frac{E(x_{R}-E(x_{R}))E(y_{R}-E(y_{R}))}{\sqrt{D(x_{R})D(y_{R})}}, \end{array}$$
(21)
$$\begin{array}{@{}rcl@{}} R_{G}(x_{G},y_{G})=\frac{E(x_{G}-E(x_{G}))E(y_{G}-E(y_{G}))}{\sqrt{D(x_{G})D(y_{G})}}, \end{array}$$
(22)
$$\begin{array}{@{}rcl@{}} R_{B}(x_{B},y_{B})=\frac{E(x_{B}-E(x_{B}))E(y_{B}-E(y_{B}))}{\sqrt{D(x_{B})D(y_{B})}}, \end{array}$$
(23)

where E(x R ), E(x G ), E(x B ) and D(x R ), D(x G ), D(x B ) denote the expectation and variance of the gray-level value of three primary colors of red, green, blue, respectively.

To investigate the diffusion effect of our scheme, the correlation is tested between two horizontally, vertically, and diagonally adjacent pixels in the 12 original images and the corresponding encrypted images, respectively. Specifically, by randomly selecting 10,000 pairs of adjacent pixels in each direction from the original image and its encrypted version, the correlation between pixels can be obtained. Suppose that the I O r i and I E n c denote the original image and the encrypted image, respectively, and that the I [28] denotes the encrypted image by using the scheme in [28]. The results of correlation coefficients for horizontal, vertical and diagonal adjacent pixels for 12 original images and their corresponding encrypted images are given in Table 2.

Table 2 The correlation coefficients for horizontal, vertical and diagonal adjacent pixels for the original images and their corresponding encrypted images

It is clear from Table 2 that the correlation between the adjacent pixels in the original image I O r i is very strong, and the adjacent pixels in the encrypted image I E n c is almost irrelevant, and in all three directions of horizontal, vertical and diagonal, the correlation of our method are weaker than that of [28]. This indicates that our method is more secure than scheme in [28].

The visual testing of the correlation of adjacent pixels can be done by plotting the distribution of the adjacent pixels in the plain image and its corresponding cipher image. To illustrate the diffusion effect of our scheme, taking the fourth image as an example, the distribution of the adjacent pixels in the original image and its encrypted image are respectively plotted in Figs. 1011 and 12. In each of the figure, the three child figures at the top belong to the original image, and the three child figures at the bottom belong to the encrypted image.

Fig. 10
figure 10

Correlations between two adjacent pixels in the red color

Fig. 11
figure 11

Correlations between two adjacent pixels in the green color

Fig. 12
figure 12

Correlations between two adjacent pixels in the blue color

The experimental results show that the proposed encryption strategy generally provides a satisfactory correlation performance.

4.4 Histogram Test

Histogram can reflect the distribution of pixel color value in the image, it is clear that the uniform distribution of the histogram can effectively resist various brute force attacks. Taking the twelfth image as an example, the histogram of the pixel R,G,B values before and after encryption is shown in Fig. 13, where the three child figures at the top belong to the original image, and the three child figures at the bottom belong to the encrypted image.

Fig. 13
figure 13

The histogram distributions of the original image and the encrypted one

It can be seen from the Fig. 13, the encrypting operation can exhibit a uniform distribution of the histogram, and do not provide any clue to employ any statistical attack on the proposed image encryption algorithm.

The uniformity of a histogram is justified using the χ 2 test [28], in the following equation

$$\begin{array}{@{}rcl@{}} \chi^{2}=\sum\limits_{k=1}^{256}\frac{(O_{k}-E_{k})^{2}}{E_{k}}, \end{array} $$
(24)

where k denotes the number of gray levels (256), O k denotes the observed occurrence frequencies of each gray level (0-255), and E k denotes the expected occurrence frequencies of each level. For example, E k is equal to 64 for image size of 128 × 128. Obviously, the less the χ 2 value, the better the uniformity. The χ 2 values are presented for all twelve encrypted images as shown in Table 3. In order to compare with other algorithms, the results obtained by using the scheme in [28] are also given in this table.

Table 3 Comparison of χ 2 test of the encrypted images between the proposed scheme and the scheme in [28]

From Table 3, the χ 2 value for encrypted images of our proposed method is about is considerably lower than this value of encryption scheme in [28].

4.5 Mean Square Error

An ideal encrypted image should be significantly different from the original one. The difference between encrypted images and original ones can be characterize by mean square error (MSE) defined in the following equation.

$$\begin{array}{@{}rcl@{}} \text{MSE}_{\text{R}}=\frac{1}{m\times n}\sum\limits_{i=1}^{m}\sum\limits_{j=1}^{n}(I_{Ori}(i,j,2)-I_{Enc}(i,j,1))^{2}, \end{array} $$
(25)
$$\begin{array}{@{}rcl@{}} \text{MSE}_{\text{G}}=\frac{1}{m\times n}\sum\limits_{i=1}^{m}\sum\limits_{j=1}^{n}(I_{Ori}(i,j,3)-I_{Enc}(i,j,2))^{2}, \end{array} $$
(26)
$$\begin{array}{@{}rcl@{}} \text{MSE}_{\text{B}}=\frac{1}{m\times n}\sum\limits_{i=1}^{m}\sum\limits_{j=1}^{n}(I_{Ori}(i,j,3)-I_{Enc}(i,j,3))^{2}, \end{array} $$
(27)

where m × n is the size of image. The parameters I O r i (i, j, k) and I E n c (i, j, k), k = 1, 2, 3, are R,G,B values of pixel (i, j) in original and encrypted images, respectively, where k = 1 denotes R, k = 2 denotes G, and k = 3 denotes B. The larger the MSE value, the better the encryption security.

For all twelve encrypted images by our proposed scheme and scheme in [28], the MSE values are calculated as shown in Table 4.

Table 4 Comparison of mean square error of the encrypted images between the proposed scheme and the scheme in [28]

The MSE of the proposed encrypted image is more than MSE of the scheme in [28], which shows that our method is more effective.

4.6 Probability Deviation

In the encrypted image, the color value of each pixel is no longer in a determined basic state, but in a balanced superposition state, and the probability of which is in state 0 or 1 state is 0.5. Suppose that the kt h qubit of pixel P(Y, X) is \(|C_{YX}^{k}\rangle =\cos \theta _{YX}^{k}|0\rangle +\sin \theta _{YX}^{k}|1\rangle \). The specific definition of probability deviation is as follows.

$$\begin{array}{@{}rcl@{}} &{\Delta} P_{R}=\sum\limits_{Y=0}^{2^{n}-1}\sum\limits_{X=0}^{2^{n}-1}\sum\limits_{k=0}^{7}\frac{(\cos^{2}\theta_{YX}^{k}-0.5)^{2}}{0.5}, \end{array} $$
(28)
$$\begin{array}{@{}rcl@{}} &{\Delta} P_{G}=\sum\limits_{Y=0}^{2^{n}-1}\sum\limits_{X=0}^{2^{n}-1}\sum\limits_{k=8}^{15}\frac{(\cos^{2}\theta_{YX}^{k}-0.5)^{2}}{0.5}, \end{array} $$
(29)
$$\begin{array}{@{}rcl@{}} &{\Delta} P_{B}=\sum\limits_{Y=0}^{2^{n}-1}\sum\limits_{X=0}^{2^{n}-1}\sum\limits_{k=16}^{23}\frac{(\cos^{2}\theta_{YX}^{k}-0.5)^{2}}{0.5}. \end{array} $$
(30)

We calculated the probability deviation of 12 original images and the corresponding encrypted images, and the results are shown in Table 5.

Table 5 Probability deviation contrasts between the original images and the encrypted images

From Table 5, the probability deviation of all the encrypted images is almost zero, which indicates that the qubits in encrypted image are accurately in the equilibrium quantum superposition state, namely, the probability that they are in state |0〉 or state |1〉 is equal. Therefore, only an uniform white noise can be obtained that all pixels take random values when the encrypted image is measured, which can effectively resist brute force attacks of illegal users.

5 Conclusions

In quantum digital images encryption, although, most of the encryption algorithms are designed in the spatial domain and the frequency domain, the quantum digital image could be encrypted only in the spatial domain as well. we proposed a simple algorithm to encrypt an quantum images only in spatial domain. In proposed method, the images are represented based on NEQR model. The pixel’s gray level information is described by 24 quantum bits which is in |0〉 or |1〉. The encryption scheme is to make these qubits be in an equilibrium quantum superposition state. For a 2n × 2n color image, the secret key is a vector of length 2n × 2n × 24, and each component of the vector is randomly taken 1 or − 1. The advantage of this method is that it can be implemented on the future quantum computer and has a large secret key space. The simulation results on a classical computer verify that the proposed quantum image encryption scheme is more secure in comparison with other encryption algorithms.