PHYSICAL REVIEW X 7, 031041 (2017)

Quantum Image Processing and Its Application to Edge Detection: Theory and Experiment

Xi-Wei Yao,1,4,5,* Hengyan Wang,2 Zeyang Liao,3 Ming-Cheng Chen,6 Jian Pan,2 Jun Li,7 Kechao Zhang,8 Xingcheng Lin,9 Zhehui Wang,10 Zhihuang Luo,7 Wenqiang Zheng,11 Jianzhong Li,12 † ‡ Meisheng Zhao,13 Xinhua Peng,2,14, and Dieter Suter15, 1Department of Electronic Science, College of Physical Science and Technology, Xiamen University, Xiamen, Fujian 361005, China 2CAS Key Laboratory of Microscale Magnetic Resonance and Department of Modern Physics, University of Science and Technology of China, Hefei, Anhui 230026, China 3Institute for Quantum Science and Engineering (IQSE) and Department of Physics and Astronomy, Texas A&M University, College Station, Texas 77843-4242, USA 4Dahonggou Haydite Mine, Urumqi, Xinjiang 831499, China 5College of Physical Science and Technology, Yili University, Yining, Xinjiang 835000, China 6Hefei National Laboratory for Physical Sciences at Microscale and Department of Modern Physics, University of Science and Technology of China, Hefei, Anhui 230026, China 7Beijing Computational Science Research Center, Beijing 100193, China 8Institute of Theoretical Physics, Chinese Academy of Sciences, Beijing 100190, China 9Department of Physics & Astronomy and Center for Theoretical Biological Physics, Rice University, Houston, Texas 77005, USA 10School of Mathematical Sciences, Peking University, Beijing 100871, China 11Center for Optics and Optoelectronics Research, College of Science, Zhejiang University of Technology, Hangzhou, Zhejiang 310023, China 12College of mathematics and statistics, Hanshan Normal University, Chaozhou, Guangdong 521041, China 13Shandong Institute of Quantum Science and Technology, Co., Ltd., Jinan, Shandong 250101, China 14Synergetic Innovation Center of and Quantum Physics, University of Science and Technology of China, Hefei, Anhui 230026, China 15Fakultät Physik, Technische Universität Dortmund, D-44221 Dortmund, Germany (Received 26 April 2017; revised manuscript received 30 June 2017; published 11 September 2017) Processing of digital images is continuously gaining in volume and relevance, with concomitant demands on data storage, transmission, and processing power. Encoding the image information in quantum-mechanical systems instead of classical ones and replacing classical with quantum information processing may alleviate some of these challenges. By encoding and processing the image information in quantum-mechanical systems, we here demonstrate the framework of quantum image processing, where a pure encodes the image information: we encode the pixel values in the probability amplitudes and the pixel positions in the computational basis states. Our quantum image representation reduces the required number of compared to existing implementations, and we present image processing that provide exponential speed-up over their classical counterparts. For the commonly used task of detecting the edge of an image, we propose and implement a quantum that completes the task with only one single- operation, independent of the size of the image. This demonstrates the potential of quantum image processing for highly efficient image and video processing in the big data era.

DOI: 10.1103/PhysRevX.7.031041 Subject Areas: Quantum Physics, Quantum Information

I. INTRODUCTION is one of the most important functions of the human brain [1]. In 1950, Turing proposed the development of machines Vision is by far the most important channel for obtaining that would be able to “think,” i.e., learn from experience and information. Accordingly, the analysis of visual information draw conclusions, in analogy to the human brain. Today, this field of research is known as artificial intelligence (AI) [2–4]. *[email protected] Since then, the analysis of visual information by electronic † [email protected] devices has become a reality that enables machines to ‡ dieter.suter@tu‑dortmund.de directly process and analyze the information contained in images and stereograms or video streams, resulting in Published by the American Physical Society under the terms of rapidly expanding applications in widely separated fields the Creative Commons Attribution 4.0 International license. Further distribution of this work must maintain attribution to like biomedicine, economics, entertainment, and industry the author(s) and the published article’s title, journal citation, (e.g., automatic pilot) [5–7]. Some of these tasks can be and DOI. performed very efficiently by digital data processors, but

2160-3308=17=7(3)=031041(14) 031041-1 Published by the American Physical Society XI-WEI YAO et al. PHYS. REV. X 7, 031041 (2017) others remain time-consuming. In particular, the rapidly Encoding Processing Decoding increasing volume of image data as well as increasingly Classical challenging computational tasks have become important 0110...01 driving forces for further improving the efficiency of image 2n bits processing and analysis. Quantum information processing (QIP), which exploits G= PFQ F = ()F G = ()Gij quantum-mechanical phenomena such as quantum super- ij ML× ML× positions and [8–23], allows one to overcome the limitations of classical computation and reaches higher computational speed for certain problems like factoring large numbers [24,25], searching an unsorted database [26], boson sampling [27–32], quantum simula- tion [33–40], solving linear systems of equations [41–45], and machine learning [46–48]. These unique quantum F11 T G11 F UQ P = properties, such as and quantum f = 21 g G 21 parallelism, may also be used to speed up signal and data FML GML processing [49,50]. For quantum image processing, quan- n qubits tum image representation (QImR) plays a key role, which substantively determines the kinds of processing tasks Quantum and how well they can be performed. A number of – FIG. 1. Comparison of image processing by classical and QImRs [51 54] have been discussed. quantum computers. F and G are the input and output images, In this article, we demonstrate the basic framework of respectively. On the classical computer, an M × L image can quantum image processing based on a different type of be represented as a matrix and encoded with at least 2n bits QImR, which reduces the qubit resources required for [n ¼ ⌈log2ðMLÞ⌉]. The classical image transformation is con- encoding an image. Based on this QImR, we experimen- ducted by matrix computation. In contrast, the same image can be tally implement several commonly used two-dimensional represented as a quantum state and encoded in n qubits. The transforms that are common steps in image processing on a quantum image transformation is performed by unitary evolution ˆ quantum computer and demonstrate that they run expo- U under a suitable Hamiltonian. nentially faster than their classical counterparts. In addition, we propose a highly efficient for QImR where the image is encoded in a pure quantum state, detecting the boundary between different regions of a i.e., encoding the pixel values in its probability amplitudes picture: It requires only one single-qubit gate in the and the pixel positions in the computational basis states processing stage, independent of the size of the picture. of the Hilbert space. In this section, we introduce the We perform both numerical and experimental demonstra- principle of QImP based on such a QImR, and then present tions to prove the validity of our quantum edge detection experimental implementations for some basic image trans- algorithm. These results open up the prospect of utilizing forms, including the 2D , 2D Hadamard, quantum parallelism for image processing. and the 2D Haar wavelet transform. The article is organized as follows. In Sec. II, we firstly introduce the basic framework of quantum image process- ing, then present the experimental demonstration for several A. Quantum image representation ¼ð Þ basic image transforms on a nuclear magnetic resonance Given a 2D image F Fi;j M×L, where Fi;j represents (NMR) quantum information processor. In Sec. III,we the pixel value at position ði; jÞ with i ¼ 1; …;M and propose a highly efficient quantum edge detection algorithm, j ¼ 1; …;L, a vector f⃗with ML elements can be formed along with the proof-of-principle numerical and experimen- ⃗ tal demonstrations. Finally, in Sec. IV, we summarize the by letting the first M elements of f be the first column of F, results and give a perspective for future work. the next M elements the second column, etc. That is, ⃗¼ ð Þ II. FRAMEWORK OF QUANTUM f vec F T IMAGE PROCESSING ¼ðF1;1;F2;1; …;FM;1;F1;2; …;Fi;j; …;FM;LÞ : ð1Þ In Fig. 1, we compare the principles of classical and ⃗ quantum image processing (QImP). The first step for QImP Accordingly, the imageP data f can be mapped onto a pure j i¼ 2n−1 j i ¼ ⌈ ð Þ⌉ is the encoding of the 2D image data into a quantum- quantum state f k¼0 ck k of n log2 ML mechanical system (i.e., QImR). The QImR model sub- qubits, where the computational basis jki encodes the ð Þ stantively determines the types of processing tasks and how position i; j of each pixel, andP the coefficient ck encodes ¼ ð 2 Þ1=2 well they can be performed. Our present work is based on a the pixel value, i.e., ck Fi;j= Fi;j for k

031041-2 QUANTUM IMAGE PROCESSING AND ITS APPLICATION … PHYS. REV. X 7, 031041 (2017) ck ¼ 0 for k ≥ ML. Typically, the pixel values must be cosine transform (DCT), similar to the discrete Fourier scaled by a suitable factor before they can be written into transform, is important for numerous applications in the quantum state, such that the resulting quantum state is science and engineering, from data compression of audio normalized. When the image data are stored in a quantum (e.g., MP3) and images (e.g., JPEG), to spectral methods random access memory, this mapping takesP OðnÞ steps for the numerical solution of partial differential equations. j j2 [55]. In addition, it was shown that if ck and k ck can be High-efficiency video coding (HEVC), also known as efficiently calculated by a classical algorithm, constructing H.265, is one of several video compression successors to the n-qubit image state jfi then takes O½polyðnÞ steps the widely used MPEG-4 (H.264). Almost all digital videos [56,57]. Alternatively, QImP could act as a subroutine of a including HEVC are compressed by using basic image larger quantum algorithm receiving image data from other transforms such as 2D DCT or 2D discrete wavelet trans- components [41]. Once the image data are in quantum forms. With the increasing amount of data, the running time form, they could be postprocessed by various quantum increases drastically so that real-time processing is infea- algorithms [4]. In Appendix A, we discuss some other sible, while quantum image transforms show untapped QImR models and make a comparison between the QImR potential to exponentially speed up over their classical we use and others. counterparts. To illustrate QImP, we now discuss several basic 2D B. Quantum image transforms transforms in the framework of QIP, such as the Fourier, Hadamard, and Haar wavelet transforms [59–61]. For these m l Here, we focus on cases where ML ¼ 2 × 2 (an image three 2D transforms, P is the transpose of Q. Quantum n with N ¼ ML ¼ 2 pixels). Image processing on a quan- versions for the one-dimensional Fourier transform (1D tum computer corresponds to evolving the quantum state QFT) [62], 1D , and the 1D Haar jfi under a suitable Hamiltonian. A large class of image wavelet transform take time O½polyðmÞ, which is poly- operations is linear in nature, including unitary trans- nomial in the number of qubits m (see Appendix B for formations, convolutions, and linear filtering (see further details). However, corresponding classical versions Appendix C for details). In the quantum context, the linear take time Oðm2mÞ. When both input data preparation ˆ transformation can be represented as jgi¼Ujfi, with the and output information extraction require no greater than input image state jfi and the output image state jgi. When a O½polyðnÞ steps, QImP, such as the 2D Fourier, Hadamard, linear transformation is unitary, it can be implemented as a and Haar wavelet transforms, can in principle achieve an unitary evolution. Some basic and commonly used image exponential speed-up over classical algorithms. Figure 2 transforms (e.g., the Fourier, Hadamard, and Haar wavelet compares the different requirements on resources for the transforms) can be expressed in the form G ¼ PFQ, with the resulting image G and a row (column) transform matrix ð Þ ˆ (a) P Q [5]. The corresponding unitary operator U can then Space resources Time cost be written as Uˆ ¼ QT ⊗ P, where P and Q are now unitary Coding Haar Fourier Hadamard Edge detection operators corresponding to the classical operations. That is, the corresponding unitary operations of n qubits can be Classical bits represented as a direct product of two independent oper- Quantum qubits ations, with one acting on the first l ¼ log2 L qubits and the other on the last m ¼ log2 M qubits. (b) (c) 1010 The final stage of QImP is to extract useful information 108 Edge detection & Haar 108 from the processed results. Clearly, to read out all the Classical 106 Fourier & Hadamard components of the image state jgi would require Oð2nÞ 106 Quantum Haar 4 j i 4 10 operations. However, often one is interested not in g 10 Quantum Fourier Time cost Time itself but in some significant statistical characteristics or 2 102 Quantum Hadamard 10 Quantum

Number of bits & qubits Quantum Edge detection useful global features about image data [41], so it is possibly 0 100 10 1 2 3 4 5 6 7 unnecessary to read out the output image explicitly. When the 101 103 105 107 10 10 10 10 10 10 10 required information is, e.g., a binary result, as in the example Number of pixels N Number of pixels N of pattern matching and recognition, the number of required operations could be significantly smaller. For example, the FIG. 2. (a) Comparison of resource costs of classical and j i j 0i quantum image processing for an image of N ¼ M × L (i.e., similarity between g and the template image g (associated ¼ h j 0i n log2 N) pixels with d-bit depth. (b) Space resources com- with an inner product g g ) can be efficiently extracted via parison. Top (bottom) curve represents classical (quantum) the SWAP test [58] (see Appendix D for a simple example of algorithms, with d ¼ 36. (c) Time cost comparison. The two recognizing specific patterns). curves at the top of this graph represent classical algorithms, and Basic transforms are commonly used in digital media the four curves (Quantum Haar, Quantum Fourier, etc.) at the and signal processing [5]. As an example, the discrete bottom represent quantum algorithms.

031041-3 XI-WEI YAO et al. PHYS. REV. X 7, 031041 (2017)

(a) 19 19 19 classical and quantum algorithms, in terms of the size of the F1 F2 F1 F3 F132C TF2(s)3 19 register (i.e., space) and the number of steps (i.e., time). 1 19 19 F -56444.8 F1 F2 4.8 13 19 C F2 -129.0 -42682.8 19 6.8 C. Experimental demonstrations F3 19 F3 -33131.7 We now proceed to experimentally demonstrate, on a 51.5 64.6 4.4 nuclear quantum computer, some of these elementary 13C 39.1 -275.6 -297.7 15480.1 7.9 image transforms. With established processing techniques [63,64], NMR has been used for many demonstrations of (b) Input image state preparation quantum information processing [47,62,65,66]. Gz Gz 19 As a simple test image, we choose a 4 × 4 chessboard F1 19 pattern, F2 19 UPPS1 UPPS2 Uencode 2 3 F3 1010 6 7 13C 1 6 01017 F ¼ pffiffiffi 6 7; ð2Þ b 2 2 4 10105 (c) Haar Fourier Hadamard 0101 H H

H H R H H whose encoding and processing require four qubits. We H H therefore chose iodotrifluoroethylene (C2F3I) as a 4-qubit quantum register, whose molecular structure and relevant H H R H H 19 19 19 properties are shown in Fig. 3(a). We label F1, F2, F3, 13 and C as the first, second, third, and fourth qubit, FIG. 3. (a) Properties of the iodotrifluoroethylene molecule. respectively. The natural Hamiltonian of this system in The chemical shifts and J-coupling constants (in Hz) are given by the doubly rotating frame [67] is the diagonal and nondiagonal elements, respectively. The mea- 13 sured spin-lattice relaxation times T1 are 21 s for C and 12.5 s for 19F. The chemical shifts are given with respect to the reference X4 X4 π H ¼ πν σj þ J σjσr; ð3Þ frequencies of 100.62 MHz (carbon) and 376.48 MHz (fluorines). int j z 2 jr z z (b) Preparation of the input image states. Two unitary operators j¼1 1≤j

031041-4 QUANTUM IMAGE PROCESSING AND ITS APPLICATION … PHYS. REV. X 7, 031041 (2017)

2 3 11 1 1 compensated [71]. The resulting fidelities for the π refo- cusing rotations range from 97.2% to 99.5%, and for the 6 1 −1 − 7 1 6 i i 7 π=2 rotations from 99.7% to 99.9%. We use the GRAPE QFT4 ¼ 6 7; ð6Þ 2 4 1 −11−1 5 technique to further improve the control performance. The 1 −i −1 i compilation procedure generates a shaped pulse of rela- tively high fidelity, which serves as a good starting point and for the gradient iteration. So the GRAPE search quickly reaches a high performance. The final pulse has a numerical   1 11 fidelity of ≈99.9%, after taking into account 5% rf H ¼ pffiffiffi : ð7Þ inhomogeneity. The whole pulse durations of implement- 2 1 −1 ing the Haar, Fourier, and Hadamard transforms are 21.95, 19.86, and 3.81 ms, respectively. The corresponding quantum circuits and the actual pulse Since the isotropic composition of our sample corre- sequences in our experiments are shown in Figs. 3(c) and 4, sponds to natural abundance, only ≈1% of the molecules respectively. Each unitary rotation in the pulse sequences contain a 13C nuclear spin and can therefore be used as is implemented through a Gaussian selective soft pulse, quantum registers. To distinguish their signal from that and a compilation program is employed to increase the 12 much larger background of molecules containing C fidelity of the entire selective pulse network [70]. The nuclei, we do not measure the signal of the 19F nuclear program systematically adjusts the irradiation frequencies, spins directly, but transfer the states of the 19F spins to the rotational angles, and transmission phases of the selective 13 C spin by a SWAP gate and read out the state information pulses, so that up to first-order dynamics, the phase errors 19 13 and unwanted evolutions of the sequence are largely of the F spins through the C spectra. Thus, all signals of these four qubits are obtained from the 13C spectra. We apply the Haar wavelet, Fourier, and Hadamard (a)

19 transforms to the input 2D pattern, using the corresponding F1

19 sequences of rf pulses. To examine if the experiments have F2 19 produced the correct results, we perform quantum state F3

13C tomography [72] of the input and output image states. Compared with theoretical density matrices, the input- (b) (c) image state and the corresponding transformed-image

19 19 states have fidelities in the range of [0.961, 0.975], As F1 F1 an alternative to quantum state tomography, we also 19 19 P F2 F2 jψ i¼ 16 cexptjki 19 19 reconstruct state vectors expt k¼1 k directly F3 F3 from the experimental spectra. The input-image and the 13C 13C transformed-image states are experimentally read out and (d) the decoded image arrays are displayed in Fig. 5. The top row shows the experimental spectra. The middle row shows the corresponding measured image matrices (only the real parts, since the imaginary parts are negligibly

1 2 small) as 3D bar charts whose pixel values are equal to the (e) coefficients of the quantum states. The bottom row repre- sents the same image data as 2D gray scale (visual intensity) pictures. The experimental and theoretical data agree quite well with each other, with the image ∥ − ∥ ∥ ∥ ≈ 0 08 Euclidean distances [73] Fexpt Fth = Fth . in the

1 2 input data and ∈ ½0.09; 0.12 in the resulting data after processing. FIG. 4. Pulse sequences for implementing the (a) Haar, (b) Fourier, (c) Hadamard image transform, (d) the operation III. QUANTUM EDGE DETECTION ALGORITHM ½−iðI1I2þI3I4Þπ ½iðI1I2þI3I4Þπ=2 e z z z z , and (e) e z z z z . Here, τ1 ¼j1=2J34j and A typical image processing task is the recognition of τ2 ¼j1=2J12j − j1=2J34j, respectively. The rectangles represent the rotation RðθÞ with the phases given above the rectangles. boundaries (intensity changes) between two adjacent The rotation angles θ1 ¼−0.1282π, θ2 ¼−0.2634π, θ3 ¼0.0894π, regions [74]. This task is not only important for digital θ4 ¼ −2πν1τ2, θ5 ¼ −2πν2τ2, θ6 ¼ −2πν3τ1, θ7 ¼ θ4=2, image processing, but is also used by the brain: It has θ8 ¼ θ5=2, and θ9 ¼ θ6=2. The time order of the pulse sequence been shown that the brain processes visual information by is from left to right. responding to lines and edges with different neurons [75],

031041-5 XI-WEI YAO et al. PHYS. REV. X 7, 031041 (2017)

(a) (b) (c) (d) Input Haar Fourier Hadamard 3.2

Amplitude (arb. unit) 200 0 −200 200 0 −200 200 0 −200 200 0 −200 Frequency (Hz) Frequency (Hz) Frequency (Hz) Frequency (Hz)

0.6 0.4 0.2

Pixel value 0

1 2 4 3 3 2 4 1 1.0

0.5 1 2

Gray scale 4 0 3 2 3 4 1

FIG. 5. Experimental results of quantum image transformations. (a) Input 4 × 4 image, (b) Haar-transformed image, (c) Fourier- transformed image, (d) Hadamard-transformed image. In (a), the spectral amplitude is zoomed-in by 3.2 times. The experimental spectra (top) of the 13C qubit were obtained by π=2 readout pulses, shown as blue curves. The simulated spectra are denoted as red curves, shifted for clarity. The experimentally reconstructed images (only real parts are displayed since all imaginary parts are negligibly small) are shown as 3D bar charts (middle). Their 2D gray scale (visual intensity) pictures (bottom) are displayed with each square representing one pixel in the images.

2 3 which is an essential step in many pattern recognition tasks. 1100 00 6 7 Classically, edge detection methods rely on the computa- 6 1 −10 0 007 tion of image gradients by different types of filtering masks 6 7 6 0011 007 [5]. Therefore, all classical algorithms require a computa- 6 7 1 6 7 tional complexity of at least Oð2nÞ because each pixel 6 001−1 007 I2n−1 ⊗ H ¼ pffiffiffi 6 7; ð8Þ 2 6 ...... 7 needs to be processed. A quantum algorithm has been 6 ...... 7 6 ...... 7 proposed that is supposed to provide an exponential speed- 6 7 up compared with existing edge extraction algorithms [76]. 4 0000 115 However, this algorithm includes a COPY operation and a 0000 1 −1 quantum black box for calculating the gradients of all the pixels simultaneously. For both steps, no efficient imple- −1 −1 −1 2n 2n mentations are currently available. Based on the afore- where I2n is the ×P unit matrix. For an n-qubit j i¼ N−1 j i ¼ 2n mentioned QImR, we propose and implement a highly input image state f k¼0 ck k (N pixels), we j i¼ð −1 ⊗ Þj i efficient quantum algorithm that finds the boundaries have the output image state g I2n H f as between two regions in Oð1Þ time, independent of the 2 3 2 3 image size. Further discussions regarding more general c0 c0 þ c1 6 7 6 7 filtering masks are given in Appendix C. 6 7 6 7 6 c1 7 6 c0 − c1 7 Basically, a Hadamardpffiffiffi gate H, which convertspffiffiffi a 6 7 6 7 6 c2 7 6 c2 þ c3 7 qubit j0i → ðj0iþj1iÞ= 2 and j1i → ðj0i − j1iÞ= 2,is 6 7 1 6 7 6 7 pffiffiffi 6 7 applied to detect the boundary. Since the positions of any I2n−1 ⊗ H∶6 c3 7 ↦ 6 c2 − c3 7: ð9Þ 6 7 2 6 7 pair of neighboring pixels in a picture column are given by 6 7 6 7 6 7 6 7 the binary sequences b1…bn−10 and b1…bn−11, with bj ¼ 6 7 6 7 4 c −2 5 4 c −2 þ c −1 5 0 or 1, their pixel values are stored as the coefficients N N N cN−1 cN−2 − cN−1 cb1…bn−10 and cb1…bn−11 of the corresponding computational basis states. The Hadamard transform on the last qubit changes them to the new coefficients c … 0 c … 1. − b1 bn−1 b1 bn−1 Here, we are interested in the difference cb1…bn−10 The total operation is then cb1…bn−11 (the even elements of the resulting state): If the

031041-6 QUANTUM IMAGE PROCESSING AND ITS APPLICATION … PHYS. REV. X 7, 031041 (2017) two pixels belong to the same region, their intensity (a) (b) values are identical and the difference vanishes, other- wise their difference is nonvanishing, which indicates a region boundary. The edge information in the even positions can be extracted by measuring the last qubit. Conditioned on the measurement result of the last qubit being 1, the state of the first n − 1 qubits encodes the domain boundaries. Therefore, this procedure yields the horizontal boundaries between pixels at positions 0=1, 2=3,etc. FIG. 6. Numerical simulation for the QHED algorithm. (a) Input To obtain also the boundaries between the remaining 256 × 256 image. (b) Output image encoding the edge informa- pairs 1=2, 3=4, etc., we apply the n-qubit amplitude tion. The pixels in white and black have amplitude values 0 and 1, permutation to the input image state, yielding a new image respectively. state jf0i with its odd (even) elements equal to the even 2 3 j i 0 ¼ 0100 (odd) elements of the input one f (e.g., c2k c2kþ1 and 0 6 7 c ¼ c2 þ2). The quantum amplitude permutation can 1 6 11107 2kþ1 k F ¼ pffiffiffi 6 7 ð10Þ be efficiently performed in O½polyðnÞ time [61]. Applying e 2 2 4 11115 again a single-qubit Hadamard rotation to this new image 0000 state jf0i, we get the remaining half of the differences. An alternative approach for obtaining all boundary values is to in a quantum state jfei of our 4-qubit quantum register. use an ancilla qubit in the image encoding (see Appendix E We then apply a single-qubit Hadamard gate to the last for a suitable ). For example, a 2-qubit qubit while keeping the other qubits untouched, i.e., image state ðc0;c1;c2;c3Þ can be redundantly encoded in ð Þ three qubits as c0;c1;c1;c2;c2;c3;c3;c0 . After applying (a) (b) a Hadamard gate to the last qubit of the new image state, we Input Output obtain the state ðc0 þ c1;c0 − c1;c1 þ c2;c1 − c2;c2 þ c3; 1.8 c2 − c3;c3 þ c0;c3 − c0Þ. By measuring the last qubit, conditioned on obtaining 1, we obtain the reduced state ðc0 − c1;c1 − c2;c2 − c3;c3 − c0Þ, which contains the full

boundary information. With image encoding along differ- Amplitude (arb. unit) ent orientations, the corresponding boundaries are detected, 200 0 −200 200 0 −200 e.g., row (column) scanning for the vertical (horizontal) Frequency (Hz) Frequency (Hz) boundary. (c) (d) This quantum Hadamard edge detection (QHED) algo- 0.4 rithm generates a quantum state encoding the information 0.2 about the boundary. Converting that state into classical Pixel value 0 information will require Oð2nÞ measurements, but if the 1 2 4 goal is, e.g., to discover if a specific pattern is present in 3 3 4 2 1 the picture, a measurement of single local 1.0 may be sufficient. A good example is the SWAP test (see 0.5 Appendix D), which determines the similarity between a 1 2 4 resulting image and a reference image. Gray scale 0 3 2 3 4 1 As a numerical example, Fig. 6 shows the outcome of the QHED algorithm simulated on a classical computer for FIG. 7. Experimental results of the QHED algorithm. The 13 an input binary (b=w) image Fcat. For this simple demon- upper panels are the C spectra (blue curves) for (a) the input stration, we use only a binary image; nevertheless, the image Fe and (b) output image representing the edge information, QHED algorithm is also valid for an image with general along with the simulated ones (red curves). The simulated spectra 256 256 are shifted for clarity. In (a), the spectral amplitude is zoomed-in gray levels. A × image Fcat is encoded into a j i 216 ¼ 65536 by 1.8 times. In (b), the top (bottom) spectrum is the result after quantum state fcat with 16 qubits instead of 0 applying a Hadamard gate to jfei (the processed image jfei after classical bits (i.e., 8 kB). Then a unitary operator I215 ⊗ H 13 j i the amplitude permutation). The C spectra were obtained by is applied to fcat . The resulting image decoded from the applying π=2 readout pulses. The lower two panels are the image output state demonstrates that the QHED algorithm can array results of (c) the input 4 × 4 image and (d) the output image successfully detect the boundaries in the image. representing the edge information. The images are plotted as To test the QHED algorithm experimentally, we encode amplitude 3D bar charts (top) and 2D visual intensity pictures a simple image (bottom) with each square representing one pixel.

031041-7 XI-WEI YAO et al. PHYS. REV. X 7, 031041 (2017)

ˆ Ue ¼ I8 ⊗ H. The edge information with half of the pixels area to explore and discover more interesting practical ˆ applications involving QImP and AI. This paradigm is (even positions) in the resulting state jgei¼Uejfei is produced, which can be read out from the experimental likely to outperform the classical one and works as an spectra. We separately perform two experiments to obtain efficient solution in the era of big data. the boundaries for odd and even positions with and without the amplitude permutation, as described above. ACKNOWLEDGMENTS To test if the processing result is correct, we measure the We are grateful to Emanuel Knill for helpful comments and input and output image states and obtain their fidelities in discussions on the manuscript. We also thank Fu Liu, W. the range of [0.972, 0.981]. The experimental results of Zhao, X. N. Xu, H. P.Peng, S. Wei, J. Zhang, and X. Y.Zheng boundary information are shown in Fig. 7, along with for technical assistance, C.-Y. Lu, Z. Chen, S.-Y. Ding, J.-W. some corresponding experimental spectra. Compared Shuai, Y.-F. Chen, Z.-G. Liu, W. Kong, and J. Q. Gu for with the theoretical data, the experimental input and inspiration and fruitful discussions, and R. Han, X. Zhou, output images have image Euclidean distance of 0.06 and J. Du, and Z. Tian for a great encouragement and helpful 0.08, respectively. conversations. This work is supported by National Key Basic Research Program of China (Grants No. 2013CB921800 IV. CONCLUSION and No. 2014CB848700), the National Science Fund In summary, we demonstrate the potential of quantum for Distinguished Young Scholars of China (Grant image processing to alleviate some of the challenges brought No. 11425523), the National Natural Science Foundation by the rapidly increasing amount ofimage processing. Instead of China (Grants No. 11375167 and No. 11227901), the of the QImR models used in previous theoretical research Strategic Priority Research Program (B) of the CAS (Grant on QImP, we encode the pixel values of the image in the No. XDB01030400), Key Research Program of Frontier probability amplitudes and the pixel positions in the computa- Sciences of the CAS (Grant No. QYZDY-SSW-SLH004), tional basis states. Based on this QImR, which reduces the and the Deutsche Forschungsgemeinschaft through Su required qubit resources, we discuss the principle of QImP 192/24-1. Z. Liao acknowledges support from the Qatar and experimentally demonstrate the feasibility of a number of National Research Fund (QNRF) under the NPRP Project fundamental quantum image processing operations, such No. 7-210-1-032. J.-Z. Li acknowledges support from the as the 2D Fourier transform, the Hadamard, and the Haar Natural Science Foundation of Guangdong Province (Grant wavelet transform, which are usually included as subroutines No. 2014A030310038). in more complicated tasks of image processing. These X.-W. Y. and H. W. contributed equally to this work. quantum image transforms provide exponential speed-ups over their classical counterparts. As an interesting and practical application, we present and experimentally imple- APPENDIX A: COMPARISON OF QImRs ment a highly efficient quantum algorithm for image edge Thus far, several QImR models have been proposed. In detection, which employs only one single-qubit Hadamard 2003, Venegas-Andraca and Bose suggested the “qubit gate to process the global information (edge) of an image; lattice” model to represent quantum images [52] where each the processing runs in Oð1Þ time, instead of Oð2nÞ as in the pixel is represented by a qubit, therefore requiring 2n qubits classical algorithms. Therefore, this algorithm has significant for an image of 2n pixels.Thisisaquantum-analog advantages over the classical algorithms for large image data. presentation of classical images without any gain from It is completely general and can be implemented on any quantum speed-up. A flexible representation of quantum general-purpose quantum computer, such as trapped ions images (FRQI) [53] integrates the pixel value and position [77,78], superconducting [45,48,79], and photonic quantum þ 1 informationinanimageintoan(pffiffiffiffiffi P n )-qubit quantum state computing [80,81]. Our experiment serves as a first exper- n ð1 2nÞ 2 −1ð θ j0iþ θ j1iÞj i imental study towards practical applications of quantum = k¼0 cos k sin k k , where the angle θ computers for digital image processing. k in a single qubit encodes the pixel value of the corre- j i In addition to the computational tasks we show in this sponding position k . A novel enhanced quantum represen- j ð Þi paper, quantum computers have the potential to resolve tation (NEQR) [54] uses the basis state f k of d qubits to other challenges of image processing and analysis, such as store the pixel value, instead of an angle encoded in a qubit machine learning, linear filtering and convolution, multi- in FRQI,pffiffiffiffiffi P i.e., an image is encoded as such a quantum state ð1 2nÞ 2n−1 j ð Þij i j ð Þi¼j 0 1… d−1i scale analysis, face and pattern recognition, and image = k¼0 f k k ,where f k CkCk Ck , – 0 1… d−1 and video coding [4,46 49]. Image and video information with a binary sequence CkCk Ck encoding the pixel value encoded in qubits can be used not only for efficient fðkÞ.TableI compares our present QImR, which we refer processing but also for securely transmitting these data to as quantum probability image encoding (QPIE), with the through networks protected by . The other two main quantum representation models: FRQI theoretical and experimental results we present here may and NEQR. It clearly shows that the QImR we use here well stimulate further research in these fields. It is an open (QPIE) requires fewer resources than the others.

031041-8 QUANTUM IMAGE PROCESSING AND ITS APPLICATION … PHYS. REV. X 7, 031041 (2017)

¼ð Þ ¼ ¼ 2m TABLE I. Comparison of different QImRs for an image F Fi;j M×L with d-bit depth (for the case M L and n ¼ 2m).

Image representation FRQI NEQR QPIE P P P Quantum state ð1 2mÞ 22m−1ð θ j0iþ θ j1iÞj ið1 2mÞ 22m−1 j ð Þij iji¼ 22m−1 j i = k¼0 cos k sin k k = k¼0 f k k f k¼0 ck k Qubit resource 1 þ 2mdþ 2m 2m Pixel-value qubit 1 d 0 θ ð Þ¼ 0 1… d−1 Pixel value k f k CkCk Ck ck Pixel-value encoding Angle Basis of qubits

APPENDIX B: QUANTUM WAVELET that is, A2 is a Hadamard transform. We can recursively TRANSFORM decompose the quantum Haar wavelet transform (Fig. 8)as follows: Here, we discuss the implementation circuit and com-   plexity of the quantum Haar wavelet transform. Generally, A 2 m ¼ M= ð ⊗ Þ ð Þ the M × M Haar [82] wavelet transform AM (M ¼ 2 , AM SM IM=2 A2 ; B3 I 2 m ¼ 0; 1; 2; …) can be defined by the following equation M= as where SM is the qubit cyclic right shift permutation: j … i¼j … i ¼ 0   SM i1i2 im−1im imi1i2 im−1 , and with ij or 1 AM=2 ⊗ BX and m the number of qubits. Specifically, S4 is the SWAP A ¼ ; ðB1Þ M ⊗ gate to interchange the states of the two qubits: ji1i2i → IM=2 BX¯ ji2i1i. Therefore, the corresponding circuit consists of the following controlled gates. ¼ 1 2 2 0 1 2 −1 where A1 pffiffiffi, IM=2 is a M= ×pM=ffiffiffi unit operator, (1) C ðHÞ;C ðHÞ;C ðHÞ; …;Cm ðHÞ, ¼½11 2 ¼½1 − 1 2 0 1 m−2 BX = , and BX¯ = . This implies, for (2) C ðS2m Þ;C ðS2m−1 Þ; …;C ðS4Þ. M ¼ 2, Here, CkðUÞ is a multiple qubit controlled gate described as follows:     B 1 11 ¯ ¯ ¯ X k i1i2…i A2 ¼ ¼ pffiffiffi ¼ H; ðB2Þ C ðUÞji1i2…i ijψi¼ji1i2…i iU k jψi; ðB4Þ 1 −1 k k BX¯ 2 ¯ ¯ ¯ where i1i2…i in the exponent of U means the product of k ¯ ¯ ¯ ¯ the bits’ inverse i1i2…ik, and i ¼ NOTðiÞ. That is, if the first k control qubits are all in state j0i, the m − k qubit unitary operator U is applied to the last m − k target qubits, = log M 2 otherwise the identity operator is applied to the last m − k qubits SM AM/2 target qubits. Since S2m−k can be implemented by ðm − k − 1Þ SWAP k H gates, the circuit for C ðS2m−k Þ is composed of ðm − k − 1Þ CkðSWAPÞ gates. C1ðSWAPÞ can be implemented by 3 C2ðNOTÞ gates [59]. Hence, the implementation of k kþ1 C ðS2m−k Þ needs in total 3ðm − k − 1Þ C ðNOTÞ gates. Both CkðHÞ and CkðNOTÞ can be implemented with linear complexity, for k ¼ 0; …;m− 1. Hence, we conclude that the quantum Haar wavelet transform can be implemented by Oðm3Þ elementary gates.

APPENDIX C: IMAGE SPATIAL FILTERING H HHHH Spatial filtering is a technique of image processing, S M AM/2 such as image smoothing, sharpening, and edge enhance- ment, by operating the pixels in the neighborhood of the FIG. 8. Quantum circuit for the Haar wavelet transform AM. H is a Hadamard gate, and A2 ¼ H for the case M ¼ 2. SM is corresponding input pixel. The filtered value of the target the qubit cyclic right shift permutation SM∶ji1i2…im−1imi → pixel is given by a linear combination of the neighborhood jimi1i2…im−1i, which can be implemented by m − 1 SWAP gates. pixels with the specific weights determined by the mask

031041-9 XI-WEI YAO et al. PHYS. REV. X 7, 031041 (2017) 2 3 values [5]. For example, given an input image F ¼ 0 ðF Þ 3 3 6 7 i;j M×M and a general × filtering mask, 6 w13 w23 w33 7 6 7 6 ...... 7 2 3 6 . . . 7 ¼ 6 7 ð Þ w11 w12 w13 V3 6 7 : C5 6 ...... 7 6 7 6 . . . 7 W ¼ 4 w21 w22 w23 5; ðC1Þ 6 7 4 w13 w23 w33 5 w31 w32 w33 0 M×M spatial filtering will give theP output image G ¼ 3 ðG Þ G ¼ w F þ −2 þ −2 i;j M×M with the pixel i;j u;v¼1 uv i u ;j v Proof.—Since g⃗¼ vecðGÞ, we have gk ¼ Gt;sþ1, with ð2 ≤ i; j ≤ M − 1Þ. Here, we construct a linear filtering k ¼ t þ Ms (1 ≤ k ≤ M2; 1 ≤ t ≤ M; 0 ≤ s ≤ M − 1). For operator U such that g⃗¼ Uf⃗, where f⃗¼ vecðFÞ and t ≠ 1, M and s ≠ 0, M − 1,wehave g⃗¼ vecðGÞ. f⃗and g⃗are both M2-dimensional vectors, 2 2 ¼ ¼ð Þ and the dimension of U is M × M . We prove that U can gk Gt;sþ1 W F t;sþ1 be constructed as ¼ w11Ft−1;s þ w21Ft;s þ w31Ftþ1;s

þ w12F −1 þ1 þ w22F þ1 þ w32F þ1 þ1 2 3 t ;s t;s t ;s E þ w13F −1 þ2 þ w23F þ2 þ w33F þ1 þ2: 6 7 t ;s t;s t ;s 6 V1 V2 V3 7 6 7 6 . . . 7 PM2 6 ...... 7 ⃗¼ ⃗ ¼ 6 7 Let h Uf, then we have hk i¼1Uk;ifi. From the U ¼ 6 7; ðC2Þ 6 ...... 7 expression of U in Eq. (C2), we can see that the nonzero 6 . . . 7 6 7 elements are 4 V1 V2 V3 5 ¼ ¼ E Uk;Mðs−1Þþt−1 w11;Uk;Mðs−1Þþt w21;

Uk;Mðs−1Þþtþ1 ¼ w31;Uk;Msþt−1 ¼ w12; where E is an M × M identity matrix, and V1, V2, V3 are Uk;Msþt ¼ w22;Uk;Msþtþ1 ¼ w32; M × M matrices defined by Uk;Mðsþ1Þþt−1 ¼ w13;Uk;Mðsþ1Þþt ¼ w23; ¼ 2 3 Uk;Mðsþ1Þþtþ1 w33; 0 6 7 ⃗ 6 w11 w21 w31 7 and for other i, U ¼ 0. Since f ¼ vecðFÞ,wehave 6 7 k;i 6 . . . 7 6 ...... 7 6 7 f ð −1Þþ −1 ¼ F −1 ;fð −1Þþ ¼ F ; V1 ¼ 6 7 ; ðC3Þ M s t t ;s M s t t;s 6 ...... 7 6 . . . 7 f ð −1Þþ þ1 ¼ F þ1 ;fþ −1 ¼ F −1 þ1; 6 7 M s t t ;s Ms t t ;s 4 w11 w21 w31 5 fMsþt ¼ Ft;sþ1;fMsþtþ1 ¼ Ftþ1;sþ1; 0 M×M fMðsþ1Þþt−1 ¼ Ft−1;sþ2;fMðsþ1Þþt ¼ Ft;sþ2;

fMðsþ1Þþtþ1 ¼ Ftþ1;sþ2:

By direct comparison, it is readily seen that hk ¼ gk. 2 3 ⃗ 1 Hence, we have g⃗¼ Uf. 6 7 We can deduce that U is unitary if and only if w22 ¼1 6 w12 w22 w32 7 6 7 and other elements are all zero in W [Eq. (C1)]. In general, 6 . . . 7 6 . . . 7 the linear transformation of spatial filtering is nonunitary. 6 . . . 7 V2 ¼ 6 7 ; ðC4Þ For a nonunitary linear transformation U, we can try to 6 ...... 7 6 . . . 7 embed it in a bigger quantum system, and perform a 6 7 bigger unitary operation to realize an embedded trans- 4 w12 w22 w32 5 formation U [83]. Alternatively, the quantum matrix- 1 M×M inversion techniques [41,50] could also help to perform

031041-10 QUANTUM IMAGE PROCESSING AND ITS APPLICATION … PHYS. REV. X 7, 031041 (2017) some nonunitary linear transformations on a quantum 1 computer. 2 APPENDIX D: DETECTING SYMMETRY BY QImP 3 D2n+1 Here, we present a highly efficient quantum algorithm for recognizing an inversion-symmetric image, which outperforms state-of-the-art classical algorithms with an Ancilla H H exponential speed-up. First, we use the NOT gate (i.e., the σ Pauli X operator x) to rotate the input image 180° with FIG. 9. Quantum circuit for the QHED algorithm with an respect to the image center. Then we utilize the SWAP test auxiliary qubit. H is a Hadamard gate, and D2nþ1 is an amplitude [58] to detect the overlap between the input and rotated permutation operation for n þ 1 qubits. images: The larger the overlap, the better the inversion symmetry of original image. This algorithm is described as Fig. 9. The operation D nþ1 is an n þ 1-qubit amplitude follows. 2 permutation, which can be written in matrix form as (1) Encode an input M × L ¼ 2m × 2n image into a j i ¼ þ 2 3 quantum state f with n m l qubits. 0100 00 (2) Perform a NOT operation on each qubit such that 6 7 j … i 6 0010 007 the basis i1i2 in switches to the complementary 6 7 j¯ ¯ …¯ i ¼ ⊗n ¼ σ⊗n 6 7 basis i1i2 in (i.e., UNOT NOT x ), 6 0001 007 ¯ 6 7 where i1;i2; …;in ¼ 0 or 1 and i ¼ NOTðiÞ. Since þ1 ¼ 6 0000 007 ð Þ þ ¯ ¼ 1 … þ ¯ ¯ …¯ ¼ 11…1 D2n 6 7: E1 i i , we have i1i2 in i1i2 in . 6 ...... 7 6 ...... 7 Therefore, the bases are swapped around the center; 6 ...... 7 6 7 i.e., the image is rotated by 180°. 4 0000 015 (3) Using the SWAP test method [4,47], we detect the overlap between two states before and after applying 1000 00 NOT operation to the input pattern; a measured h j j i It can be efficiently implemented in O½polyðnÞ time overlap value f UNOT f [84] can efficiently supply useful information on the inversion symmetry of the [61]. For an input image encoded in an n-qubit state j i¼ð … ÞT input pattern. f c0;c1;c2; ;cN−2;cN−1 , a Hadamard gate is Estimating distances and inner products between state applied to the input state j0i of the auxiliary qubit, yielding vectors of image data in ML-dimensional vector spaces anpffiffiffi (n þ 1)-qubit redundant image state jfi⊗ðj0iþj1iÞ= −1=2 T then takes time Oðlog MLÞ on a quantum computer, which 2¼2 ðc0;c0;c1;c1;c2;c2;…;cN−2;cN−2;cN−1;cN−1Þ . is exponentially faster than that of classical computers The amplitude permutation D2nþ1 is performed to yield a −1=2 [85,86]. Here, a specific example of a 2 × 2 image is new redundant image state 2 ðc0;c1;c1;c2;c2;c3; …; T provided for illustration. To rotate the input image matrix cN−2;cN−1;cN−1;c0Þ . After applying a Hadamard gate to −1 by 180° as follows, the last qubit of this state, we obtain the state 2 ðc0 þ     c1;c0 − c1;c1 þ c2;c1 − c2;c2 þ c3;c2 − c3;…;cN−2 þ cN−1; 13 Rotation 42 − þ − ÞT ⟶ : ðD1Þ cN−2 cN−1;cN−1 c0;cN−1 c0 . By measuring the last 24 180° 31 qubit, conditioned on obtaining 1, we obtain the n-qubit −1 state jgi¼2 ðc0 − c1;c1 − c2;c2 − c3; …;cN−2 − cN−1; The input state of left-hand image is ðj00iþ2j01iþ T pffiffiffiffiffi cN−1 − c0Þ , which contains the full boundary information. 3j10iþ4j11iÞ= 30. Applying a NOT gate to each qubit, the inputpffiffiffiffiffi state is transformed to (j11iþ2j10iþ3j01iþ 4j00iÞ= 30 (corresponding to the rotated image on the right-hand side). It is clear that the input image has been [1] D. Marr, Vision: A Computational Investigation into the rotated by 180° around its center, which corresponds to Human Representation and Processing of Visual Informa- point reflection in 2D. tion (W.H. Freeman and Company, San Francisco, 1982). [2] A. M. Turing, Computing Machinery and Intelligence, APPENDIX E: VARIANT OF Mind 59, 433 (1950). QHED ALGORITHM [3] D. Silver, A. Huang, C. Maddison, A. Guez, L. Sifre, G. Driessche, J.Schrittwieser, I. Antonoglou, V.Panneershelvam, In order to produce full boundary values in a single step, M. Lanctot, S. Dieleman, D. Grewe, J. Nham, N. Kalchbren- a variant of the QHED algorithm uses an auxiliary qubit for ner, L. Sutskever, T. Lillicrap, M. Leach, K. Kavukcuoglu, encoding the image. The quantum circuit is shown in T. Graepel, and D. Hassabis, Mastering the Game of Go with

031041-11 XI-WEI YAO et al. PHYS. REV. X 7, 031041 (2017)

Deep Neural Networks and Tree Search, Nature (London) [23] D.-L. Deng, X. Li, and S. D. Sarma, Quantum Entanglement 529, 484 (2016). in Neural Network States, Phys. Rev. X 7, 021021 (2017). [4] P. Rebentrost, M. Mohseni, and S. Lloyd, Quantum Support [24] P. W. Shor, in Proceedings of the 35th Annual Symposium Vector Machine for Big Data Classification, Phys. Rev. on Foundations of (IEEE Computer Lett. 113, 130503 (2014). Society Press, New York, 1994), pp. 124–134. [5] R. C. Gonzalez and R. E. Woods, Digital Image Processing [25] X.-H. Peng, Z.-Y. Liao, N. Xu, G. Qin, X. Zhou, D. Suter, (Prentice-Hall, London, 2007). and J. Du, Quantum Adiabatic Algorithm for Factorization [6] B. M. Lake, R. Salakhutdinov, and J. B. Tenenbaum, and Its Experimental Implementation, Phys. Rev. Lett. 101, Human-Level Concept Learning through Probabilistic 220405 (2008). Program Induction, Science 350, 1332 (2015). [26] L. K. Grover, Helps in Searching for [7] N. Jean, M. Burke, M. Xie, W. M. Davis, D. B. Lobell, a Needle in a Haystack, Phys. Rev. Lett. 79, 325 (1997). and S. Ermon, Combining Satellite Imagery and [27] S. Aaronson and A. Arkhipov, in Proceedings of the Machine Learning to Predict Poverty, Science 353, 790 43rd Annual ACM Symposium on Theory of Computing (2016). (ACM, New York, 2011), pp. 333–342. [8] D. Deutsch, Quantum Theory, the Church-Turing Principle [28] M. A. Broome, A. Fedrizzi, S. Rahimi-Keshari, J. Dove, S. and the Universal Quantum Computer, Proc. R. Soc. A 400, Aaronson, T. C. Ralph, and A. G. White, Photonic Boson 97 (1985). Sampling in a Tunable Circuit, Science 339, 794 (2013). [9] E. Knill, R. Laflamme, and G. J. Milburn, A Scheme for [29] J. B. Spring, B. J. Metcalf, P. C. Humphreys, W. S. Efficient Quantum Computation with Linear Optics, Nature Kolthammer, X.-M. Jin, M. Barbieri, A. Datta, N. (London) 409, 46 (2001). Thomas-Peter, N. K. Langford, D. Kundys, J. C. Gates, [10] D. Aasen, M. Hell, R. V. Mishmash, A. Higginbotham, B. J. Smith, P. G. R. Smith, and I. A. Walmsley, Boson J. Danon, M. Leijnse, T. S. Jespersen, J. A. Folk, C. M. Sampling on a Photonic Chip, Science 339, 798 (2013). Marcus, K. Flensberg, and J. Alicea, Milestones Toward [30] M. Tillmann, B. Dakić, R. Heilmann, S. Nolte, A. Szameit, Majorana-Based , Phys. Rev. X 6, and P. Walther, Experimental Boson Sampling, Nat. Pho- 031016 (2016). tonics 7, 540 (2013). [11] J. Yin et al., Satellite-Based Entanglement Distribution over [31] A. Crespi, R. Osellame, R. Ramponi, D. J. Brod, E. F. 1200 Kilometers, Science 356, 1140 (2017). Galvão, N. Spagnolo, C. Vitelli, E. Maiorino, P. Mataloni, [12] S.-K. Liao et al., Satellite-to-Ground Quantum Key Dis- and F. Sciarrino, Integrated Multimode Interferometers tribution, Nature (London) 549, 43 (2017). with Arbitrary Designs for Photonic Boson Sampling, [13] J.-G. Ren et al., Ground-to-Satellite Quantum Teleporta- Nat. Photonics 7, 545 (2013). tion, Nature (London) 549, 70 (2017). [32] H. Wang, Y. He, Y. Li, Z. Su, B. Li, H. Huang, X. Ding, [14] D. E. Browne and T. Rudolph, Resource-Efficient Linear M.-C. Chen, C. Liu, J. Qin, J.-P. Li, Y.-M. He, C. Schneider, Optical Quantum Computation, Phys. Rev. Lett. 95, 010501 M. Kamp, C.-Z. Peng, S. Höfling, C.-Y. Lu, and J.-W. Pan, (2005). High-Efficiency Multiphoton Boson Sampling, Nat. Pho- [15] J.-W. Pan, Z.-B. Chen, C.-Y. Lu, H. Weinfurter, A. tonics 11, 361 (2017). Zeilinger, and M. Żukowski, Multiphoton Entanglement [33] S. Lloyd, Universal Quantum Simulators, Science 273, and Interferometry, Rev. Mod. Phys. 84, 777 (2012). 1073 (1996). [16] X. L. Wang, X. D. Cai, Z. E. Su, M.-C. Chen, D. Wu, L. Li, [34] X.-H. Peng, J. Zhang, J. Du, and D. Suter, Quantum N. L. Liu, C.-Y. Lu, and J.-W. Pan, Simulation of a System with Competing Two- and Three- of Multiple Degrees of Freedom of a Single Photon, Nature Body Interactions, Phys. Rev. Lett. 103, 140501 (2009). (London) 518, 516 (2015). [35] X.-H. Peng and D. Suter, Spin Qubits for Quantum [17] E. Knill, Quantum Computing with Realistically Noisy Simulations, Front. Phys. China 5, 1 (2010). Devices, Nature (London) 434, 39 (2005). [36] G. A. Álvarez and D. Suter, NMR Quantum Simulation of [18] D. Suter and G. A. Álvarez, Protecting Quantum Informa- Localization Effects Induced by Decoherence, Phys. Rev. tion against Environmental Noise, Rev. Mod. Phys. 88, Lett. 104, 230403 (2010). 041001 (2016). [37] X.-H. Peng, Z. H. Luo, W. Zheng, S. Kou, D. Suter, and [19] J. Zhang and D. Suter, Experimental Protection of Two-Qubit J. Du, Experimental Implementation of Adiabatic Passage Quantum Gates against Environmental Noise by Dynamical between Different Topological Orders, Phys. Rev. Lett. 113, Decoupling, Phys. Rev. Lett. 115, 110502 (2015). 080404 (2014). [20] C. Zu, W.-B. Wang, L. He, W.-G. Zhang, C.-Y. Dai, F. [38] G. A. Álvarez, D. Suter, and R. Kaiser, Localization- Wang, and L.-M. Duan, Experimental Realization of Uni- Delocalization Transition in the Dynamics of Dipolar- versal Geometric Quantum Gates with Solid-State Spins, Coupled Nuclear Spins, Science 349, 846 (2015). Nature (London) 514, 72 (2014). [39] M.-C. Chen, D. Wu, Z. Su, X. Cai, X. Wang, T. Yang, L. Li, [21] B. Zeng, X. Chen, D.-L. Zhou, and X.-G. Wen, Quantum N. Liu, C.-Y. Lu, and J.-W. Pan, Efficient Measurement Information Meets Quantum Matter—From Quantum En- of Multiparticle Entanglement with Embedding Quantum tanglement to Topological Phase in Many-Body Systems, Simulator, Phys. Rev. Lett. 116, 070502 (2016). arXiv:1508.02595. [40] J. Li, R. Fan, H. Wang, B. Ye, B. Zeng, H. Zhai, X.-H. Peng, [22] G. H. Low, T. J. Yoder, and I. L. Chuang, Methodology of and J. Du, Measuring Out-of-Time-Order Correlators on a Resonant Equiangular Composite Quantum Gates, Phys. Nuclear Magnetic Resonance , Phys. Rev. X 6, 041067 (2016). Rev. X 7, 031011 (2017).

031041-12 QUANTUM IMAGE PROCESSING AND ITS APPLICATION … PHYS. REV. X 7, 031041 (2017)

[41] A. W. Harrow, A. Hassidim, and S. Lloyd, Quantum [60] P. Hoyer, Efficient Quantum Transforms, arXiv:quant-ph/ Algorithm for Linear Systems of Equations, Phys. Rev. 9702028. Lett. 103, 150502 (2009). [61] A. Fijany and C. Williams, in Proceedings of the 1st [42] X. D. Cai, C. Weedbrook, Z. E. Su, M.-C. Chen, M. Gu, NASA International Conference on Quantum Computing M. J. Zhu, L. Li, N. L. Liu, C.-Y. Lu, and J.-W. Pan, and Quantum Communications (Springer, Berlin, 1998), Experimental Quantum Computing to Solve Systems of pp. 10–33. Linear Equations, Phys. Rev. Lett. 110, 230501 (2013). [62] Y. S. Weinstein, M. A. Pravia, E. M. Fortunato, S. Lloyd, [43] J. Pan, Y. Cao, X. Yao, Z. Li, C. Ju, H. Chen, X. Peng, S. and D. G. Cory, Implementation of the Quantum Fourier Kais, and J. Du, Experimental Realization of Quantum Transform, Phys. Rev. Lett. 86, 1889 (2001). Algorithm for Solving Linear Systems of Equations, Phys. [63] L. M. K. Vandersypen, I. L. Chuang, and D. Suter, in Rev. A 89, 022313 (2014). Encyclopedia of Magnetic Resonance (John Wiley & Sons, [44] S. Barz, I. Kassal, M. Ringbauer, Y. O. Lipp, B. Dakić, Ltd., New York, 2010). A. Aspuru-Guzik, and P. Walther, A Two-Qubit Photonic [64] D. G. Cory, M. D. Price, and T. F. Havel, Nuclear Magnetic Quantum Processor and Its Application to Solving Systems Resonance Spectroscopy: An Experimentally Accessible of Linear Equations, Sci. Rep. 4, 6115 (2014). Paradigm for Quantum Computing, Physica (Amsterdam) [45] Y.R. Zheng, C. Song, M.-C. Chen, B. Xia, W. Liu, Q. Guo, 120D, 82 (1998). L. Zhang, D. Xu, H. Deng, K. Huang, Y. Wu, Z. Yan, D. [65] A. M. Souza, J. Zhang, C. A. Ryan, and R. Laflamme, Zheng, L. Lu, J.-W. Pan, H. Wang, C.-Y. Lu, and X. B. Zhu, Experimental Magic State Distillation For Fault-Tolerant Solving Systems of Linear Equations with a Superconducting Quantum Computing, Nat. Commun. 2, 169 (2011). Quantum Processor, Phys. Rev. Lett. 118, 210504 (2017). [66] X. Peng, H. Zhou, B. B. Wei, J. Cui, J. Du, and R. B. Liu, [46] X. Cai, D. Wu, Z. Su, M.-C. Chen, X.-L. Wang, L. Li, N. Experimental Observation of Lee-Yang Zeros, Phys. Rev. Liu, C.-Y. Lu, and J.-W. Pan, Entanglement-Based Machine Lett. 114, 010601 (2015). Learning on a Quantum Computer, Phys. Rev. Lett. 114, [67] M. H. Levitt, Spin Dynamics: Basics of Nuclear Magnetic 110504 (2015). Resonance (John Wiley & Sons, Ltd., New York, 2008). [47] Z. Li, X. Liu, N. Xu, and J. Du, Experimental Realization of [68] X.-H. Peng, X. Zhu, X. Fang, M. Feng, K. Gao, X. Yang, a Quantum Support Vector Machine, Phys. Rev. Lett. 114, and M. Liu, Preparation of Pseudo-Pure States By Line- 140504 (2015). Selective Pulses in Nuclear Magnetic Resonance, Chem. [48] D. Ristè, M. Silva, C. Ryan, A. Cross, A. Córcoles, J. Phys. Lett. 340, 509 (2001). Smolin, J. Gambetta, J. Chow, and B Johnson, Demon- [69] N. Khaneja, T. Reiss, C. Kehlet, T. Schulte-Herbrüggen, and stration of Quantum Advantage in Machine Learning, S. J. Glaser, Optimal Control of Coupled Spin Dynamics: Quantum Inf. Comput. 3, 16 (2017). Design of NMR Pulse Sequences by Gradient Ascent [49] S. Lloyd, M. Mohseni, and P. Rebentrost, Quantum Princi- Algorithms, J. Magn. Reson. 172, 296 (2005). pal Component Analysis, Nat. Phys. 10, 631 (2014). [70] C. A. Ryan, C. Negrevergne, M. Laforest, E. Knill, and R. [50] N. Wiebe, D. Braun, and S. Lloyd, Quantum Algorithm for Laflamme, Liquid-State Nuclear Magnetic Resonance as a Data Fitting, Phys. Rev. Lett. 109, 050505 (2012). Testbed for Developing Quantum Control Methods, Phys. [51] F. Yan, A. M. Iliyasu, and S. E. Venegas-andraca, A Survey Rev. A 78, 012328 (2008). of Quantum Image Representations, Quantum Inf. Process. [71] J. Li, J. Cui, R. Laflamme, and X.-H. Peng, Selective-Pulse- 15, 1 (2016). Network Compilation on a Liquid-State Nuclear-Magnetic- [52] S. E. Venegas-Andraca and S. Bose, Storing, Processing Resonance System, Phys. Rev. A 94, 032316 (2016). and Retrieving an Image Using Quantum Mechanics, Proc. [72] I. L. Chuang, N. Gershenfeld, M. G. Kubinec, and D. W. SPIE Int. Soc. Opt. Eng. 5105, 137 (2003). Leung, Bulk Quantum Computation with Nuclear Magnetic [53] P. Le, F. Dong, and K. Hirota, A Flexible Representation Resonance: Theory and Experiment, Proc. R. Soc. A 454, of Quantum Images for Polynomial Preparation, Image 447 (1998). Compression, and Processing Operations, Quantum Inf. [73] J. Li and B. Lu, An Adaptive Image Euclidean Distance, Process. 10, 63 (2011). Pattern Recogn. 42, 349 (2009). [54] Y. Zhang, K. Lu, Y. Gao, and M. Wang, NEQR: A Novel [74] D. Marr and E. Hildreth, Theory of Edge Detection, Proc. R. Enhanced Quantum Representation of Digital Images, Soc. B 207, 187 (1980). Quantum Inf. Process. 12, 2833 (2013). [75] D. Hubel, Eye, Brain and Vision (Scientific American Press, [55] V. Giovannetti, S. Lloyd, and L. Maccone, Quantum Random New York, 1995). Access Memory, Phys. Rev. Lett. 100, 160501 (2008). [76] Y. Zhang, K. Lu, and Y. Gao, Qsobel: A Novel Quantum [56] L. Grover and T. Rudolph, Creating Superpositions That Image Edge Extraction Algorithm, Sci. China Inf. Sci. 58,1 Correspond to Efficiently Integrable Probability Distribu- (2015). tions, arXiv:quant-ph/0208112. [77] C. Ospelkaus, U. Warring, Y. Colombe, K. R. Brown, [57] A. N. Soklakov and R. Schack, Efficient State Preparation for J. M. Amini, D. Leibfried, and D. J. Wineland, Microwave a Register of Quantum Bits, Phys. Rev. A 73, 012307 (2006). Gates for Trapped Ions, Nature (London) [58] H. Buhrman, R. Cleve, J. Watrous, and R. de Wolf, Quantum 476, 181 (2011). Fingerprinting, Phys. Rev. Lett. 87, 167902 (2001). [78] G. Higgins, W. Li, F. Pokorny, C. Zhang, F. Kress, C. Maier, [59] M. A. Nielsen and I. L. Chuang, Quantum Computation J. Haag, Q. Bodart, I. Lesanovsky, and M. Hennrich, Single and Quantum Information (Cambridge University Press, Strontium Rydberg Ion Confined in a Paul Trap, Phys. Rev. Cambridge, England, 2000). X 7, 021038 (2017).

031041-13 XI-WEI YAO et al. PHYS. REV. X 7, 031041 (2017)

[79] J. Kelly et al., State Preservation by Repetitive Error [83] S. J. Wei and G. L. Long, Duality Quantum Computer and Detection in a Superconducting Quantum Circuit, Nature the Efficient Quantum Simulations, Quantum Inf. Process. (London) 519, 66 (2015). 15, 1189 (2016). [80] P. Kok, W. J. Munro, K. Nemoto, T. C. Ralph, J. P. Dowling, [84] E. Knill, G. Ortiz, and R. D. Somma, Optimal Quantum and G. J. Milburn, Linear Optical Quantum Computing with Measurements of Expectation Values of , Phys. Photonic Qubits, Rev. Mod. Phys. 79, 135 (2007). Rev. A 75, 012328 (2007). [81] J. Carolan, C. Harrold, C. Sparrow, E. Martinlopez, N. J. [85] S. Lloyd, M. Mohseni, and P. Rebentrost, Quantum Algo- Russell, J. W. Silverstone, and A. Laing, Universal Linear rithms for Supervised and Unsupervised Machine Learning, Optics, Science 349, 711 (2015). arXiv:1307.0411. [82] A. Haar, Zur Theorie der Orthogonalen Funktionensysteme, [86] S. Aaronson, BQP and the Polynomial Hierarchy, arXiv: Math. Ann. 69, 331 (1910). 0910.4698.

031041-14