Top Banner
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 Suter 15,1 Department of Electronic Science, College of Physical Science and Technology, Xiamen University, Xiamen, Fujian 361005, China 2 CAS Key Laboratory of Microscale Magnetic Resonance and Department of Modern Physics, University of Science and Technology of China, Hefei, Anhui 230026, China 3 Institute for Quantum Science and Engineering (IQSE) and Department of Physics and Astronomy, Texas A&M University, College Station, Texas 77843-4242, USA 4 Dahonggou Haydite Mine, Urumqi, Xinjiang 831499, China 5 College of Physical Science and Technology, Yili University, Yining, Xinjiang 835000, China 6 Hefei National Laboratory for Physical Sciences at Microscale and Department of Modern Physics, University of Science and Technology of China, Hefei, Anhui 230026, China 7 Beijing Computational Science Research Center, Beijing 100193, China 8 Institute of Theoretical Physics, Chinese Academy of Sciences, Beijing 100190, China 9 Department of Physics & Astronomy and Center for Theoretical Biological Physics, Rice University, Houston, Texas 77005, USA 10 School of Mathematical Sciences, Peking University, Beijing 100871, China 11 Center for Optics and Optoelectronics Research, College of Science, Zhejiang University of Technology, Hangzhou, Zhejiang 310023, China 12 College of mathematics and statistics, Hanshan Normal University, Chaozhou, Guangdong 521041, China 13 Shandong Institute of Quantum Science and Technology, Co., Ltd., Jinan, Shandong 250101, China 14 Synergetic Innovation Center of Quantum Information and Quantum Physics, University of Science and Technology of China, Hefei, Anhui 230026, China 15 Fakultä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 quantum state 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 qubits compared to existing implementations, and we present image processing algorithms 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 algorithm that completes the task with only one single-qubit 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 Vision is by far the most important channel for obtaining information. Accordingly, the analysis of visual information is one of the most important functions of the human brain [1]. In 1950, Turing proposed the development of machines that would be able to think, i.e., learn from experience and draw conclusions, in analogy to the human brain. Today, this field of research is known as artificial intelligence (AI) [24]. Since then, the analysis of visual information by electronic devices has become a reality that enables machines to directly process and analyze the information contained in images and stereograms or video streams, resulting in rapidly expanding applications in widely separated fields like biomedicine, economics, entertainment, and industry (e.g., automatic pilot) [57]. Some of these tasks can be performed very efficiently by digital data processors, but * [email protected] [email protected] dieter.suter@tudortmund.de Published by the American Physical Society under the terms of the Creative Commons Attribution 4.0 International license. Further distribution of this work must maintain attribution to the author(s) and the published articles title, journal citation, and DOI. PHYSICAL REVIEW X 7, 031041 (2017) 2160-3308=17=7(3)=031041(14) 031041-1 Published by the American Physical Society
14

Quantum Image Processing and Its Application to Edge ...€¦ · Quantum Image Processing and Its Application to Edge Detection: Theory and Experiment Xi-Wei Yao,1,4,5,* Hengyan Wang,2

Jul 27, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Quantum Image Processing and Its Application to Edge ...€¦ · Quantum Image Processing and Its Application to Edge Detection: Theory and Experiment Xi-Wei Yao,1,4,5,* Hengyan Wang,2

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, China2CAS Key Laboratory of Microscale Magnetic Resonance and Department of Modern Physics,

University of Science and Technology of China, Hefei, Anhui 230026, China3Institute for Quantum Science and Engineering (IQSE) and Department of Physics and Astronomy,

Texas A&M University, College Station, Texas 77843-4242, USA4Dahonggou Haydite Mine, Urumqi, Xinjiang 831499, China

5College of Physical Science and Technology, Yili University, Yining, Xinjiang 835000, China6Hefei National Laboratory for Physical Sciences at Microscale and Department of Modern Physics,

University of Science and Technology of China, Hefei, Anhui 230026, China7Beijing Computational Science Research Center, Beijing 100193, China

8Institute of Theoretical Physics, Chinese Academy of Sciences, Beijing 100190, China9Department of Physics & Astronomy and Center for Theoretical Biological Physics, Rice University,

Houston, Texas 77005, USA10School 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, China13Shandong Institute of Quantum Science and Technology, Co., Ltd., Jinan, Shandong 250101, China

14Synergetic Innovation Center of Quantum Information 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 demandson data storage, transmission, and processing power. Encoding the image information in quantum-mechanicalsystems instead of classical ones and replacing classical with quantum information processing may alleviatesome of these challenges. By encoding and processing the image information in quantum-mechanicalsystems, we here demonstrate the framework of quantum image processing, where a pure quantum stateencodes the image information: we encode the pixel values in the probability amplitudes and the pixelpositions in the computational basis states. Our quantum image representation reduces the required number ofqubits compared to existing implementations, and we present image processing algorithms that provideexponential speed-up over their classical counterparts. For the commonly used task of detecting the edge of animage, we propose and implement a quantum algorithm that completes the task with only one single-qubitoperation, independent of the size of the image. This demonstrates the potential of quantum image processingfor 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

Vision is by far the most important channel for obtaininginformation. Accordingly, the analysis of visual information

is one of the most important functions of the human brain[1]. In 1950, Turing proposed the development of machinesthat would be able to “think,” i.e., learn from experience anddraw conclusions, in analogy to the human brain. Today, thisfield of research is known as artificial intelligence (AI) [2–4].Since then, the analysis of visual information by electronicdevices has become a reality that enables machines todirectly process and analyze the information contained inimages and stereograms or video streams, resulting inrapidly expanding applications in widely separated fieldslike biomedicine, economics, entertainment, and industry(e.g., automatic pilot) [5–7]. Some of these tasks can beperformed very efficiently by digital data processors, but

*[email protected][email protected]‡dieter.suter@tu‑dortmund.de

Published by the American Physical Society under the terms ofthe Creative Commons Attribution 4.0 International license.Further distribution of this work must maintain attribution tothe author(s) and the published article’s title, journal citation,and DOI.

PHYSICAL REVIEW X 7, 031041 (2017)

2160-3308=17=7(3)=031041(14) 031041-1 Published by the American Physical Society

Page 2: Quantum Image Processing and Its Application to Edge ...€¦ · Quantum Image Processing and Its Application to Edge Detection: Theory and Experiment Xi-Wei Yao,1,4,5,* Hengyan Wang,2

others remain time-consuming. In particular, the rapidlyincreasing volume of image data as well as increasinglychallenging computational tasks have become importantdriving forces for further improving the efficiency of imageprocessing and analysis.Quantum information processing (QIP), which exploits

quantum-mechanical phenomena such as quantum super-positions and quantum entanglement [8–23], allows one toovercome the limitations of classical computation andreaches higher computational speed for certain problemslike factoring large numbers [24,25], searching an unsorteddatabase [26], boson sampling [27–32], quantum simula-tion [33–40], solving linear systems of equations [41–45],and machine learning [46–48]. These unique quantumproperties, such as quantum superposition and quantumparallelism, may also be used to speed up signal and dataprocessing [49,50]. For quantum image processing, quan-tum image representation (QImR) plays a key role, whichsubstantively determines the kinds of processing tasksand how well they can be performed. A number ofQImRs [51–54] have been discussed.In this article, we demonstrate the basic framework of

quantum image processing based on a different type ofQImR, which reduces the qubit resources required forencoding an image. Based on this QImR, we experimen-tally implement several commonly used two-dimensionaltransforms that are common steps in image processing on aquantum computer and demonstrate that they run expo-nentially faster than their classical counterparts. In addition,we propose a highly efficient quantum algorithm fordetecting the boundary between different regions of apicture: It requires only one single-qubit gate in theprocessing stage, independent of the size of the picture.We perform both numerical and experimental demonstra-tions to prove the validity of our quantum edge detectionalgorithm. These results open up the prospect of utilizingquantum parallelism for image processing.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 severalbasic image transforms on a nuclear magnetic resonance(NMR) quantum information processor. In Sec. III, wepropose a highly efficient quantum edge detection algorithm,along with the proof-of-principle numerical and experimen-tal demonstrations. Finally, in Sec. IV, we summarize theresults and give a perspective for future work.

II. FRAMEWORK OF QUANTUMIMAGE PROCESSING

In Fig. 1, we compare the principles of classical andquantum image processing (QImP). The first step for QImPis the encoding of the 2D image data into a quantum-mechanical system (i.e., QImR). The QImR model sub-stantively determines the types of processing tasks and howwell they can be performed. Our present work is based on a

QImR where the image is encoded in a pure quantum state,i.e., encoding the pixel values in its probability amplitudesand the pixel positions in the computational basis statesof the Hilbert space. In this section, we introduce theprinciple of QImP based on such a QImR, and then presentexperimental implementations for some basic image trans-forms, including the 2D Fourier transform, 2D Hadamard,and the 2D Haar wavelet transform.

A. Quantum image representation

Given a 2D image F ¼ ðFi;jÞM×L, where Fi;j representsthe pixel value at position ði; jÞ with i ¼ 1;…;M andj ¼ 1;…; L, a vector f with ML elements can be formedby letting the firstM elements of f be the first column of F,the next M elements the second column, etc. That is,

f ¼ vecðFÞ¼ ðF1;1; F2;1;…; FM;1; F1;2;…; Fi;j;…; FM;LÞT: ð1Þ

Accordingly, the image data f can be mapped onto a purequantum state jfi ¼ P

2n−1k¼0 ckjki of n ¼ ⌈ log2ðMLÞ⌉

qubits, where the computational basis jki encodes theposition ði; jÞ of each pixel, and the coefficient ck encodesthe pixel value, i.e., ck ¼ Fi;j=ð

PF2i;jÞ1=2 for k < ML and

g=

G PFQ= GM L

= ( ) ×ij

FF

ML

11

21

GG

GML

11

21

Classical

Quantum

Encoding Processing Decoding

n

FM L

= ( ) ×

f =TU Q P

0110...012n bits

qubits

ijF G

F

FIG. 1. Comparison of image processing by classical andquantum computers. F and G are the input and output images,respectively. On the classical computer, an M × L image canbe represented as a matrix and encoded with at least 2n bits[n ¼ ⌈log2ðMLÞ⌉]. The classical image transformation is con-ducted by matrix computation. In contrast, the same image can berepresented as a quantum state and encoded in n qubits. Thequantum image transformation is performed by unitary evolutionU under a suitable Hamiltonian.

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

031041-2

Page 3: Quantum Image Processing and Its Application to Edge ...€¦ · Quantum Image Processing and Its Application to Edge Detection: Theory and Experiment Xi-Wei Yao,1,4,5,* Hengyan Wang,2

ck ¼ 0 for k ≥ ML. Typically, the pixel values must bescaled by a suitable factor before they can be written intothe quantum state, such that the resulting quantum state isnormalized. When the image data are stored in a quantumrandom access memory, this mapping takes OðnÞ steps[55]. In addition, it was shown that if ck and

Pkjckj2 can be

efficiently calculated by a classical algorithm, constructingthe n-qubit image state jfi then takes O½polyðnÞ� steps[56,57]. Alternatively, QImP could act as a subroutine of alarger quantum algorithm receiving image data from othercomponents [41]. Once the image data are in quantumform, they could be postprocessed by various quantumalgorithms [4]. In Appendix A, we discuss some otherQImR models and make a comparison between the QImRwe use and others.

B. Quantum image transforms

Here, we focus on cases whereML ¼ 2m × 2l (an imagewith N ¼ ML ¼ 2n pixels). Image processing on a quan-tum computer corresponds to evolving the quantum statejfi under a suitable Hamiltonian. A large class of imageoperations is linear in nature, including unitary trans-formations, convolutions, and linear filtering (seeAppendix C for details). In the quantum context, the lineartransformation can be represented as jgi ¼ Ujfi, with theinput image state jfi and the output image state jgi. When alinear transformation is unitary, it can be implemented as aunitary evolution. Some basic and commonly used imagetransforms (e.g., the Fourier, Hadamard, and Haar wavelettransforms) can be expressed in the form G ¼ PFQ, withthe resulting image G and a row (column) transform matrixPðQÞ [5]. The corresponding unitary operator U can thenbe written as U ¼ QT ⊗ P, where P andQ are now unitaryoperators corresponding to the classical operations. That is,the corresponding unitary operations of n qubits can berepresented as a direct product of two independent oper-ations, with one acting on the first l ¼ log2 L qubits and theother on the last m ¼ log2 M qubits.The final stage of QImP is to extract useful information

from the processed results. Clearly, to read out all thecomponents of the image state jgi would require Oð2nÞoperations. However, often one is interested not in jgiitself but in some significant statistical characteristics oruseful global features about image data [41], so it is possiblyunnecessary to read out the output image explicitly.When therequired information is, e.g., a binary result, as in the exampleof pattern matching and recognition, the number of requiredoperations could be significantly smaller. For example, thesimilarity between jgi and the template image jg0i (associatedwith an inner product hgjg0i) can be efficiently extracted viathe SWAP test [58] (see Appendix D for a simple example ofrecognizing specific patterns).Basic transforms are commonly used in digital media

and signal processing [5]. As an example, the discrete

cosine transform (DCT), similar to the discrete Fouriertransform, is important for numerous applications inscience and engineering, from data compression of audio(e.g., MP3) and images (e.g., JPEG), to spectral methodsfor the numerical solution of partial differential equations.High-efficiency video coding (HEVC), also known asH.265, is one of several video compression successors tothe widely used MPEG-4 (H.264). Almost all digital videosincluding HEVC are compressed by using basic imagetransforms such as 2D DCT or 2D discrete wavelet trans-forms. With the increasing amount of data, the running timeincreases drastically so that real-time processing is infea-sible, while quantum image transforms show untappedpotential to exponentially speed up over their classicalcounterparts.To illustrate QImP, we now discuss several basic 2D

transforms in the framework of QIP, such as the Fourier,Hadamard, and Haar wavelet transforms [59–61]. For thesethree 2D transforms, P is the transpose of Q. Quantumversions for the one-dimensional Fourier transform (1DQFT) [62], 1D Hadamard transform, and the 1D Haarwavelet transform take time O½polyðmÞ�, which is poly-nomial in the number of qubits m (see Appendix B forfurther details). However, corresponding classical versionstake time Oðm2mÞ. When both input data preparationand output information extraction require no greater thanO½polyðnÞ� steps, QImP, such as the 2D Fourier, Hadamard,and Haar wavelet transforms, can in principle achieve anexponential speed-up over classical algorithms. Figure 2compares the different requirements on resources for the

Space resources

101 102 103 104 105 106 107100

102

104

106

108

Number of pixels N

Quantum Fourier

Fourier & Hadamard

Quantum Haar

Edge detection & Haar

Quantum Hadamard

Quantum Edge detection

(b) (c)

Tim

e co

st

Number of pixels N101 103 107105

1010

Num

ber

of b

its &

qub

its

106

104

102

100

108

Classical

Quantum

Time cost

Classical

Quantum

bits

qubits

(a)

Coding Haar HadamardFourier Edge detection

FIG. 2. (a) Comparison of resource costs of classical andquantum image processing for an image of N ¼ M × L (i.e.,n ¼ log2 N) pixels with d-bit depth. (b) Space resources com-parison. Top (bottom) curve represents classical (quantum)algorithms, with d ¼ 36. (c) Time cost comparison. The twocurves at the top of this graph represent classical algorithms, andthe four curves (Quantum Haar, Quantum Fourier, etc.) at thebottom represent quantum algorithms.

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

031041-3

Page 4: Quantum Image Processing and Its Application to Edge ...€¦ · Quantum Image Processing and Its Application to Edge Detection: Theory and Experiment Xi-Wei Yao,1,4,5,* Hengyan Wang,2

classical and quantum algorithms, in terms of the size of theregister (i.e., space) and the number of steps (i.e., time).

C. Experimental demonstrations

We now proceed to experimentally demonstrate, on anuclear spin quantum computer, some of these elementaryimage transforms. With established processing techniques[63,64], NMR has been used for many demonstrations ofquantum information processing [47,62,65,66].As a simple test image, we choose a 4 × 4 chessboard

pattern,

Fb ¼1

2ffiffiffi2

p

266641 0 1 0

0 1 0 1

1 0 1 0

0 1 0 1

37775; ð2Þ

whose encoding and processing require four qubits. Wetherefore chose iodotrifluoroethylene (C2F3I) as a 4-qubitquantum register, whose molecular structure and relevantproperties are shown in Fig. 3(a). We label 19F1, 19F2, 19F3,and 13C as the first, second, third, and fourth qubit,respectively. The natural Hamiltonian of this system inthe doubly rotating frame [67] is

Hint ¼X4j¼1

πνjσjz þ

X41≤j<r≤4

π

2Jjrσ

jzσrz; ð3Þ

where νj represents the chemical shift of spin j, and Jjr isthe coupling constant between spins j and r. The experi-ments were carried out at 305 K on a Bruker AV-400spectrometer in a magnetic field of 9.4 T.The input image preparation is illustrated in Fig. 3(b).

Starting from the thermal equilibrium and using the line-selective method [68], we prepare the pseudopure state(PPS) ρ0000 ¼ ϵj0000ih0000j þ ½ð1 − ϵÞ=16�I16, whereϵ ≈ 10−5 is the polarization and I16 denotes the 16 × 16unit operator. The operator UPPS1 equalizes all populationsexcept that of the state j0000i, and a subsequent gradientfield pulse destroys all coherences except for the homo-nuclear zero quantum coherences (ZQC) of the 19F nuclei.A specially designed unitary operator UPPS2 is applied tothe system and transforms these remaining ZQC to non-ZQC, which are then eliminated by a second gradientpulse. The resulting PPS has a fidelity of 98.4% definedby jtrðρthρexptÞj=½trðρ2thÞtrðρ2exptÞ�1=2, where ρth and ρexptrepresent the theoretical and experimentally measureddensity matrices, respectively. The last operator Uencodeturns j0000ih0000j into the image state ρimg ¼ jfimgihfimgj,which corresponds to the input image. The three unitaryoperations UPPS1, UPPS2, and Uencode are all realized by

gradient ascent pulse engineering (GRAPE) [69], eachhaving theoretical fidelity of about 99.9%.For a 4 × 4 image, the three image transformation

operators that we consider are

UHaar ¼ A⊗24 ;

UFourier ¼ QFT⊗24 ;

UHadamard ¼ H⊗4; ð4Þ

where the Haar, Fourier, and Hadamard matrices are

A4 ¼1

2

26664

1 1 1 1

1 1 −1 −1ffiffiffi2

p−

ffiffiffi2

p0 0

0 0ffiffiffi2

p−

ffiffiffi2

p

37775; ð5Þ

F1 F2 F3

51.5

4.8

6.8

4.4

T2(s)

13

-33131.7

-42682.8

15480.1

-129.0

-275.6

F1

F2

F3

C

CF3F2F1

-297.7 7.9

F2

C

13

13

F3

F1

19 1919

19

19

19

19

19 19-56444.8

64.6

39.1

UPPS1

Gz

F119

F219

F319

C13

Gz

UPPS2 encodeU

HH

H

HHR

H

(b)

(c)

HH

H

HHR

H

Haar Fourier Hadamard

Input image state preparation

(a)

FIG. 3. (a) Properties of the iodotrifluoroethylene molecule.The chemical shifts and J-coupling constants (in Hz) are given bythe diagonal and nondiagonal elements, respectively. The mea-sured spin-lattice relaxation times T1 are 21 s for 13C and 12.5 sfor 19F. The chemical shifts are given with respect to the referencefrequencies of 100.62 MHz (carbon) and 376.48 MHz (fluorines).(b) Preparation of the input image states. Two unitary operatorsUPPS1 and UPPS2 and two z-axis gradient field pulses are used toprepare the pseudopure state (PPS) ρ0000. Then Uencode realizesquantum image encoding. (c) Quantum circuits for the Haarwavelet, Fourier, and Hadamard image transforms, where H is a

Hadamard gate and R ¼h1 0

0 i

iis a phase gate.

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

031041-4

Page 5: Quantum Image Processing and Its Application to Edge ...€¦ · Quantum Image Processing and Its Application to Edge Detection: Theory and Experiment Xi-Wei Yao,1,4,5,* Hengyan Wang,2

QFT4 ¼1

2

266641 1 1 1

1 i −1 −i1 −1 1 −11 −i −1 i

37775; ð6Þ

and

H ¼ 1ffiffiffi2

p�1 1

1 −1

�: ð7Þ

The corresponding quantum circuits and the actual pulsesequences in our experiments are shown in Figs. 3(c) and 4,respectively. Each unitary rotation in the pulse sequencesis implemented through a Gaussian selective soft pulse,and a compilation program is employed to increase thefidelity of the entire selective pulse network [70]. Theprogram systematically adjusts the irradiation frequencies,rotational angles, and transmission phases of the selectivepulses, so that up to first-order dynamics, the phase errorsand unwanted evolutions of the sequence are largely

compensated [71]. The resulting fidelities for the π refo-cusing rotations range from 97.2% to 99.5%, and for theπ=2 rotations from 99.7% to 99.9%. We use the GRAPEtechnique to further improve the control performance. Thecompilation procedure generates a shaped pulse of rela-tively high fidelity, which serves as a good starting pointfor the gradient iteration. So the GRAPE search quicklyreaches a high performance. The final pulse has a numericalfidelity of ≈99.9%, after taking into account 5% rfinhomogeneity. The whole pulse durations of implement-ing the Haar, Fourier, and Hadamard transforms are 21.95,19.86, and 3.81 ms, respectively.Since the isotropic composition of our sample corre-

sponds to natural abundance, only ≈1% of the moleculescontain a 13C nuclear spin and can therefore be used asquantum registers. To distinguish their signal from thatmuch larger background of molecules containing 12Cnuclei, we do not measure the signal of the 19F nuclearspins directly, but transfer the states of the 19F spins to the13C spin by a SWAP gate and read out the state informationof the 19F spins through the 13C spectra. Thus, all signals ofthese four qubits are obtained from the 13C spectra.We apply the Haar wavelet, Fourier, and Hadamard

transforms to the input 2D pattern, using the correspondingsequences of rf pulses. To examine if the experiments haveproduced the correct results, we perform quantum statetomography [72] of the input and output image states.Compared with theoretical density matrices, the input-image state and the corresponding transformed-imagestates have fidelities in the range of [0.961, 0.975], Asan alternative to quantum state tomography, we alsoreconstruct state vectors jψ expti ¼

P16k¼1 c

exptk jki directly

from the experimental spectra. The input-image and thetransformed-image states are experimentally read out andthe decoded image arrays are displayed in Fig. 5. The toprow shows the experimental spectra. The middle rowshows the corresponding measured image matrices (onlythe real parts, since the imaginary parts are negligiblysmall) as 3D bar charts whose pixel values are equal to thecoefficients of the quantum states. The bottom row repre-sents the same image data as 2D gray scale (visualintensity) pictures. The experimental and theoreticaldata agree quite well with each other, with the imageEuclidean distances [73] ∥Fexpt − Fth∥=∥Fth∥ ≈ 0.08 in theinput data and ∈ ½0.09; 0.12� in the resulting data afterprocessing.

III. QUANTUM EDGE DETECTION ALGORITHM

A typical image processing task is the recognition ofboundaries (intensity changes) between two adjacentregions [74]. This task is not only important for digitalimage processing, but is also used by the brain: It hasbeen shown that the brain processes visual information byresponding to lines and edges with different neurons [75],

F119

F219

F319

C13

(b)

(a)

21

(e)

(d)

F119

F219

F319

C13

21

(c)

F119

F219

F319

C13

FIG. 4. Pulse sequences for implementing the (a) Haar,(b) Fourier, (c) Hadamard image transform, (d) the operatione½−iðI1z I2zþI3z I4zÞπ�, and (e) e½iðI1z I2zþI3z I4z Þπ=2�. Here, τ1 ¼ j1=2J34j andτ2 ¼ j1=2J12j − j1=2J34j, respectively. The rectangles representthe rotation RðθÞ with the phases given above the rectangles.The rotation angles θ1¼−0.1282π, θ2¼−0.2634π, θ3¼0.0894π,θ4 ¼ −2πν1τ2, θ5 ¼ −2πν2τ2, θ6 ¼ −2πν3τ1, θ7 ¼ θ4=2,θ8 ¼ θ5=2, and θ9 ¼ θ6=2. The time order of the pulse sequenceis from left to right.

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

031041-5

Page 6: Quantum Image Processing and Its Application to Edge ...€¦ · Quantum Image Processing and Its Application to Edge Detection: Theory and Experiment Xi-Wei Yao,1,4,5,* Hengyan Wang,2

which is an essential step in many pattern recognition tasks.Classically, edge detection methods rely on the computa-tion of image gradients by different types of filtering masks[5]. Therefore, all classical algorithms require a computa-tional complexity of at least Oð2nÞ because each pixelneeds to be processed. A quantum algorithm has beenproposed that is supposed to provide an exponential speed-up compared with existing edge extraction algorithms [76].However, this algorithm includes a COPY operation and aquantum black box for calculating the gradients of all thepixels simultaneously. For both steps, no efficient imple-mentations are currently available. Based on the afore-mentioned QImR, we propose and implement a highlyefficient quantum algorithm that finds the boundariesbetween two regions in Oð1Þ time, independent of theimage size. Further discussions regarding more generalfiltering masks are given in Appendix C.Basically, a Hadamard gate H, which converts a

qubit j0i → ðj0i þ j1iÞ= ffiffiffi2

pand j1i → ðj0i − j1iÞ= ffiffiffi

2p

, isapplied to detect the boundary. Since the positions of anypair of neighboring pixels in a picture column are given bythe binary sequences b1…bn−10 and b1…bn−11, with bj ¼0 or 1, their pixel values are stored as the coefficientscb1…bn−10 and cb1…bn−11 of the corresponding computationalbasis states. The Hadamard transform on the last qubitchanges them to the new coefficients cb1…bn−10 � cb1…bn−11.The total operation is then

I2n−1 ⊗ H ¼ 1ffiffiffi2

p

26666666666664

1 1 0 0 � � � 0 0

1 −1 0 0 � � � 0 0

0 0 1 1 � � � 0 0

0 0 1 −1 � � � 0 0

..

. ... ..

. ... . .

. ... ..

.

0 0 0 0 � � � 1 1

0 0 0 0 � � � 1 −1

37777777777775

; ð8Þ

where I2n−1 is the 2n−1 × 2n−1 unit matrix. For an n-qubitinput image state jfi ¼ P

N−1k¼0 ckjki (N ¼ 2n pixels), we

have the output image state jgi ¼ ðI2n−1 ⊗ HÞjfi as

I2n−1 ⊗ H∶

26666666666664

c0c1c2c3� � �cN−2

cN−1

37777777777775

↦1ffiffiffi2

p

26666666666664

c0 þ c1c0 − c1c2 þ c3c2 − c3� � �

cN−2 þ cN−1

cN−2 − cN−1

37777777777775

: ð9Þ

Here, we are interested in the difference cb1…bn−10 −cb1…bn−11 (the even elements of the resulting state): If the

Pix

el v

alue

Input Haar Fourier Hadamard

(a) (b) (c) (d)

0

0.5

1.0

0

0.60.40.2

1 23 4

12

34

Gra

y sc

ale

1 2 34

12

34

−2000200

Frequency (Hz)

Am

plitu

de (

arb.

uni

t)

−2000200

Frequency (Hz)−2000200

Frequency (Hz)−2000200

Frequency (Hz)

3.2

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 representingone pixel in the images.

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

031041-6

Page 7: Quantum Image Processing and Its Application to Edge ...€¦ · Quantum Image Processing and Its Application to Edge Detection: Theory and Experiment Xi-Wei Yao,1,4,5,* Hengyan Wang,2

two pixels belong to the same region, their intensityvalues are identical and the difference vanishes, other-wise their difference is nonvanishing, which indicates aregion boundary. The edge information in the evenpositions can be extracted by measuring the last qubit.Conditioned on the measurement result of the last qubitbeing 1, the state of the first n − 1 qubits encodes thedomain boundaries. Therefore, this procedure yields thehorizontal boundaries between pixels at positions 0=1,2=3, etc.To obtain also the boundaries between the remaining

pairs 1=2, 3=4, etc., we apply the n-qubit amplitudepermutation to the input image state, yielding a new imagestate jf0i with its odd (even) elements equal to the even(odd) elements of the input one jfi (e.g., c02k ¼ c2kþ1 andc02kþ1 ¼ c2kþ2). The quantum amplitude permutation canbe efficiently performed in O½polyðnÞ� time [61]. Applyingagain a single-qubit Hadamard rotation to this new imagestate jf0i, we get the remaining half of the differences. Analternative approach for obtaining all boundary values is touse an ancilla qubit in the image encoding (see Appendix Efor a suitable quantum circuit). For example, a 2-qubitimage state ðc0; c1; c2; c3Þ can be redundantly encoded inthree qubits as ðc0; c1; c1; c2; c2; c3; c3; c0Þ. After applyinga Hadamard gate to the last qubit of the new image state, weobtain the state ðc0 þ c1; c0 − c1; c1 þ c2; c1 − c2; c2 þ c3;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 fullboundary information. With image encoding along differ-ent orientations, the corresponding boundaries are detected,e.g., row (column) scanning for the vertical (horizontal)boundary.This quantum Hadamard edge detection (QHED) algo-

rithm generates a quantum state encoding the informationabout the boundary. Converting that state into classicalinformation will require Oð2nÞ measurements, but if thegoal is, e.g., to discover if a specific pattern is present inthe picture, a measurement of single local observablemay be sufficient. A good example is the SWAP test (seeAppendix D), which determines the similarity between aresulting image and a reference image.As a numerical example, Fig. 6 shows the outcome of the

QHED algorithm simulated on a classical computer foran input binary (b=w) image Fcat. For this simple demon-stration, we use only a binary image; nevertheless, theQHED algorithm is also valid for an image with generalgray levels. A 256 × 256 image Fcat is encoded into aquantum state jfcati with 16 qubits instead of 216 ¼ 65536classical bits (i.e., 8 kB). Then a unitary operator I215 ⊗ His applied to jfcati. The resulting image decoded from theoutput state demonstrates that the QHED algorithm cansuccessfully detect the boundaries in the image.To test the QHED algorithm experimentally, we encode

a simple image

Fe ¼1

2ffiffiffi2

p

266640 1 0 0

1 1 1 0

1 1 1 1

0 0 0 0

37775 ð10Þ

in a quantum state jfei of our 4-qubit quantum register.We then apply a single-qubit Hadamard gate to the lastqubit while keeping the other qubits untouched, i.e.,

(a) (b)

FIG. 6. Numerical simulation for the QHED algorithm. (a) Input256 × 256 image. (b) Output image encoding the edge informa-tion. The pixels in white and black have amplitude values 0 and 1,respectively.

(a)

(c)

1 2 3 41

23

4

0

0.2

0.4

Input Output

1 2 3 41

23

4

Pix

el v

alue

0

0.5

1.0

Gra

y sc

ale

(b)

(d)

−2000200Frequency (Hz)

Am

plitu

de (

arb.

uni

t)

−2000200Frequency (Hz)

1.8

FIG. 7. Experimental results of the QHED algorithm. Theupper panels are the 13C spectra (blue curves) for (a) the inputimage Fe and (b) output image representing the edge information,along with the simulated ones (red curves). The simulated spectraare shifted for clarity. In (a), the spectral amplitude is zoomed-inby 1.8 times. In (b), the top (bottom) spectrum is the result afterapplying a Hadamard gate to jfei (the processed image jf0ei afterthe amplitude permutation). The 13C spectra were obtained byapplying π=2 readout pulses. The lower two panels are the imagearray results of (c) the input 4 × 4 image and (d) the output imagerepresenting the edge information. The images are plotted asamplitude 3D bar charts (top) and 2D visual intensity pictures(bottom) with each square representing one pixel.

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

031041-7

Page 8: Quantum Image Processing and Its Application to Edge ...€¦ · Quantum Image Processing and Its Application to Edge Detection: Theory and Experiment Xi-Wei Yao,1,4,5,* Hengyan Wang,2

Ue ¼ I8 ⊗ H. The edge information with half of the pixels(even positions) in the resulting state jgei ¼ Uejfei isproduced, which can be read out from the experimentalspectra. We separately perform two experiments to obtainthe boundaries for odd and even positions with andwithout the amplitude permutation, as described above.To test if the processing result is correct, we measure theinput and output image states and obtain their fidelities inthe range of [0.972, 0.981]. The experimental results ofboundary information are shown in Fig. 7, along withsome corresponding experimental spectra. Comparedwith the theoretical data, the experimental input andoutput images have image Euclidean distance of 0.06 and0.08, respectively.

IV. CONCLUSION

In summary, we demonstrate the potential of quantumimage processing to alleviate some of the challenges broughtby the rapidly increasing amount of image processing. Insteadof the QImR models used in previous theoretical researchon QImP, we encode the pixel values of the image in theprobability amplitudes and the pixel positions in the computa-tional basis states. Based on this QImR, which reduces therequired qubit resources, we discuss the principle of QImPand experimentally demonstrate the feasibility of a number offundamental quantum image processing operations, suchas the 2D Fourier transform, the Hadamard, and the Haarwavelet transform, which are usually included as subroutinesin more complicated tasks of image processing. Thesequantum image transforms provide exponential speed-upsover their classical counterparts. As an interesting andpractical application, we present and experimentally imple-ment a highly efficient quantum algorithm for image edgedetection, which employs only one single-qubit Hadamardgate to process the global information (edge) of an image;the processing runs in Oð1Þ time, instead of Oð2nÞ as in theclassical algorithms. Therefore, this algorithm has significantadvantages over the classical algorithms for large image data.It is completely general and can be implemented on anygeneral-purpose quantum computer, such as trapped ions[77,78], superconducting [45,48,79], and photonic quantumcomputing [80,81]. Our experiment serves as a first exper-imental study towards practical applications of quantumcomputers for digital image processing.In addition to the computational tasks we show in this

paper, quantum computers have the potential to resolveother challenges of image processing and analysis, such asmachine learning, linear filtering and convolution, multi-scale analysis, face and pattern recognition, and imageand video coding [4,46–49]. Image and video informationencoded in qubits can be used not only for efficientprocessing but also for securely transmitting these datathrough networks protected by quantum technology. Thetheoretical and experimental results we present here maywell stimulate further research in these fields. It is an open

area to explore and discover more interesting practicalapplications involving QImP and AI. This paradigm islikely to outperform the classical one and works as anefficient solution in the era of big data.

ACKNOWLEDGMENTS

Wearegrateful to EmanuelKnill for helpful comments anddiscussions on the manuscript. We also thank Fu Liu, W.Zhao,X. N.Xu,H. P. Peng, S.Wei, J. Zhang, andX. Y. Zhengfor technical assistance, C.-Y. Lu, Z. Chen, S.-Y. Ding, J.-W.Shuai, Y.-F. Chen, Z.-G. Liu, W. Kong, and J. Q. Gu forinspiration and fruitful discussions, and R. Han, X. Zhou,J. Du, and Z. Tian for a great encouragement and helpfulconversations. This work is supported by National Key BasicResearch Program of China (Grants No. 2013CB921800and No. 2014CB848700), the National Science Fundfor Distinguished Young Scholars of China (GrantNo. 11425523), the National Natural Science Foundationof China (Grants No. 11375167 and No. 11227901), theStrategic Priority Research Program (B) of the CAS (GrantNo. XDB01030400), Key Research Program of FrontierSciences of the CAS (Grant No. QYZDY-SSW-SLH004),and the Deutsche Forschungsgemeinschaft through Su192/24-1. Z. Liao acknowledges support from the QatarNational Research Fund (QNRF) under the NPRP ProjectNo. 7-210-1-032. J.-Z. Li acknowledges support from theNatural Science Foundation of Guangdong Province (GrantNo. 2014A030310038).

X.-W. Y. and H.W. contributed equally to this work.

APPENDIX A: COMPARISON OF QImRs

Thus far, several QImR models have been proposed. In2003, Venegas-Andraca and Bose suggested the “qubitlattice” model to represent quantum images [52] where eachpixel is represented by a qubit, therefore requiring 2n qubitsfor an image of 2n pixels. This is a quantum-analogpresentation of classical images without any gain fromquantum speed-up. A flexible representation of quantumimages (FRQI) [53] integrates the pixel value and positioninformation in an image into an (nþ 1)-qubit quantum stateð1= ffiffiffiffiffi

2np ÞP2n−1

k¼0 ðcos θkj0i þ sin θkj1iÞjki, where the angleθk in a single qubit encodes the pixel value of the corre-sponding position jki. A novel enhanced quantum represen-tation (NEQR) [54] uses the basis state jfðkÞi of d qubits tostore the pixel value, instead of an angle encoded in a qubitin FRQI, i.e., an image is encoded as such a quantum stateð1= ffiffiffiffiffi

2np ÞP2n−1

k¼0 jfðkÞijki, where jfðkÞi ¼ jC0kC

1k…Cd−1

k i,with a binary sequenceC0

kC1k…Cd−1

k encoding the pixel valuefðkÞ. Table I compares our present QImR, which we referto as quantum probability image encoding (QPIE), with theother two main quantum representation models: FRQIand NEQR. It clearly shows that the QImR we use here(QPIE) requires fewer resources than the others.

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

031041-8

Page 9: Quantum Image Processing and Its Application to Edge ...€¦ · Quantum Image Processing and Its Application to Edge Detection: Theory and Experiment Xi-Wei Yao,1,4,5,* Hengyan Wang,2

APPENDIX B: QUANTUM WAVELETTRANSFORM

Here, we discuss the implementation circuit and com-plexity of the quantum Haar wavelet transform. Generally,the M ×M Haar [82] wavelet transform AM (M ¼ 2m,m ¼ 0; 1; 2;…) can be defined by the following equationas

AM ¼�AM=2 ⊗ BX

IM=2 ⊗ BX

�; ðB1Þ

where A1 ¼ 1, IM=2 is a M=2 ×M=2 unit operator,

BX ¼ ½11�= ffiffiffi2

p, and BX ¼ ½1 − 1�= ffiffiffi

2p

. This implies, forM ¼ 2,

A2 ¼�BX

BX

�¼ 1ffiffiffi

2p

�1 1

1 −1

�¼ H; ðB2Þ

that is, A2 is a Hadamard transform. We can recursivelydecompose the quantum Haar wavelet transform (Fig. 8) asfollows:

AM ¼�AM=2

IM=2

�SMðIM=2 ⊗ A2Þ; ðB3Þ

where SM is the qubit cyclic right shift permutation:SMji1i2…im−1imi ¼ jimi1i2…im−1i, and with ij ¼ 0 or 1and m the number of qubits. Specifically, S4 is the SWAP

gate to interchange the states of the two qubits: ji1i2i →ji2i1i. Therefore, the corresponding circuit consists of thefollowing controlled gates.(1) C0ðHÞ; C1ðHÞ; C2ðHÞ;…; Cm−1ðHÞ,(2) C0ðS2mÞ; C1ðS2m−1Þ;…; Cm−2ðS4Þ.

Here, CkðUÞ is a multiple qubit controlled gate described asfollows:

CkðUÞji1i2…ikijψi ¼ ji1i2…ikiUi1 i2…ik jψi; ðB4Þwhere i1i2…ik in the exponent of U means the product ofthe bits’ inverse i1i2…ik, and i ¼ NOTðiÞ. That is, if thefirst k control qubits are all in state j0i, the m − k qubitunitary operator U is applied to the lastm − k target qubits,otherwise the identity operator is applied to the last m − ktarget qubits.Since S2m−k can be implemented by ðm − k − 1Þ SWAP

gates, the circuit for CkðS2m−kÞ is composed of ðm − k − 1ÞCkðSWAPÞ gates. C1ðSWAPÞ can be implemented by 3C2ðNOTÞ gates [59]. Hence, the implementation ofCkðS2m−kÞ needs in total 3ðm − k − 1Þ Ckþ1ðNOTÞ gates.Both CkðHÞ and CkðNOTÞ can be implemented with linearcomplexity, for k ¼ 0;…; m − 1. Hence, we conclude thatthe quantum Haar wavelet transform can be implementedby Oðm3Þ elementary gates.

APPENDIX C: IMAGE SPATIAL FILTERING

Spatial filtering is a technique of image processing,such as image smoothing, sharpening, and edge enhance-ment, by operating the pixels in the neighborhood of thecorresponding input pixel. The filtered value of the targetpixel is given by a linear combination of the neighborhoodpixels with the specific weights determined by the mask

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

and n ¼ 2m).

Image representation FRQI NEQR QPIE

Quantum state ð1=2mÞP22m−1k¼0 ðcos θkj0i þ sin θkj1iÞjki ð1=2mÞP22m−1

k¼0 jfðkÞijki jfi ¼ P22m−1k¼0 ckjki

Qubit resource 1þ 2m dþ 2m 2mPixel-value qubit 1 d 0Pixel value θk fðkÞ ¼ C0

kC1k…Cd−1

k ckPixel-value encoding Angle Basis of qubits Probability amplitude

SM AM/2

H H H H H

SM

H

AM/2

qubits

= log M 2

FIG. 8. Quantum circuit for the Haar wavelet transform AM. His a Hadamard gate, and A2 ¼ H for the case M ¼ 2. SM isthe qubit cyclic right shift permutation SM∶ji1i2…im−1imi →jimi1i2…im−1i, which can be implemented by m − 1 SWAP gates.

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

031041-9

Page 10: Quantum Image Processing and Its Application to Edge ...€¦ · Quantum Image Processing and Its Application to Edge Detection: Theory and Experiment Xi-Wei Yao,1,4,5,* Hengyan Wang,2

values [5]. For example, given an input image F ¼ðFi;jÞM×M and a general 3 × 3 filtering mask,

W ¼

264w11 w12 w13

w21 w22 w23

w31 w32 w33

375; ðC1Þ

spatial filtering will give the output image G ¼ðGi;jÞM×M with the pixel Gi;j ¼

P3u;v¼1 wuvFiþu−2;jþv−2

ð2 ≤ i; j ≤ M − 1Þ. Here, we construct a linear filteringoperator U such that g ¼ Uf, where f ¼ vecðFÞ andg ¼ vecðGÞ. f and g are both M2-dimensional vectors,and the dimension of U is M2 ×M2. We prove that U canbe constructed as

U ¼

266666666664

E

V1 V2 V3

. .. . .

. . ..

. .. . .

. . ..

V1 V2 V3

E

377777777775; ðC2Þ

where E is an M ×M identity matrix, and V1, V2, V3 areM ×M matrices defined by

V1 ¼

266666666664

0

w11 w21 w31

. .. . .

. . ..

. .. . .

. . ..

w11 w21 w31

0

377777777775M×M

; ðC3Þ

V2 ¼

266666666664

1

w12 w22 w32

. .. . .

. . ..

. .. . .

. . ..

w12 w22 w32

1

377777777775M×M

; ðC4Þ

V3 ¼

266666666664

0

w13 w23 w33

. .. . .

. . ..

. .. . .

. . ..

w13 w23 w33

0

377777777775M×M

: ðC5Þ

Proof.—Since g ¼ vecðGÞ, we have gk ¼ Gt;sþ1, withk ¼ tþMs (1 ≤ k ≤ M2; 1 ≤ t ≤ M; 0 ≤ s ≤ M − 1). Fort ≠ 1, M and s ≠ 0, M − 1, we have

gk ¼ Gt;sþ1 ¼ ðW � FÞt;sþ1

¼ w11Ft−1;s þ w21Ft;s þ w31Ftþ1;s

þ w12Ft−1;sþ1 þ w22Ft;sþ1 þ w32Ftþ1;sþ1

þ w13Ft−1;sþ2 þ w23Ft;sþ2 þ w33Ftþ1;sþ2:

Let h ¼ Uf, then we have hk ¼P

i¼1

M2

Uk;ifi. From theexpression of U in Eq. (C2), we can see that the nonzeroelements are

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;

Uk;Msþt ¼ w22; Uk;Msþtþ1 ¼ w32;

Uk;Mðsþ1Þþt−1 ¼ w13; Uk;Mðsþ1Þþt ¼ w23;

Uk;Mðsþ1Þþtþ1 ¼ w33;

and for other i, Uk;i ¼ 0. Since f ¼ vecðFÞ, we have

fMðs−1Þþt−1 ¼ Ft−1;s; fMðs−1Þþt ¼ Ft;s;

fMðs−1Þþtþ1 ¼ Ftþ1;s; fMsþt−1 ¼ Ft−1;sþ1;

fMsþt ¼ Ft;sþ1; fMsþtþ1 ¼ Ftþ1;sþ1;

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.Hence, we have g ¼ Uf.We can deduce that U is unitary if and only if w22 ¼ �1

and other elements are all zero in W [Eq. (C1)]. In general,the linear transformation of spatial filtering is nonunitary.For a nonunitary linear transformation U, we can try toembed it in a bigger quantum system, and perform abigger unitary operation to realize an embedded trans-formation U [83]. Alternatively, the quantum matrix-inversion techniques [41,50] could also help to perform

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

031041-10

Page 11: Quantum Image Processing and Its Application to Edge ...€¦ · Quantum Image Processing and Its Application to Edge Detection: Theory and Experiment Xi-Wei Yao,1,4,5,* Hengyan Wang,2

some nonunitary linear transformations on a quantumcomputer.

APPENDIX D: DETECTING SYMMETRYBY QImP

Here, we present a highly efficient quantum algorithmfor recognizing an inversion-symmetric image, whichoutperforms state-of-the-art classical algorithms with anexponential speed-up. First, we use the NOT gate (i.e., thePauli X operator σx) to rotate the input image 180° withrespect to the image center. Then we utilize the SWAP test[58] to detect the overlap between the input and rotatedimages: The larger the overlap, the better the inversionsymmetry of original image. This algorithm is described asfollows.(1) Encode an input M × L ¼ 2m × 2n image into a

quantum state jfi with n ¼ mþ l qubits.(2) Perform a NOT operation on each qubit such that

the basis ji1i2…ini switches to the complementarybasis ji1 i2…ini (i.e., UNOT ¼ NOT⊗n ¼ σ⊗n

x ),where i1; i2;…; in ¼ 0 or 1 and i ¼ NOTðiÞ. Sinceiþ i ¼ 1, we have i1i2…in þ i1i2…in ¼ 11…1.Therefore, the bases are swapped around the center;i.e., the image is rotated by 180°.

(3) Using the SWAP test method [4,47], we detect theoverlap between two states before and after applyingNOT operation to the input pattern; a measuredoverlap value hfjUNOTjfi [84] can efficiently supplyuseful information on the inversion symmetry of theinput pattern.

Estimating distances and inner products between statevectors of image data in ML-dimensional vector spacesthen takes time OðlogMLÞ on a quantum computer, whichis exponentially faster than that of classical computers[85,86]. Here, a specific example of a 2 × 2 image isprovided for illustration. To rotate the input image matrixby 180° as follows,

�1 3

2 4

�⟶Rotation

180°

�4 2

3 1

�: ðD1Þ

The input state of left-hand image is ðj00i þ 2j01i þ3j10i þ 4j11iÞ= ffiffiffiffiffi

30p

. Applying a NOT gate to each qubit,the input state is transformed to (j11i þ 2j10i þ 3j01iþ4j00iÞ= ffiffiffiffiffi

30p

(corresponding to the rotated image on theright-hand side). It is clear that the input image has beenrotated by 180° around its center, which corresponds topoint reflection in 2D.

APPENDIX E: VARIANT OFQHED ALGORITHM

In order to produce full boundary values in a single step,a variant of the QHED algorithm uses an auxiliary qubit forencoding the image. The quantum circuit is shown in

Fig. 9. The operation D2nþ1 is an nþ 1-qubit amplitudepermutation, which can be written in matrix form as

D2nþ1 ¼

26666666666664

0 1 0 0 � � � 0 0

0 0 1 0 � � � 0 0

0 0 0 1 � � � 0 0

0 0 0 0 � � � 0 0

..

. ... ..

. ... . .

. ... ..

.

0 0 0 0 � � � 0 1

1 0 0 0 � � � 0 0

37777777777775

: ðE1Þ

It can be efficiently implemented in O½polyðnÞ� time[61]. For an input image encoded in an n-qubit statejfi ¼ ðc0; c1; c2;…; cN−2; cN−1ÞT , a Hadamard gate isapplied to the input state j0i of the auxiliary qubit, yieldingan (nþ 1)-qubit redundant image state jfi⊗ðj0iþj1iÞ=ffiffiffi2

p ¼2−1=2ðc0;c0;c1;c1;c2;c2;…;cN−2;cN−2;cN−1;cN−1ÞT .The amplitude permutation D2nþ1 is performed to yield anew redundant image state 2−1=2ðc0; c1; c1; c2; c2; c3;…;cN−2; cN−1; cN−1; c0ÞT . After applying a Hadamard gate tothe last qubit of this state, we obtain the state 2−1ðc0þc1;c0−c1;c1þc2;c1−c2;c2þc3;c2−c3;…;cN−2þcN−1;cN−2−cN−1;cN−1þc0;cN−1−c0ÞT . By measuring the lastqubit, conditioned on obtaining 1, we obtain the n-qubitstate jgi ¼ 2−1ðc0 − c1; c1 − c2; c2 − c3;…; cN−2 − cN−1;cN−1 − c0ÞT , which contains the full boundary information.

[1] D. Marr, Vision: A Computational Investigation into theHuman Representation and Processing of Visual Informa-tion (W.H. Freeman and Company, San Francisco, 1982).

[2] A. M. Turing, Computing Machinery and Intelligence,Mind 59, 433 (1950).

[3] D. Silver, A. Huang, C. Maddison, A. Guez, L. Sifre, G.Driessche, J.Schrittwieser, I.Antonoglou,V. Panneershelvam,M. Lanctot, S. Dieleman, D. Grewe, J. Nham, N. Kalchbren-ner, L. Sutskever, T. Lillicrap, M. Leach, K. Kavukcuoglu,T. Graepel, and D. Hassabis,Mastering the Game of Go with

Ancilla

D n+1

H H

2

1

2

3

FIG. 9. Quantum circuit for the QHED algorithm with anauxiliary qubit. H is a Hadamard gate, and D2nþ1 is an amplitudepermutation operation for nþ 1 qubits.

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

031041-11

Page 12: Quantum Image Processing and Its Application to Edge ...€¦ · Quantum Image Processing and Its Application to Edge Detection: Theory and Experiment Xi-Wei Yao,1,4,5,* Hengyan Wang,2

Deep Neural Networks and Tree Search, Nature (London)529, 484 (2016).

[4] P. Rebentrost, M. Mohseni, and S. Lloyd, Quantum SupportVector Machine for Big Data Classification, Phys. Rev.Lett. 113, 130503 (2014).

[5] R. C. Gonzalez and R. E. Woods, Digital Image Processing(Prentice-Hall, London, 2007).

[6] B. M. Lake, R. Salakhutdinov, and J. B. Tenenbaum,Human-Level Concept Learning through ProbabilisticProgram Induction, Science 350, 1332 (2015).

[7] N. Jean, M. Burke, M. Xie, W.M. Davis, D. B. Lobell,and S. Ermon, Combining Satellite Imagery andMachine Learning to Predict Poverty, Science 353, 790(2016).

[8] D. Deutsch, Quantum Theory, the Church-Turing Principleand the Universal Quantum Computer, Proc. R. Soc. A 400,97 (1985).

[9] E. Knill, R. Laflamme, and G. J. Milburn, A Scheme forEfficient Quantum Computation with Linear Optics, Nature(London) 409, 46 (2001).

[10] D. Aasen, M. Hell, R. V. Mishmash, A. Higginbotham,J. Danon, M. Leijnse, T. S. Jespersen, J. A. Folk, C. M.Marcus, K. Flensberg, and J. Alicea, Milestones TowardMajorana-Based Quantum Computing, Phys. Rev. X 6,031016 (2016).

[11] J. Yin et al., Satellite-Based Entanglement Distribution over1200 Kilometers, Science 356, 1140 (2017).

[12] S.-K. Liao et al., Satellite-to-Ground Quantum Key Dis-tribution, Nature (London) 549, 43 (2017).

[13] J.-G. Ren et al., Ground-to-Satellite Quantum Teleporta-tion, Nature (London) 549, 70 (2017).

[14] D. E. Browne and T. Rudolph, Resource-Efficient LinearOptical Quantum Computation, Phys. Rev. Lett. 95, 010501(2005).

[15] J.-W. Pan, Z.-B. Chen, C.-Y. Lu, H. Weinfurter, A.Zeilinger, and M. Żukowski, Multiphoton Entanglementand Interferometry, Rev. Mod. Phys. 84, 777 (2012).

[16] X. L. Wang, X. D. Cai, Z. E. Su, M.-C. Chen, D. Wu, L. Li,N. L. Liu, C.-Y. Lu, and J.-W. Pan, Quantum Teleportationof Multiple Degrees of Freedom of a Single Photon, Nature(London) 518, 516 (2015).

[17] E. Knill, Quantum Computing with Realistically NoisyDevices, Nature (London) 434, 39 (2005).

[18] D. Suter and G. A. Álvarez, Protecting Quantum Informa-tion against Environmental Noise, Rev. Mod. Phys. 88,041001 (2016).

[19] J. Zhang and D. Suter, Experimental Protection of Two-QubitQuantum Gates against Environmental Noise by DynamicalDecoupling, Phys. Rev. Lett. 115, 110502 (2015).

[20] C. Zu, W.-B. Wang, L. He, W.-G. Zhang, C.-Y. Dai, F.Wang, and L.-M. Duan, Experimental Realization of Uni-versal Geometric Quantum Gates with Solid-State Spins,Nature (London) 514, 72 (2014).

[21] B. Zeng, X. Chen, D.-L. Zhou, and X.-G. Wen, QuantumInformation Meets Quantum Matter—From Quantum En-tanglement to Topological Phase in Many-Body Systems,arXiv:1508.02595.

[22] G. H. Low, T. J. Yoder, and I. L. Chuang, Methodology ofResonant Equiangular Composite Quantum Gates, Phys.Rev. X 6, 041067 (2016).

[23] D.-L. Deng, X. Li, and S. D. Sarma,Quantum Entanglementin Neural Network States, Phys. Rev. X 7, 021021 (2017).

[24] P. W. Shor, in Proceedings of the 35th Annual Symposiumon Foundations of Computer Science (IEEE ComputerSociety Press, New York, 1994), pp. 124–134.

[25] X.-H. Peng, Z.-Y. Liao, N. Xu, G. Qin, X. Zhou, D. Suter,and J. Du, Quantum Adiabatic Algorithm for Factorizationand Its Experimental Implementation, Phys. Rev. Lett. 101,220405 (2008).

[26] L. K. Grover, Quantum Mechanics Helps in Searching fora Needle in a Haystack, Phys. Rev. Lett. 79, 325 (1997).

[27] S. Aaronson and A. Arkhipov, in Proceedings of the43rd Annual ACM Symposium on Theory of Computing(ACM, New York, 2011), pp. 333–342.

[28] M. A. Broome, A. Fedrizzi, S. Rahimi-Keshari, J. Dove, S.Aaronson, T. C. Ralph, and A. G. White, Photonic BosonSampling in a Tunable Circuit, Science 339, 794 (2013).

[29] J. B. Spring, B. J. Metcalf, P. C. Humphreys, W. S.Kolthammer, X.-M. Jin, M. Barbieri, A. Datta, N.Thomas-Peter, N. K. Langford, D. Kundys, J. C. Gates,B. J. Smith, P. G. R. Smith, and I. A. Walmsley, BosonSampling on a Photonic Chip, Science 339, 798 (2013).

[30] M. Tillmann, B. Dakić, R. Heilmann, S. Nolte, A. Szameit,and P. Walther, Experimental Boson Sampling, Nat. Pho-tonics 7, 540 (2013).

[31] A. Crespi, R. Osellame, R. Ramponi, D. J. Brod, E. F.Galvão, N. Spagnolo, C. Vitelli, E. Maiorino, P. Mataloni,and F. Sciarrino, Integrated Multimode Interferometerswith Arbitrary Designs for Photonic Boson Sampling,Nat. Photonics 7, 545 (2013).

[32] H. Wang, Y. He, Y. Li, Z. Su, B. Li, H. Huang, X. Ding,M.-C. Chen, C. Liu, J. Qin, J.-P. Li, Y.-M. He, C. Schneider,M. Kamp, C.-Z. Peng, S. Höfling, C.-Y. Lu, and J.-W. Pan,High-Efficiency Multiphoton Boson Sampling, Nat. Pho-tonics 11, 361 (2017).

[33] S. Lloyd, Universal Quantum Simulators, Science 273,1073 (1996).

[34] X.-H. Peng, J. Zhang, J. Du, and D. Suter, QuantumSimulation of a System with Competing Two- and Three-Body Interactions, Phys. Rev. Lett. 103, 140501 (2009).

[35] X.-H. Peng and D. Suter, Spin Qubits for QuantumSimulations, Front. Phys. China 5, 1 (2010).

[36] G. A. Álvarez and D. Suter, NMR Quantum Simulation ofLocalization Effects Induced by Decoherence, Phys. Rev.Lett. 104, 230403 (2010).

[37] X.-H. Peng, Z. H. Luo, W. Zheng, S. Kou, D. Suter, andJ. Du, Experimental Implementation of Adiabatic Passagebetween Different Topological Orders, Phys. Rev. Lett. 113,080404 (2014).

[38] G. A. Álvarez, D. Suter, and R. Kaiser, Localization-Delocalization Transition in the Dynamics of Dipolar-Coupled Nuclear Spins, Science 349, 846 (2015).

[39] M.-C. Chen, D. Wu, Z. Su, X. Cai, X. Wang, T. Yang, L. Li,N. Liu, C.-Y. Lu, and J.-W. Pan, Efficient Measurementof Multiparticle Entanglement with Embedding QuantumSimulator, Phys. Rev. Lett. 116, 070502 (2016).

[40] J. Li, R. Fan, H. Wang, B. Ye, B. Zeng, H. Zhai, X.-H. Peng,and J. Du, Measuring Out-of-Time-Order Correlators on aNuclear Magnetic Resonance Quantum Simulator, Phys.Rev. X 7, 031011 (2017).

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

031041-12

Page 13: Quantum Image Processing and Its Application to Edge ...€¦ · Quantum Image Processing and Its Application to Edge Detection: Theory and Experiment Xi-Wei Yao,1,4,5,* Hengyan Wang,2

[41] A.W. Harrow, A. Hassidim, and S. Lloyd, QuantumAlgorithm for Linear Systems of Equations, Phys. Rev.Lett. 103, 150502 (2009).

[42] X. D. Cai, C. Weedbrook, Z. E. Su, M.-C. Chen, M. Gu,M. J. Zhu, L. Li, N. L. Liu, C.-Y. Lu, and J.-W. Pan,Experimental Quantum Computing to Solve Systems ofLinear Equations, Phys. Rev. Lett. 110, 230501 (2013).

[43] J. Pan, Y. Cao, X. Yao, Z. Li, C. Ju, H. Chen, X. Peng, S.Kais, and J. Du, Experimental Realization of QuantumAlgorithm for Solving Linear Systems of Equations, Phys.Rev. A 89, 022313 (2014).

[44] S. Barz, I. Kassal, M. Ringbauer, Y. O. Lipp, B. Dakić,A. Aspuru-Guzik, and P. Walther, A Two-Qubit PhotonicQuantum Processor and Its Application to Solving Systemsof Linear Equations, Sci. Rep. 4, 6115 (2014).

[45] Y. R. Zheng, C. Song, M.-C. Chen, B. Xia, W. Liu, Q. Guo,L. Zhang, D. Xu, H. Deng, K. Huang, Y. Wu, Z. Yan, D.Zheng, L. Lu, J.-W. Pan, H. Wang, C.-Y. Lu, and X. B. Zhu,Solving Systems of Linear Equations with a SuperconductingQuantum Processor, Phys. Rev. Lett. 118, 210504 (2017).

[46] X. Cai, D. Wu, Z. Su, M.-C. Chen, X.-L. Wang, L. Li, N.Liu, C.-Y. Lu, and J.-W. Pan, Entanglement-Based MachineLearning on a Quantum Computer, Phys. Rev. Lett. 114,110504 (2015).

[47] Z. Li, X. Liu, N. Xu, and J. Du, Experimental Realization ofa Quantum Support Vector Machine, Phys. Rev. Lett. 114,140504 (2015).

[48] D. Ristè, M. Silva, C. Ryan, A. Cross, A. Córcoles, J.Smolin, J. Gambetta, J. Chow, and B Johnson, Demon-stration of Quantum Advantage in Machine Learning,Quantum Inf. Comput. 3, 16 (2017).

[49] S. Lloyd, M. Mohseni, and P. Rebentrost, Quantum Princi-pal Component Analysis, Nat. Phys. 10, 631 (2014).

[50] N. Wiebe, D. Braun, and S. Lloyd, Quantum Algorithm forData Fitting, Phys. Rev. Lett. 109, 050505 (2012).

[51] F. Yan, A. M. Iliyasu, and S. E. Venegas-andraca, A Surveyof Quantum Image Representations, Quantum Inf. Process.15, 1 (2016).

[52] S. E. Venegas-Andraca and S. Bose, Storing, Processingand Retrieving an Image Using Quantum Mechanics, Proc.SPIE Int. Soc. Opt. Eng. 5105, 137 (2003).

[53] P. Le, F. Dong, and K. Hirota, A Flexible Representationof Quantum Images for Polynomial Preparation, ImageCompression, and Processing Operations, Quantum Inf.Process. 10, 63 (2011).

[54] Y. Zhang, K. Lu, Y. Gao, and M. Wang, NEQR: A NovelEnhanced Quantum Representation of Digital Images,Quantum Inf. Process. 12, 2833 (2013).

[55] V. Giovannetti, S. Lloyd, and L. Maccone,Quantum RandomAccess Memory, Phys. Rev. Lett. 100, 160501 (2008).

[56] L. Grover and T. Rudolph, Creating Superpositions ThatCorrespond to Efficiently Integrable Probability Distribu-tions, arXiv:quant-ph/0208112.

[57] A. N. Soklakov and R. Schack, Efficient State Preparation fora Register of Quantum Bits, Phys. Rev. A 73, 012307 (2006).

[58] H. Buhrman, R. Cleve, J. Watrous, and R. de Wolf, QuantumFingerprinting, Phys. Rev. Lett. 87, 167902 (2001).

[59] M. A. Nielsen and I. L. Chuang, Quantum Computationand Quantum Information (Cambridge University Press,Cambridge, England, 2000).

[60] P. Hoyer, Efficient Quantum Transforms, arXiv:quant-ph/9702028.

[61] A. Fijany and C. Williams, in Proceedings of the 1stNASA International Conference on Quantum Computingand Quantum Communications (Springer, Berlin, 1998),pp. 10–33.

[62] Y. S. Weinstein, M. A. Pravia, E. M. Fortunato, S. Lloyd,and D. G. Cory, Implementation of the Quantum FourierTransform, Phys. Rev. Lett. 86, 1889 (2001).

[63] L. M. K. Vandersypen, I. L. Chuang, and D. Suter, inEncyclopedia of Magnetic Resonance (John Wiley & Sons,Ltd., New York, 2010).

[64] D. G. Cory, M. D. Price, and T. F. Havel, Nuclear MagneticResonance Spectroscopy: An Experimentally AccessibleParadigm for Quantum Computing, Physica (Amsterdam)120D, 82 (1998).

[65] A. M. Souza, J. Zhang, C. A. Ryan, and R. Laflamme,Experimental Magic State Distillation For Fault-TolerantQuantum Computing, Nat. Commun. 2, 169 (2011).

[66] X. Peng, H. Zhou, B. B. Wei, J. Cui, J. Du, and R. B. Liu,Experimental Observation of Lee-Yang Zeros, Phys. Rev.Lett. 114, 010601 (2015).

[67] M. H. Levitt, Spin Dynamics: Basics of Nuclear MagneticResonance (John Wiley & Sons, Ltd., New York, 2008).

[68] X.-H. Peng, X. Zhu, X. Fang, M. Feng, K. Gao, X. Yang,and M. Liu, Preparation of Pseudo-Pure States By Line-Selective Pulses in Nuclear Magnetic Resonance, Chem.Phys. Lett. 340, 509 (2001).

[69] N. Khaneja, T. Reiss, C. Kehlet, T. Schulte-Herbrüggen, andS. J. Glaser, Optimal Control of Coupled Spin Dynamics:Design of NMR Pulse Sequences by Gradient AscentAlgorithms, J. Magn. Reson. 172, 296 (2005).

[70] C. A. Ryan, C. Negrevergne, M. Laforest, E. Knill, and R.Laflamme, Liquid-State Nuclear Magnetic Resonance as aTestbed for Developing Quantum Control Methods, Phys.Rev. A 78, 012328 (2008).

[71] J. Li, J. Cui, R. Laflamme, and X.-H. Peng, Selective-Pulse-Network Compilation on a Liquid-State Nuclear-Magnetic-Resonance System, Phys. Rev. A 94, 032316 (2016).

[72] I. L. Chuang, N. Gershenfeld, M. G. Kubinec, and D.W.Leung, Bulk Quantum Computation with Nuclear MagneticResonance: Theory and Experiment, Proc. R. Soc. A 454,447 (1998).

[73] J. Li and B. Lu, An Adaptive Image Euclidean Distance,Pattern Recogn. 42, 349 (2009).

[74] D. Marr and E. Hildreth, Theory of Edge Detection, Proc. R.Soc. B 207, 187 (1980).

[75] D. Hubel, Eye, Brain and Vision (Scientific American Press,New York, 1995).

[76] Y. Zhang, K. Lu, and Y. Gao, Qsobel: A Novel QuantumImage Edge Extraction Algorithm, Sci. China Inf. Sci. 58, 1(2015).

[77] C. Ospelkaus, U. Warring, Y. Colombe, K. R. Brown,J. M. Amini, D. Leibfried, and D. J. Wineland, MicrowaveQuantum Logic Gates for Trapped Ions, Nature (London)476, 181 (2011).

[78] G. Higgins, W. Li, F. Pokorny, C. Zhang, F. Kress, C. Maier,J. Haag, Q. Bodart, I. Lesanovsky, and M. Hennrich, SingleStrontium Rydberg Ion Confined in a Paul Trap, Phys. Rev.X 7, 021038 (2017).

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

031041-13

Page 14: Quantum Image Processing and Its Application to Edge ...€¦ · Quantum Image Processing and Its Application to Edge Detection: Theory and Experiment Xi-Wei Yao,1,4,5,* Hengyan Wang,2

[79] J. Kelly et al., State Preservation by Repetitive ErrorDetection in a Superconducting Quantum Circuit, Nature(London) 519, 66 (2015).

[80] P. Kok, W. J. Munro, K. Nemoto, T. C. Ralph, J. P. Dowling,and G. J. Milburn, Linear Optical Quantum Computing withPhotonic Qubits, Rev. Mod. Phys. 79, 135 (2007).

[81] J. Carolan, C. Harrold, C. Sparrow, E. Martinlopez, N. J.Russell, J. W. Silverstone, and A. Laing, Universal LinearOptics, Science 349, 711 (2015).

[82] A. Haar, Zur Theorie der Orthogonalen Funktionensysteme,Math. Ann. 69, 331 (1910).

[83] S. J. Wei and G. L. Long, Duality Quantum Computer andthe Efficient Quantum Simulations, Quantum Inf. Process.15, 1189 (2016).

[84] E. Knill, G. Ortiz, and R. D. Somma, Optimal QuantumMeasurements of Expectation Values of Observables, Phys.Rev. A 75, 012328 (2007).

[85] S. Lloyd, M. Mohseni, and P. Rebentrost, Quantum Algo-rithms for Supervised and Unsupervised Machine Learning,arXiv:1307.0411.

[86] S. Aaronson, BQP and the Polynomial Hierarchy, arXiv:0910.4698.

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

031041-14