Using quantum computing to realize the Fourier Transform
in computer vision applications
Renato O. Violin
1and José H. Saito
2Computing Department – Federal University of São Carlos
{renato_violin
1, saito
2}@dc.ufscar.br
Abstract
This work proposes the quantum computing approach to the Fast Fourier Transform (FFT) implementation in vision processing. Although quantum computation is still in development, there are many researchers working in this new computation paradigm, and some simulators are available. The Quantum Fourier Transform (QFT) operation has a better computational cost than FFT algorithm. We will try to make use of Quantum Fourier Transform to verify its advantages, in the number of quantum gates, and possibly in processing speed. It is showed that the number of operations in QFT is O((log20)2), while in FFT is O(0log20), a huge difference of O(0) between them.
1. Introduction
Fourier transform is a useful mathematical tool for several areas of science. In this paper, it is covered its role in Computer vision. Computer vision makes use of image processing to enhance the images in order to obtain better results and eliminates the possibility of wrong analyzes.
During the analysis, it can be used various algorithms and techniques of pattern recognition, but, the first step is the image enhancement.
During the image processing, the FFT algorithm is frequently used to change the image from space domain to frequency domain. Then, it is performed the algorithms in the frequency domain to restore, remove noises and enhance the image quality. After that, it is performed the inverse of FFT (IFFT) to transform the image to space domain, to the analyses.
So, one computer vision application can be enhanced if the FFT and IFFT transforms could be improved, as using new computation models, as quantum computation.
The remaining of this paper is distributed as follows:
the section 2, describes about computer vision, image
processing and FFT. The section 3 describes about quantum computation and QFT. The section 4 is concerned to a theoretical comparison between FFT and QFT. To finalize, the section 5 presents the conclusion, followed by the references.
2. Computer Vision
Computer vision is a research area that mixes digital image processing and pattern recognition. A main goal of this area is to make machines that can see and recognize objects. Some machines were already made, for example, to scan the human eye for user identification and to drive a car using a camera as input [1].
One definition about computer vision is “The goal of computer vision is to make useful decisions about real physical objects and scenes based on sensed images” [1].
So, to achieve this goal, it is necessary to construct some descriptions or models of the objects in an image representation. Since we have an image representation, we often need to enhance the image quality, removing noises and distortions, enhancing the distinctness and restoring images. These steps are made to achieve a better final result.
Computer vision also uses pattern recognition techniques to recognize objects of interest for the goal.
In this work, we will focalize the image processing techniques to the computer vision.
Figure 1 illustrates the main steps in computer vision at frequency domain. The input image is generally acquired by a device like camera, satellite, scanner and sensor. So, the FFT converts the image from space domain to frequency domain. After this, it is made the processing (enhance the image quality etc.). After, the Inverse Fast Fourier Transform (IFFT) converts the image from frequency domain to space domain. So, the output image is ready to be analyzed by the machine.
Figure 1: steps in computer vision at frequency domain.
In this work, we want to show the computational advantages (in terms of computational cost) to change the FFT and IFFT by the QFT and IQFT respectively.
2.1 Image processing
Sometimes, when we acquire an image, we must perform image processing techniques to enhance the output image, which serves as input image to the next step. This next step can be a recognition process to emphasize or to extract some objects from the scene. So, before the next step, we must ensure that the image doesn’t have any unnecessary information. To do this, we usually transform the image to the frequency domain where we can perform the operations to remove noise and distortions, enhance the distinctness etc. To convert the image from space domain to frequency domain we use the Discrete Fourier Transform (DFT). The DFT is given by
1
0
( ) 1 ( ) exp[ 2 / ]
0
x
F u f x j ux 0
0 − π
=
=
∑
− (eq. 1)and its inverse, which restore the original image is given by
1
0
( ) ( ) exp[ 2 / ]
0
u
f x − F u j πux 0
=
=
∑
(eq. 2)These transformation operations are of high computational cost, of O(02), where 0 is the input number. The next section presents another algorithm that has a better computational cost.
2.2 The FFT algorithm
The computers spent a big time to perform the DFT.
In 1965, Cooley and Tukey made an algorithm that enables a computer perform the DFT efficiently, called Fast Fourier Transform (FFT), which has a better computation cost, O(0 log2 0) [2].
First, consider the equation
1
0
( ) 1 ( )
0
ux 0 x
F u f x W
0
−
=
=
∑
(eq. 3)where
exp[ 2 / ]
W0= −j π 0 . (eq. 4)
Since 0 =2n, thus 0 can be write as 0=2M . So, substituting in the equation 3, we obtain
2 1
2 0
1 1
( 2 ) (2 1)
2 2
0 0
( ) 1 ( )
2
1 1 1
(2 ) (2 1)
2
M
ux M x
M M
u x u x
M M
x x
F u f x W
M
f x W f x W
M M
−
=
− −
+
= =
=
= + +
∑
∑ ∑
(eq. 5) Simplifying the equation 5, we obtain
1 1
2
0 0
1 1 1
( ) (2 ) (2 1)
2
M M
ux ux u
M M M
x x
F u f x W f x W W
M M
− −
= =
=
∑
+∑
+ (eq. 6) Analyzing the equation 6, we notice that the transformation is computed in two halves.
As this algorithm has a reduced computation cost, the FFT algorithm is frequently used in image processing to transform the images from space to frequency domain. In section 3.2 we will see a Quantum Fourier Transform (performed using quantum computation), the analogous of FFT.
3. Quantum Computation
Quantum computing makes use of the quantum mechanics principles to do the processing. Quantum computation gives us some phenomena not present in classical computation, such as superposition and entanglement. Superposition will be explained below.
Entanglement is a phenomenon that enables the data to be safely transmitted. It is often used in quantum information theory.
The small information unit in quantum computation is a qubit (quantum bit). It is likely a bit, however, it has a difference: a qubit can be in both possible states (0 and 1) at the same time, differently of a bit, which can be in only one of the two states (0 or 1) at the same time. It is known, in quantum mechanics, as superposition principle.
The next equation shows this principle.
0 1
ψ = α +β (eq. 7)
The state ψ is an arbitrary state. The components α and β are complex numbers that are proportional to the probability of the result 0 or 1 when a measurement is made, obeying the constraint α2+ β2=1. So, at the measurement, we have α2 probability to obtain 0 and β2 probability to obtain 1 . The states 0 and 1 form the computational basis in Hilbert complex vector space, meaning binary values 0 and 1, in Dirac notation.
The above states 0 and 1 have a matrix representation,
0 1 0
=
and 0
1 1
=
(eq. 8) To act the qubits, we use unitary operators U . They are defined as U U† =U U† = . Any unitary matrix can I be an operator. The most common operators are Pauli operators X, Y, Z, and Hadamard H, which have the following matrix representation:
0 1 X 1 0
=
0
0 Y i
i
−
=
1 0
0 1
Z
= − 1 1
1 1
H
= − (eq. 9) The X gate performs the same action of NOT classical gate. Hadamard gate is used to put one state in a superposition with the same probabilities, such as:
0 1 ( 0 1 )
2
H = + 1
1 ( 0 1 )
2
H = − (eq. 10)
As we saw, the gates in quantum computation are unitary operators represented by its matrix.
Quantum circuits have the same representation of classical circuits. Figure 2 shows a general quantum circuit diagram.
Figure 2. Quantum circuit diagram.
In this circuit diagram, the state x contains the input data in a superposition state. The state y is an ancilla state, generally been in 0 state. We will consider Uf as a black box that performs the desired operation. Thus, with x been in superposition, we can apply Uf over all values in x simultaneously:
, , ( )
Uf x y = x y⊕ f x (eq. 11) During the processing, the probability of each state is changed according to the applied operations, which
correspond to matrix multiplications. When the algorithm is finished, it is made a measurement that results in the major probability state.
For example, consider x and y been in state 0 . Applying one Hadamard gate on the state x , we will put it in a superposition state, like in equation12:
( )
0 1 1
0 00 10
2 2
0, 0 (0) 1, 0 (1) 2
f f f
U U U
f f
+
= +
⊕ + ⊕
=
(eq. 12)
The equation 12 shows the processing using the superposition principle, so that the calculus of the f(0) and f(1) are made at the same time. Apparently, this sounds great, however, the quantum mechanics tell us that it is not possible to obtain all values of superposition. So, we can say that one qubit can be in superposition state in computation time, and when we made a measurement, the superposition state collapses to state that has the biggest probability. Thus, we can not obtain all possible output values, so, limiting the power of quantum computers, but there is some techniques to solve this problem (this will not be covered in this paper).
To conclude, the main advantage of quantum computers is the possibility of solving some problems that in classical computing would spend an impracticable time, such as factorization, information retrieval in not ordered database, and so on. The next section describes the Quantum Fourier Transform, the analogous of DFT in classical computation.
3.1 Quantum Fourier Transform
At the digital image processing using quantum computing, it is used the QFT, instead of FFT. Here, it is described the QFT algorithm, according with [3], [4] and [5].
The QFT algorithm receives as input a vector of complex numbers x0, x1, x2, ..., xN-1 with length N, and results at the output, another complex numbers vector, defined by equation 13:
1
2 /
0
1 0 i j k 0
k j
j
y x e
0
− π
=
=
∑
(eq. 13) A QFT can be described as FFT, with some different notations. Thus, a QFT in the computational base { 0 ,..., 0−1 } is defined as a linear operator, which operates at the base as equation 14:1
2 /
0
| 1 |
0
i j k 0
k
y e k
0
− π
=
> →
∑
> (eq. 14)and the action to an arbitrary state is given as equation 15:
1 1
0 0
| |
0 0
j k
j k
x j y k
− −
= =
> → >
∑ ∑
(eq. 15) where each amplitude yk is a discrete transform of the amplitudes x j.The inverse transform, denoted IQFT, is a linear operator whose action is given by equation 16:
1
2 /
0
| 1 |
0
i j k 0
j
k e j
0
− π
−
=
> →
∑
> (eq. 16) Another useful QFT notation is the product representation, given by equation 17:(
2 0.) (
2 0. 1)
1 / 2
| 0 | 1 | 0 | 1
| ...
2
n n n
i j i j j
n n
e e
j j
π π −
> + > > + >
> →
(eq. 17) where the state j is described in binary notation
1 2 0
12n 22n ... n2
j=j − + j − + + j , and the notation 0.j = jl
jl+1 ... jm represent the binary fraction j = jl /21 + jl+1 /42+ ... + jm /2m-l+1 .
The product representation makes easier the quantum circuit construction. Figure 3 shows an efficient QFT quantum circuit.
At Figure 3 the Rk gate represents the operation described by the matrix given by:
2 / 2
1 0
0 k
k i
R
eπ
=
(eq. 18) and H gate represents and operation known as Hadamard, given by:
1 1
1 1
H
= − (eq. 19)
The algorithm starts with one Hadamard operation, and n-1 conditional rotations at the first qubit j1 , totalizing n operations. The conditions are controlled by other input qubits j2 ,..., jn . It is followed by the application of another Hadamard operation, and n-2 rotations, to the second qubit, j2 , totalizing (n-1) operations. Thus, it is noted that n + (n-1) + ... + 1 = n + (n-1)/2 operations are needed, and at most, n/2 operations to change the bit order, each one constructed by CNOT gate. It is noted that the CNOT gate can be described by the diagram of Figure 4,
| >
| >
| >
| >
Figure 4. CNOT gate
whose operation can be described, with the inputs α e β at left, and the outputs at right. The upper output is a copy of the corresponding upper input, and the lower output is controlled by the upper input, resulting in exclusive-or operation of the inputs.
As final results, considering 0 = 2n, the QFT circuit has a computational cost of O((log20)2), that is exponentially faster than the FFT algorithm, that has a computational cost of O(0 log2 0).
4. Results
These results are given in terms of computational cost.
The FFT algorithm has the cost of O (0 log2 0), and the QFT has the cost of O((log20)2).
Table 1 shows the comparison of the computational cost between FFT and QFT algorithms.
Figure 3. QFT quantum circuit.
Table 1. FFT, and QFT algorithms costs.
= 2n FFT
log2
QFT (log2)2
Computational advantage FFT/QFT
4 8 4 2,00
8 24 9 2,67
16 64 16 4,00
32 160 25 6,40
64 384 36 10,67
128 896 49 18,29
256 2.048 64 32,00
512 4.608 81 56,89
1.024 10.240 100 102,40
2.048 22.528 121 186,18
4.096 49.152 144 341,33
8.192 106.496 169 630,15
1.048.576 20.971.520 400 52428,80
At the last row, we have a 1.048.576 inputs. We can think this as been an image with 1024x1024 pixels. Also, this table shows that the advantage of QFT over FFT increases when the input number increases.
4. Conclusion
The proposal of this work is to explore the possibilities of the use of QFT in image processing, considering that QFT has a better computational cost than FFT.
This work is just theoretical. We still don’t have quantum computers available commercially, but it is expected that in near future. There are some theoretical works in quantum computation that shows algorithms with better performance than its analogous in classical computation.
Currently, quantum computers are desired to solve problems in quantum mechanics and a few problems in computer science. So, we tried, in this work, to show a possible real world application where quantum computers may be used.
As future work, we will try to use quantum computer simulators to simulate the QFT applied in an image transform.
5. References
[1] SHAPIRO, L. G.; STOCKMAN, G. C. Computer Vision. Prentice Hall, 2001.
[2] GONZALEZ, R.; WOODS. R. Processamento de imagens digitais. São Paulo: Edgar Blücher, 2000.
[3] IMRE, S.; BALÁZS, F. Quantum Computing and Communications: an engineering approach.
Chichester: John Wiley & Sons, 2005.
[4] KAYE, P.; LAFLAMME, R.; MOSCA, M. An Introduction to Quantum Computing. New York:
Oxford University Press, 2007.
[5] NIELSEN, M. A,; CHUANG, I. L. Quantum computation and Quantum information. Cambridge, Cambridge University Press, 2000.
[6] McMAHON, D. Quantum computing explained.
Hoboken, John Wiley & Sons, 2008.
[7] BELLAC, M. L. A short introduction to quantum information and quantum computation. Cambridge:
Cambridge University Press, 2006.
[8] BENETI, G.; CASATI, G.; STRINI, G. Principles of quantum computation and information. Volume I:
basic concepts. New Jersey: World Scientific Publishing Company, 2004.
[9] CHEN, G.; CHURCH, D. A.; et. al. Quantum computing devices: principles, designs and analysis.
Boca Raton: CRC Press, 2007.
[10] KAYE, P.; LAFLAMME, R.; MOSCA, M. An Introduction to Quantum Computing. New York:
Oxford University Press, 2007.
[11] JOZSA, R. Quantum algorithms and the Fourier transform. Available in: <http://qso.lanl.gov/qc/
proceedings/josza.ps>. Last accessed: 01 jul. 2007.
[12] MERMIN, N. D. Quantum computer science: an introduction. Cambridge: Cambridge University Press, 2007.
[13] NAKAHARA, M.; OHMI, T. Quantum computing:
from linear algebra to physical realizations. Boca Raton: CRC Press, 2008.
[14] PERRY, R. T. The temple of quantum computation.
Available in: <http://www.toqc.com/>. Last accessed: 20 out. 2006.
[15] PORTUGAL, R. et. al. Uma introdução à computação quântica. São Carlos: Sociedade Brasileira de Matemática Aplicada e Computacional, 2004.
[16] PRESKILL, J. Lecture 0otes for Physics 229:
quantum information and computation. California Institute of Technology, 1998. Available in:
<http://theory.caltech.edu/~preskill/ph229/#lecture>.
Last accessed: 09 ago. 2007.