Demonstration of Quantum Image Edge Extration Enhancement Through Improved Sobel Operator

Quantum image processing is a system where both quantum computing and image processings are key. Now it is required to investigate how to apply image processing concepts such as image edge detection and improved Sobel operator, to quantum image processing. Just as traditional image processing helps to image manipulation, our efforts in quantum image processing contribute to the further development of quantum algorithm and quantum information theory. Edge detection is an important problem in traditional image processing, and image edge detection algorithm can filter image edge features and retain important attributes. We proposed a quantum edge detection algorithm, which employs improved Sobel operator to improve the performance, so as to solve the problem of unsatisfactory traditional image edge detection methods. In practical application, the amount of image data to be processed increases sharply, and the computing power of classical computer becomes a limitation. Quantum information processing can effectively accelerate many classical problems by virtue of quantum mechanical characteristics, such as quantum superposition, entanglement, parallelism. Our proposed method uses the novel enhanced quantum representation to store quantum images, which stores all the pixels in the image in a superimposed state, realizing parallel computation. The improved eight-direction Sobel operator is used to calculate the gray gradient, and the quantum circuit is designed to realize quantum edge detection. Simulation results have shown that our algorithm can extract edge with dimension $2^{n}\times 2^{n}$ when the computational complexity is $O(n^{2} + 2^{q+3})$ . The improved algorithm can detect more edge details and has strong adaptability.


I. INTRODUCTION
Quantum computing [1] is a novel technical processing mode for effective computation based on the principle of quantum mechanics.Since the 1990s in which Shor algorithm and Grover algorithm were proposed, the quantum algorithm has been proved to effectively solve the NP problem [2] of computer and overcome the bottleneck caused by traditional computing methods. Due to its inherent characteristics, such as quantum superposition and parallelism, quantum algorithm [3] can greatly improve the speed of large-scale data processing and accomplish tasks that cannot be accomplished by current classical computers.
Traditional image is an important carrier of information in multimedia, and 70% of the information people obtained by comes from the visual system [4], [5]. However, an effective processing method is urgently needed because of the large amount of digital image data and considerable storage space [6]- [8]. Quantum image processing is a new technology, which is mainly used to geometric transformation, pattern recognition and image classification [9], [10], quantum morphology, quantum edge extraction [11]- [13], image matching [14], [15] and quantum watermark [16], [17]. With the continuous research on quantum image processing, the representation method of quantum image is being updated [18], [19]. In 2003, Venegas-andraca and Bose [20] proposed an image representation method based on electromagnetic wave mapping. In 2011, the image representation method based on quantum entanglement in quantum flexible VOLUME 8, 2020 This work is licensed under a Creative Commons Attribution 4.0 License. For more information, see https://creativecommons.org/licenses/by/4.0/ representation of quantum images (FRQI) proposed by Le [21] can effectively obtain images by using quantum algorithm, which makes quantum graphic processing become a research focus in quantum algorithm. Image representation, the basis for the further image processing, has sprung up in recent years. A large number of quantum image representation methods have been proposed, such as multichannel-representation of quantum images (MCQI) color image representation proposed by Sun, and novel enhanced quantum representation (NEQR) and quantum log-polar image (QUALPI) put forward by Zhang [22]. At the same time, image processing methods based on various quantum image representation methods are gradually increasing. Dang et al. proposed a quantum image matching algorithm [15] and a quantum image classification algorithm [23] in 2017. Wang et al. [24] proposed a quantum image segmentation method in 2018. Fan et al. [25] proposed an image edge detection method based on Laplacian operator in 2019.
In 2020, Xu et al. [26] proposed a quantum image processing algorithm using edge extraction based on Kirsch operator. Image edge detection algorithm is of great significance to the research of image processing and plays an important role in image segmentation [27], image mosaic [28] and image target detection [29]. In recent years, classic image edge extraction algorithms such as Prewitt [30], Kirsch [31], Sobel [32], and Canny [33] have been continuously proposed. In the known classical edge extraction algorithms, the calculation of 2 n × 2 n image cannot be completed under the complexity of O(2 2n ). In quantum image processing, the acceleration of image computation is accomplished by using the physical properties of quantum mechanics, which becomes the breakthrough of the image edge detection technology in the new era. In 2019, Fan et al. [34] completed the quantum edge detection algorithm based on Sobel. In this article, a quantum edge detection algorithm based on improved eight-direction Sobel operator [35] was proposed. After studying various classical edge detection algorithms and quantum edge detection algorithms, the precision and algorithm complexity of edge detection are further improved. In our algorithm, NEQR quantum image representation was first used to represent the image, and quantum bits can be processed on the NEQR quantum image. Then we used the improved Sobel operator for edge extraction, controlling the computational complexity of quantum edge extraction below O(n 2 + 2 q+3 ). Compared with all the classical edge extraction algorithms and some existing quantum edge extraction algorithms, our proposed scheme can achieve a significant exponential acceleration, thereby providing a computational speed. At the same time, the simulation results have shown that our algorithm has higher accuracy in edge extraction.

A. CLASSICAL IMAGE STORAGE
The classical image is represented by real number matrix f xy in the computer. Different color spaces and storage formats may have some differences.
With the example of RGB three-channel color map and single-channel grayscale map, the storage form of classic image is shown in the following Fig.1.

B. NOVEL ENHANCED QUANTUM REPRESENTATION
The images are stored by entangling color information with location information. |C YX and |YX represent color information and position information, and they are stored in a two-dimensional quantum sequence. In the NEQR model, a qubit sequence of length q can store quantum grayscale images with a grayscale range of [0, 2 q − 1]. The grayscale value |C YX of the pixel coordinate (Y,X) is expressed as follows: According to the image representation method of NEQR, a 2 n × 2 n image I can be expressed as: The representation of a NEQR 2 × 2 gray image is shown in Fig. 2. In order to perform shift transformation on an image, a set of same NEQR quantum image sets are often prepared [36].

III. QUANTUM CIRCUIT DESIGN
The quantum circuits use the parallel full adder (ADD), the parallel full subtractor (SUB), double operation (DO), X-Shift transformation C(x±), Y-Shift transformation C(y±) and threshold operation U T , realizing the improved quantum image processing algorithm of Sobel operator through their combination.

A. QUANTUM FULL ADDER
To calculate the gradient of the image, we need to add and subtract the pixels. The n-bit quantum full adder is mainly composed of n half adders. The half adder designed in this article is composed of two CNOT gates and a Toffoli gate, where two input qubits |A and |B , |0 is the auxiliary qubit, and the result after addition is stored in qubit |SUM and carry qubit |C . The quantum circuit is shown in Fig.3. Through the quantum adder, we can add multiple pixels to calculate the gradient value of the image, and use the quantum addition operation to find the sum of the I A and I B pixel values, the result I C is as follows:

B. SUBTRACTION OPERATION
The quantum subtraction process is mainly completed by the quantum adder, which is similar to the classical subtraction operation. The negative number needs to be added by taking the complement code first. The quantum circuit is shown in Fig.4. The result of pixel subtraction is stored in I C .

C. DOUBLE OPERATION
When calculating the gradient of the image, we also need to double some pixels. We move the binary bit A sequence of quantum bits is formed by adding an auxiliary qubit |0 .
The quantum circuit is shown in Fig.5.

D. CYCLIC SHIFT TRANSFORMATION
To calculate the gray gradient, it is necessary to obtain the gray value of 24 adjacent points of the pixel, and the positions of these adjacent points need to be obtained by using the shift transformation [37]. Before the displacement transformation, k identical NEQR quantum images are prepared according to the convolution operator [36], and k quantum images are taken as quantum image sets to carry out cyclic displacement operations respectively. First of all, we need to consider the quantum circuit of the copy module. The function of the quantum circuit is to copy the quantum state of n qubits and to prepare the initial NEQR quantum image set. The quantum circuit is shown in Fig.6. Then this algorithm performs a cyclic shift transformation on a quantum image of size 2 n ×2 n expressed using the NEQR model. The quantum circuit is shown in Fig.7. The X-Shift  and Y-Shift transformations are expressed as follows:

E. THE THRESHOLD OPERATION
In order to classify the qubit sequences storing the gradient value of the pixel, we set the quantum threshold operation U T , which requires an auxiliary qubit. Through the quantum threshold operation U T , we divide the qubit sequences less than the threshold value into one category, and the qubit sequences greater than the threshold value into one category as the image edge. The quantum circuit is shown in Fig.8.

IV. QUANTUM EDGE EXTRACTION ALGORITHM FOR IMPROVED SOBEL OPERATOR
In this part, we introduce in detail the quantum image edge detection algorithm based on the improved Sobel operator. The detailed flow of the algorithm is mainly divided into three parts. First, we transform the original classical image into the NEQR quantum image model. Then the quantum circuit is designed and the gray image gradient is calculated based on the improved eight-direction Sobel operator. Finally, we filter the pixel points convolved with Sobel operator, and select the image edge points within the threshold range. The workflow of quantum image edge extraction is shown in Fig.9.

A. IMPROVED EIGHT-DIRECTION SOBEL OPERATOR
Sobel operator uses horizontal and vertical templates to convolve with corresponding image data and to perform weighted calculation on discrete data. The classic Sobel operator is defined as follows: The classic Sobel operator uses a 3 × 3 template in the horizontal and vertical directions and the corresponding image data to perform convolution, so as to achieve edge detection. Based on the traditional Sobel operator, this section is extended to an eight-direction Sobel edge detection algorithm [35]. Using   for detection, the detection results are more complete and the outline is clear. The extended Sobel operator convolution template is shown in Fig.10.
The optimal Sobel edge detection operator uses the above template to detect the edge of the image from 8 directions. During the detection process, the gray value of the pixel is weighted and averaged to provide more continuous edge direction information. The Sobel edge detection operator approximates the edge of the image by calculating the gradient of the image brightness. Taking the 0 • direction template as an example, the template operation is shown in Fig.11. We calculate the gradient in different directions multiplied by the weight, and take the maximum value as the output. Then, the gray value of pixel P is: Compared with the original Sobel algorithm, the optimal Sobel algorithm can more accurately and meticulously complete the image edge detection, and at the same time, the quantum algorithm accelerates the operation speed and overcomes its relatively complex problem.

B. THE WORKING PROCESS
Taking the 0 • direction template as an example, the process of calculating the pixel gradient of quantum image by the optimal Sobel operator is shown in Table 1, and the design of quantum circuit diagram is shown in Fig.12.
The algorithm uses an optimal eight-direction Sobel operator to calculate the pixel gradient. According to the convolution templates in 8 different directions, 24 adjacent pixels around the pixels are traversed by circular displacement. Taking the 0 • direction as an example, the process and results of calculating the pixel gradient using the optimal Sobel operator are shown below. |N 1 ) |N 4 = qADD(|C xy−1 , |C xy−1 ) |S 0 = qSUB(|M 6 , |N 6 ) (17) VOLUME 8, 2020 Through calculation and comparison, the largest response value S max among the eight convolution operators is obtained, so the processed quantum image becomes: The calculated image gradient values are classified according to the threshold function U T , and a threshold T is set: Finally, output is obtained: After filtering by threshold function, when T YX = 1, the pixel point T YX is the image edge. Finally, all the qualified points are taken as a set to obtain the complete image edge.

V. MAIN RESULTS
This algorithm is improved based on Sobel quantum edge detection algorithm, and the traditional 2-directions Sobel algorithm is improved to 8 directions. It can be found from the simulation results that the edge detection results of the optimal Sobel operator quantum edge search algorithm are obviously more accurate and detailed. Especially, the experimental results are better in the image edge complex target and accurate capture of the edge details of the image.

A. SIMULATION RESULTS
In order to verify our scheme, we carried out experimental simulation in the quantum environment simulated by Matlab R2019a, and simulated our various quantum circuits in Qiskit.
Comparing the simulation result image set, thanks to the eight-direction Sobel operator, our algorithm extracts image details better and the basic contours are more obvious. The experimental results are shown in Fig.13. At the same time, we compared our algorithm with the classical Sobel algorithm and the classical Prewitt algorithm on Peak signal-to-noise ratio(PSNR). The comparison results obtained by calculation are shown in Table 3.

B. COMPLEXITY
The computational complexity in quantum image processing algorithms depends on the number of quantum gates used in the quantum circuit. In this section, considering a digital image with a size of 2 n × 2 n as an example, we analyzed the complexity of quantum image edge detection algorithm based on improved Sobel operator.
Case 1: The computational complexity of NEQR quantum image preparation This algorithm uses NEQR quantum image representation to represent classic images as quantum images. From the introduction of Ref. [22], we know that the NEQR model indicates that the computational complexity of quantum images does not exceed O(qn2 2n ).
Case 2: The computational complexity of obtaining neighborhood pixels The algorithm uses 25 cyclic shift transformations to obtain neighborhood pixel values, and the complexity of each displacement operation does not exceed O(n 2 ).   In this part, the algorithm calculates the image gradient according to the improved eight-direction Sobel operator template, and the constructed quantum circuit is shown in the Fig.8. In this circuit diagram, we use quantum full adders and quantum subtractors. The circuit complexity of ADD and According to the analysis of the above part, the computational complexity of a 2 n × 2 n image is obtained: The complexity of constructing quantum images with the NEQR model is relatively high, but it is not used as part of quantum image processing algorithms. Therefore, the quantum edge detection algorithm based on the optimal eight-direction Sobel operator can extract the edge of the NEQR quantum image when the complexity is O(n 2 + 2 q+3 ).  The performance comparison between this algorithm and other classical and quantum edge extraction algorithms is shown in Table 4.

VI. CONCLUSION
In this article, based on the edge detection algorithm of quantum image of Sobel operator, the traditional convolution template of 3 × 3 in two directions of Sobel operator is improved to the convolution template of 5 × 5 in eight direc-tions. At the same time, the quantum circuit is designed to realize the edge detection algorithm of quantum image based on the optimal Sobel operator. This algorithm can extract the edge of NEQR quantum image with size of 2 n × 2 n under the condition that the computational complexity is lower than O(n 2 + 2 q+3 ). Through experimental comparison, it can be found that the edges of the processed images are very obvious and more detailed than the results of other algorithms.