Quantum realization of the bilinear interpolation method for NEQR

In recent years, quantum image processing is one of the most active fields in quantum computation and quantum information. Image scaling as a kind of image geometric transformation has been widely studied and applied in the classical image processing, however, the quantum version of which does not exist. This paper is concerned with the feasibility of the classical bilinear interpolation based on novel enhanced quantum image representation (NEQR). Firstly, the feasibility of the bilinear interpolation for NEQR is proven. Then the concrete quantum circuits of the bilinear interpolation including scaling up and scaling down for NEQR are given by using the multiply Control-Not operation, special adding one operation, the reverse parallel adder, parallel subtractor, multiplier and division operations. Finally, the complexity analysis of the quantum network circuit based on the basic quantum gates is deduced. Simulation result shows that the scaled-up image using bilinear interpolation is clearer and less distorted than nearest interpolation.

Image is an important medium for visual information transmission. Image processing is very popular because of the need to extract visual information from the natural world. With the rapid development of quantum computation and quantum information in past several decades, quantum computer has demonstrated a bright prospect over the classic computer, such as Feynman's computation model 1 , Deutsch's quantum parallelism assertion 2 , Shor's integer factoring algorithm 3 , and Grover's database searching algorithm 4 .
Quantum image processing (QIMP), a new sub-discipline of information and image processing, which is devoted to utilizing the quantum computing technologies to capture, manipulate, and recover quantum images in different formats and for different purposes. The investigation of QIMP begins with how to store and retrieve quantum images in quantum computers. Venegas-Andraca and Bose firstly proposed the quantum image representation of qubit lattice using one qubit to hold one pixel 5 . Then Latorre presented real ket representation using quantum superposition state to store image information 6 . Le et al. 7 next proposed a flexible representation of quantum image (FRQI) using quantum superposition state to store the colors and the corresponding positions of an image. Further, more quantum image representations were proposed. For instance, a novel enhance quantum representation (NEQR) 8 used q qubits encoding the gray-scale value from 0 to 2 q − 1, which could perform the complex and elaborate color operations conveniently. Quantum log-polar image 9 was proposed as a novel quantum image representation storing images sampled in log-polar coordinates. Color image representation utilized two sets of quantum states to store M colors and N coordinates, respectively 10 . A normal arbitrary quantum superposition state was used to represent a multi-dimensional image 11 . After that, a simple quantum representation of infrared images was proposed 12 .
In addition, some geometric transformation algorithms of quantum images were designed such as two-point swapping, flip, orthogonal rotations, entire translation, cyclic translation, global and local translation [13][14][15] . Then, the quantum image scaling algorithms [16][17][18] were proposed. In paper 16 17 . Furthermore, Jiang N et al. proposed the generalized quantum image representation (GQIR) and quantum image scaling up based on GQIR and nearest-neighbor interpolation with integer scaling ratio 18 .
In the aspects of quantum protection, some algorithms have appeared recently such as quantum image scrambling [19][20][21] , quantum watermarking schemes [22][23][24][25] , LSB steganography algorithms based on NEQR 26 Hence, NEQR for a 2 n × 2 n quantum image can be written as  Figure 1 shows an example of a 2 × 2 image, and the corresponding NEQR of which is on the right.
Classical bilinear interpolation method. Bilinear interpolation method plays an important role in classical image scaling. In this paper, we mainly study the quantum realization of bilinear interpolation method. Thus, the classical bilinear interpolation method is reviewed. For a W × H(width and height) image, the size of the corresponding interpolated image is W′ × H′, which can be described in two steps.
Coordinate map. The coordinate (Y′, X′) of the interpolated image is restored from the positions (Y, X), (Y + 1, X), (Y, X + 1) and (Y + 1, X + 1) in the original image. The corresponding relationship is shown in Fig. 2. Here, Calculating pixel value. As shown in Fig. 3, the value of the destination pixel (x, c) can be obtained by Eq. (4) where (x 0 , c 0 ) and (x 1 , c 1 ) are two known pixels. That is to say, where S is the scaling function, I is the original image, I′ is the interpolated image, r y is the scaling ratio in vertical, and r x is the scaling ratio in horizontal. Thus, the pixel value in position (Y′, X′) of the interpolated image shown in Fig. 2 can be calculated according to Eq. (6) The Controlled-V and Controlled-V + Gates. The Controlled-V and Controlled-V + gates are shown in Fig. 5. If the control signal A = 0, then the qubit B will pass through the controlled part unchangeably, i.e., Q = B. When  The V and V + quantum gates have the following properties: is an identity matrix. More details of the V and V + gates refer to the literature 32,34 .
The CNOT gate. The CNOT gate shown in Fig. 6 has the mapping (A, B) to (P = A, Q = A ⊕ B), where A, B are the inputs and P, Q are the outputs, respectively.
The Toffoli gate (TG). The TG and its quantum circuit realization are shown in Fig. 7. The quantum cost of TG is 5, which can be seen from Fig. 7(b).

The Peres gate (PG).
The PG is shown in Fig. 8(a). The quantum circuit of PG is shown in Fig. 8(b), then, we can get that the quantum cost of PG is 4.     The Thapliyal Ranganathan gate (TR). TR gate and its quantum circuit are shown in Fig. 9. The quantum cost of TR gate is also 4.
Special adding one operation. The special adding one operation U 1 (n) module is shown in Fig. 10, where the label • and • represent the control qubit value 1 and 0 , respectively. When U 1 (n) works on the quantum state − −  a a a a n n 1 2 1 0 , then the result is  where n is a positive natural number, n ≥ 2, a 0 , a 1 , …, a n−1 ∈ {0, 1} .
The multiply Control-Not operation. The quantum circuit of the multiply Control-Not operation is shown in Fig. 11(a) and its simplified graph is shown in Fig. 11(b). It utilizes n Control-Not gates to copy the and |Y 0 〉 are the control qubits and the n ancillary qubits ⊗ 0 n are the target qubits. That is, the input Y by using the multiply Control-Not operation.
The reversible parallel full-adder circuit. Islam M S et al. 35 proposed the reversible full-adder based on the PG. Here, the introduction of the design of half-adder, full-adder and parallel-adder are given.
Reversible half adder (RHA). Figure 12 shows the PG working as a half-adder and its quantum circuit, where R = A ⊕ B represents the sum of A + B and Q = AB represents the carry, respectively.
Reversible full adder (RFA). Using two PG gates, the full-adder can be designed shown in Fig. 13(a), where R = A ⊕ B ⊕ C represents the sum of (A + B + C) and S = (A ⊕ B)C ⊕ AB represents the carry, respectively. The quantum circuit of RFA is shown in Fig. 13(b), and its simplified graph is shown in Fig. 13(c).
Reversible parallel adder (PA). The parallel adder adding an n-qubit Y to an n-qubit X is designed by one RHA and n-1 reversible full-adders as shown in Fig. 14. Here, the sequence −  S S SS n n 1 1 0 represents the sum of X + Y.  Other unremarked qubits are the garbage outputs and the input qubit 0 is the ancillary constant input. For convenience, the block diagram of PA omits the ancillary inputs and the garbage outputs.
The reversible parallel subtractor circuit. Thapliyal H. et al. 31 designed subtractor using the reversible TR gate and further realized optimization in terms of quantum cost and delay 36 . Here, the concrete parallel subtractor circuit is given.   Reversible half subtractor (RHS). As shown in Fig.15, the inputs of A and B are 1-bit binary number, and the TR gate can work as a half subtractor performing A-B operation, where the output R = A ⊕ B produces the difference between A and B and the output = Q A B generates the corresponding borrow bit. The quantum circuit of RHS is shown in Fig. 15(b), and its simplified graph is shown in Fig. 15(c). Fig. 16

Reversible full subtractor (RFS). The RFS as shown in
represents the borrow bit. The quantum circuit of RFS is shown in Fig. 16(b), and its simplified graph is shown in Fig. 16(c). The reversible divider (ND). Khosropour A et al. 38 realized quantum division circuit based on restoring division algorithm as shown in Fig. 20.

Reversible parallel subtractor (PS
2 1 are the input registers. Multiply P by 2 can be obtained by the left shift (LSH) 39 module. For realizing subtracting D from the highest n qubits of P 2 , we first act quantum Fourier transform (QFT) 22 on the highest n qubits of P 2 and apply a set of conditional rotation operations on the n qubits of D . Secondly, we perform inverse QFT (QFT −1 ) and check if − P D (2 ) is either positive or negative. If it is positive, the qubit Q n need to be initialized into state |0〉, otherwise, keep Q n unchanged, which can be realized using a CNOT gate. If − P D (2 ) is diagnosed to be negative, it should be set back to the previous state P 2 by simply adding D to the highest n qubits of − P D 2 . Because Q n contains the inverse of the most significant qubits in − P D 2 . Hence, the addition should be conditioned on Q n . This structure should be repeated n times to fulfill the division operation. Eventually, Q is the quotient and the highest n qubits of |P〉 is the remainder. Note that we have used only n ancillary qubits for LSH operation.  For convenience, Fig. 21 is a simplified graph of the quantum division circuit in Fig. 20, where ancillary inputs and garbage outputs are omitted, and Q is the quotient.
Feasibility and rationality of bilinear interpolation method. In this paper, the quantum circuit of the image scaling based on bilinear interpolation method for NEQR is designed. Therefore, the first problem is to prove the practicality. The key idea of the proposed circuits is mathematically explained in Eq. (7)   (7), in order to prepare the color information ′ ′ C Y X , in position (Y′, X′) of the resulting image, the color information    as the input state when designing quantum circuits. Under the guidance of this key idea, the qualification process is as follows.
Theorem The bilinear interpolation method generated by Eq. (7) is rational for a quantum image based on NEQR.
Proof Assume that the size of an original quantum image I is 2 n × 2 n , and the gray range of which is [0, 2 q − 1], the NEQR of the image is expressed by Eq. Also suppose image scaling ratio in the horizontal and vertical dimensions is 2 m , than is r y = r x = 2 m , then the size of the resulting image ′ I is 2 n+m × 2 n+m . The concrete feasibility of the bilinear interpolation is proven through the following analysis.
Problem 1 How to build the interpolation mapping relationship between the pixel of the resulting image and the original image?
The position (Y′, X′) of the resulting image has the mapping relationship with the positions (Y, X), (Y + 1, X), (Y, X + 1) and (Y + 1, X + 1) of the original image as shown in Fig. 2.
According to Eq. (3), we derive the Eq. (9)   Firstly, four quantum oracle operators Ω Y,X , Ω Y+1,X , Ω Y,X+1 and Ω Y+1,X+1 are used to compute the original pixel values of 1 , respectively. A quantum oracle operator Ω Y,X can realize the aim of assigning color information C Y X , to the ancillary qubits ⊗ 0 q8 , which can be expressed by Eq. (10) where can be described as the following.
, Ω Y X i , is a 2n-Control-Not qubit gate. Otherwise, it is a quantum identity gate. That is to say, every oracle operator Ω = . .
is at most a 2n-Control-Not qubit gate. For other three oracle operators Ω Y+1,X , Ω Y,X+1 , Ω Y+1,X+1 , the principle is also same as Ω Y,X   We need implement some arithmetic operations to calculate the pixel value

Quantum realization of the bilinear interpolation method.
In the previous section, the theoretical feasibility of the bilinear interpolation method for NEQR is discussed using the multiply Control-Not operation, special adding one operation and a series of quantum circuit modules. This section gives the concrete quantum realization circuit of the bilinear interpolation method for NEQR, including scaling up and scaling down.

Quantum image scaling up circuit of the bilinear interpolation for NEQR.
Assume that a 2 n × 2 n quantum image I is scaled up to a 2 n+m × 2 n+m quantum image ′ I based on the bilinear interpolation. The scale ratio in the vertical and horizontal level is both 2 m , that is to say, r y = r x = 2 m .
The concrete scaling-up circuit for NEQR. Figure 22 provides the quantum image scaling-up circuit that implements the bilinear interpolation for NEQR. The concrete steps can be described as follows.

.
Step 3 Calculate the pixel value ′ ′ C Y X , of the interpolated image through the four pixel values 1 as described in Eq. (10). The realization circuit is shown in Fig. 22.
Circuit complexity. The circuit network complexity depends on the number of the elementary gate in QIMP.
The complexity of the basic quantum gate is considered to be 1 including NOT gate, Control-Not gate and any 2 × 2 unitary operator 40 . In addition, when designing the quantum circuit, introducing ancillary qubit 0 or 1 is a commonly used method. The complexity of Fig. 22 is analyzed as follows.
In step 1, it needs 8(n + m) Control-Not gates and two U 1 (n) operators. As shown in Fig. 10, each unitary operator U 1 (n) has n − 1 Not gates, n + 1 Control-Not gates, and n − 1 multi-Control-Not gates of and one (n − 1)-Control-Not gate, where σ x is the NOT gate. According to Lemma 6.1 and Lemma 7.1 in ref. 40, for any 2 × 2 unitary matrix U and any n ≥ 3, a Λ n−1 (U) gate can be simulated by n qubits circuit consisting of (2 n−1 − 1)Λ 1 (V) gates, a Λ 1 (V + ) gate and (2 n−1 − 2)Λ 1 (σ x ) gates, where V represents the unitary operator, V + is the hermitian conjugate of V. We can deduce that the network complexity of single quantum operator U 1 (n) is Ο(2 n+2 ). Thus, the total quantum cost in this step is Ο(2 n+3 + 8n + 8m).
The network complexity of PS. The PS realizes the subtraction between two m + 1 qubits. It needs 1 RHS and m reversible full subtractors. The quantum cost of RHS (see Fig. 15) is 6, and the quantum cost of RFS (see Fig. 16) is 7. So the quantum cost of single PS is 7 m + 6.
The quantum cost of PA. As we know, the pixel value is represented by q qubits, the resulting pixel value can be calculated by implementing ND modules twice. Thus, the three parallel adders perform the operation of q + 2m + 2 qubits plus q + 2m + 2 qubits, it needs 1 RHA and (q + 2 m + 1) reversible full adders. The quantum cost of RHA (see Fig. 12) is 4, and the quantum cost of RFA (see Fig. 13) is 8. Therefore, the quantum cost of single PA is 8q + 16 m + 20.
The network complexity of PM. As shown Fig. 22, it is easy to find there are 4 parallel multipliers, each of which performs m + 1 qubits multiply by m + 1 qubits. We can see form Fig. 19 that each PA can add two m + 1 qubits at most. Thus, the number of PA required in PM is + + + In another case, the other 4 parallel multipliers perform 2 m + 2 qubits multiply by q qubits respectively (suppose q ≥ 2m + 2). We can see form Fig. 19  The network complexity of ND. According to paper 38 , the quantum cost of q-qubit ND is 3q 3 + 6q 2 + q.
Consequently, the complexity of the proposed scaling-up circuit shown in Fig. 22   Concrete circuit for NEQR. Fig. 23 shows the quantum image scaling-up circuit that implements the bilinear interpolation for NEQR. The concrete steps are described as follows.
Step 1 First of all, obtain the positions of (Y + 1, X), (Y, X + 1) and (Y + 1, X + 1) using 6(n + m) Control-Not gates and two special adding one U 1 (n + m) operators. Then, obtain the = . Therefore, the coordinates mapping relationship has been built between the position (Y′, X′) of the resulting image and the positions in (Y, X), (Y + 1, X), (Y, X + 1) and (Y + 1, X + 1) of the original image.
In step 2, it includes four oracle operators of Ω Y,X , Ω Y+1,X , Ω Y,X+1 and Ω Y+1,X+1 . Then, the total network complexity in this step is Ο ⋅ + q n m ( 8( )). In step 3, it includes 4 parallel subtractors, 8 parallel multipliers, 3 parallel adders and 2 reversible dividers. Consequently, the network complexity of the proposed scaling-up circuit shown in Fig. 23  Simulation results of interpolation for NEQR. Fig. 24 gives a concrete procedure of quantum bilinear interpolation. Firstly, we need to transform a classic image into a quantum image I expressed by NEQR. Then, the quantum image I acts as the input image. The resulting image (the interpolated image) ′ I can be derived using the proposed quantum bilinear interpolation method. Finally, we can retrieve the interpolated classic image by quantum measurement.
The simulation results using different interpolation method are shown in Fig. 25. Figure 25(a) is a 64 × 64 original image named Lena. Figs 25(b,c) are the corresponding 128 × 128 scaling-up NEQR images using nearest-neighbor interpolation and bilinear interpolation, respectively. The scaling ratio is r x = r y = 2, which means n = 6, m = 1 and q = 8. Figure 25(d,e) are the corresponding 256 × 256 scaling-up NEQR images using nearest-neighbor interpolation and bilinear interpolation, respectively. The scaling ratio is r x = r y = 4, which means n = 6, m = 2 and q = 8. The simulation results indicate that the scaled-up image using bilinear interpolation is clearer than nearest-neighbor interpolation.
Quantum measurement of the interpolated image. An interpolated NEQR image can be described as following.
Obviously, an interpolated NEQR image is a quantum superposition state, which can be regarded as a composite quantum system composed of 2n + q qubits.
Actually, the quantum state cannot be practically observed in quantum system because a measurement will destroy the superposition. What is worse, it is not allowed to make copies of the state and measure each one due to the non-cloning theorem. Hence, it is necessary to repeat constructing the states of interpolated image n (n > 1) times and measure each state to summarize the measurement results, through which we can estimate the interpolated image. We execute probability measurement on the interpolated image. Probability measurement converts the quantum information into classical information in form of probability distributions, i.e., it converts a single qubit state ψ α β = + 0 1 into a probability classical bit M (distinguished from a qubit by drawing it as a double-line wire), which is 0 with probability α 2 or 1 with probability β 2 , as shown in Fig. 26.
Next, we analyze the impact of quantum measurements on the interpolated image. The measurement results of the 2 n+m × 2 n+m interpolated NEQR image with gray range [0, 2 q−1 ] are some collection of basis states ... . After multiple measurements, these basis states follow a probability distribution. The measurement will continue until the probability of each basis state is stabilized at a fixed value. According to law of large numbers, there is a limit to these basis states which can be used to estimate the color information of the interpolated image. The block diagram of the measurement procedure on quantum computers is shown in Fig. 27.

Conclusions
In this paper, the bilinear interpolation method for NEQR is proposed for the first time. The proposed method constructs an interpolated image, which mainly consists of two steps: (1) position mapping (2) calculate and generate the new color information. In the position mapping stage, the multiply Control-Not operation and special adding one operation are used to build the position mapping relationship between the position (Y′, X′) in interpolated image and the positions (Y, X), (Y + 1, X), (Y, X + 1) and (Y + 1, X + 1) in the original image. After   that, exploit the oracle operator to prepare the original image pixel. Then, a series of quantum circuits designed in this paper are used to calculate the color information of the interpolated image.
The main contributions of this paper are as follows: (1) The bilinear interpolation method for NEQR is realized and the corresponding quantum realization circuits are given. (2) A series of unitary quantum circuit operations are designed, which can be used in future quantum computers. (3) The quantum image scaling algorithm is developed to change the image size.
The future works mainly include: (1) Give the bilinear interpolation method for FRQI and its realization circuit.
(2) Further realize the bicubic interpolation method for other quantum image representations such as FRQI and NEQR. (3) Give simpler quantum interpolation realization circuit through the basic quantum gates and the quantitative analysis about the circuit complexity.