Quantum image classification using principal component analysis

04/02/2015 ∙ by Mateusz Ostaszewski, et al. ∙ Institute of Theoretical and Applied Informatics 0

We present a novel quantum algorithm for classification of images. The algorithm is constructed using principal component analysis and von Neuman quantum measurements. In order to apply the algorithm we present a new quantum representation of grayscale images.



There are no comments yet.


page 1

page 2

page 3

page 4

This week in AI

Get the week's most popular data science and artificial intelligence research sent straight to your inbox every Saturday.

1 Introduction

At the end of the last century a new paradigm of computation was proposed i.e. quantum computation. Although it is not yet obvious whether useful quantum computers can be constructed, the field of quantum algorithms development in recent years progresses very rapidly [2], [1]

. For example many new algorithms for quantum machine learning and quantum image processing were recently created

[9], [11].

In this work we introduce an algorithm for image classification of grayscale images based on classical principal component analysis (PCA) and quantum measurement. The general idea behind the algorithm is following. Given a set of training images, using PCA we train a classifier to detect images similar to those in the training set. Effectively we divide the image signal space into two orthogonal subspaces. The first one — spanned by the leading principal components — catches the most of the variability of the signal in the training set, the second one consists mostly of noise.

After the classifier is constructed the leading principal components are used to create a projector onto a subspace of quantum states. The image which is being classified is also encoded on a quantum state, and then measured using the projector defined above.

The paper is organised as follows in Section 2 we recall basic notions of quantum computation, in Section 3 we shortly discuss state of the art in quantum image processing, in Section 4 we introduce image classification algorithm. And finally in Section 5 we draw conclusions.

2 Essentials of quantum computation

Lets consider the most basic model of a quantum system – a qubit – elementary quantum system with two basic physical states. In order to provide mathematical description of a state of a qubit we choose an orthonormal basis in the corresponding Hilbert Space. In this case we consider two dimensional Hilbert Space. Our basis will consist two vectors that in the braket notation take the form


The vector is called ‘ket’ and its Hermitian conjugation is called ‘bra’. We can represent any valid state of a qubit as normalized linear combination of the basis vectors:


where and .

The operation which allows us to join

independent qunit systems is the tensor product. Lets take

qunit states


We can write their joint state in as


The other way of joining quantum systems into a bigger one is use of the direct sum. The joint state of two states is


We can also consider more general quantum systems called quits. Let (ket) be a normed column vector from Hilbert space with orthonormal basis . Dual vector to ket is (bra). In such case the state of the system is represented as .

We denote inner product of and by It has three properties:

  1. where equality holds iff ,

  2. ,

  3. .

Furthermore will be their outer product.

One of the most important concepts in quantum information is the measurement. The mathematical model of a measurement is as follows. At first we define a set of outcomes . Then we assign corresponding measurement operators . We request that the measurement operators satisfy the condition and .

The probability that we obtain outcome

when measuring a state is equal to


If we instantly measure the system for the second time, the outcome willstill be equal to with certainty because after the first measurement the state of the system changes into a state

3 Quantum image processing — state of the art

There are various ways in which classical data can be encoded on quantum states. The specific encoding depends on the type of the data and quantum algorithms that one wishes to execute.

3.1 Quantum representations of digital images

Below we recall various representations of quantum images proposed in recent years.

In the Qubit Lattice representation of grayscale images proposed in [14] the intensity of pixel at position is encoded on qubit .

The Real Ket representation introduced in [6] stores grayscale images in unnormalised quantum states of the form

where and subsequent quits serve as the position of pixel encoded in a quad-tree.

Flexible representation of quantum images (FRQI) captures information about pixel colours and their corresponding position. It is inspired by the pixel representation for images in the classical computers. The information is gather into a quantum state defined as follows


where and constitutes the vector encoding colours, is a fixed basis of a two dimensional complex Hilbert space, and is a basis of dimensional space responsible for encoding position in the image. The colour is encoded in a vector by which is connected by a Kronecker product with a vector responsible for a position in the image.

A novel enhanced quantum representation (NEQR) of digital images proposed in [18] encodes a grayscale image in a quantum state of the form

where is a discrete value of image intensity, quantised with levels of quantisations of pixel at position .

3.2 Quantum image processing algorithms

The sub-field of quantum computation that deals with algorithms development for quantum image processing is developing very rapidly. At least a hundred papers discussing this subject were published in recent fifteen years.

It should be noted that, some of classical image transformations already have their quantum analogues. For example we can list here quantum Fourier transform 

[10], quantum discrete cosine transform [5, 12], and quantum wavelet transform [4].

There exists several clever techniques to process images encoded in quantum states for example in [3] authors propose a way to perform template matching algorithm using quantum Fourier transform and amplitude amplification. In paper [8] the authors extended the use of quantum circuit models for quantum image representation and processing. They developed three strategies to extend the number of geometric transformations [7] on quantum images using the FRQI representation of quantum images. In [16] authors propose quantum algorithms for edge detection and image filtering based on projective measurement. In [17] the authors propose a model for storing and operating on infra-red images.

Complex quantum image processing requires a number of basic algorithmic primitives. In [15] authors develop quantum image translation, which maps the position of each picture element into a new position. In [19] an algorithm for comparing colour quantum images based on FRQI model is described.

4 Algorithm

The aim of our algorithm is classification of quantum images. The input of the algorithm is a quantum representation of an image which we want to test. Algorithm requires a set of principal components. The output is “” or “” and answers the question whether the image exhibits features represented by principal components.

4.1 Principal Component Analysis

In order to create our quantum classifier we use Principal Component Analysis (PCA). This technique has been successfully applied in the domain of signal processing to various datasets. In celebrated classical paper [13] it was applied to classification of human faces.

Suppose we have matrix of data with rank . The matrix is composed of vertically stacked horizontal sample vectors. We assume that our samples are normalised i.e. have norm equal to one.

Then by SVD we have where and are orthogonal matrices. The matrix is such that with .

The numbers are called singular values, i.e.

non-negative square roots of the eigenvalues of

. The columns of

are eigenvectors of

and the columns of are eigenvectors of . The -th column vector of the matrix is called the -th principal component of the data.

4.2 Quantum image representation

Suppose we have a features vector of values , where . The quantum system encoding the data from the feature space will be a direct sum . Quantum representation of a picture will be a mapping from to defined by


where pixels are represented by


We will use quantum representation of vectors from PCA in the same way. Let be a set of principal components with values and be a set of quantum representations of them. Representation of each quantum vector chosen from PCA is encoded on different 2-dimensional subspace of such that each of the pixels is transformed into


where and is a pixel index. The whole principal component representation is composed of the pixel representations the same way as in eq. (8). Lets take two vectors and their quantum representation . Inner product of and is


and for corresponding quantum representations one reads


where the first equality is from eq. (8) and the last one is implied by orthonormality of the basis vectors. From eq. (11) and eq. (12) we derive that inner product of two vectors is equal to inner product of quantum representations of these vectors with respect to a constant factor . This is an important feature of the introduced representation, which is significant for the algorithm.

4.3 Construction of measurement

The quantum algorithm for principal component analysis is based on classical methods for determining the characteristic subspace of the data set in the features space. Thus we take principal components that describe the data set crucial properties. The quantum algorithm for principal components analysis will utilise the system defined in the previous section. In order to use the classically computed components in the quantum algorithm we need to convert our principal components into quantum representation .

The developed algorithm is based on the quantum measurement schema. We consider two elements output set . The first of the resulting labels will correspond to the principal components subspace and the other to the rest of the feature space. Thus we create two measurement operators and . The principal components projection operator is of the form


4.4 Measurement probabilities

Let be a input feature vector and set of the principal components. In the classical model we measure the likelihood of the input data being in the control set in the following way


Now let be a quantum representation of the input and be quantum representation of principal components with projector constructed as in eq. (13). Then the probability of the result of the measurement being for a given input is


where the last equation results from eq. (11) and eq. (12). Thus the probability is linearly dependent on the classical likelihood measure with respect to a factor . where last equation is from eq. (11) and eq. (12). Thus the probability linearly dependent on the classical likelihood measure with factor .

Because of the factor we perform tests. We assume that we have copies of the quantum representation of the vector . We perform the measurement on each of the copies. If any of the measurements returns “yes” then the algorithm returns positive answer. If not, the answer is negative. The probability that our algorithm will return the output “no”for a given input vector is equal to


Probability of positively classifying the input image in most of the cases is close to the classical likelihood measure. In general the probability is slightly lower. Thus the algorithm trifle favors the negative answer.

5 Concluding remarks

In this paper we provided a new quantum representation of digital images and an algorithm for classification of said images. The principal component analysis is used during the learning phase of the algorithm which is performed classically and its goal is to construct a quantum measuring device. Classification is performed by applying the measurement apparatus on the quantum states that represent input images. The measurement is performed on multiple copies of the image. Therefore the paper provides complete system for classification of digital images.

6 Acknowledgements

Work by M.O. and P.S. was supported by Polish National Science Centre grant number DEC-2011/03/D/ST6/00413. Work by P.G. was supported by Polish National Science Centre grant number DEC-2011/03/D/ST6/03753.


  • [1] Ambainis, A.: Recent Developments in Quantum Algorithms and Complexity. In: Descriptional Complexity of Formal Systems, p. 1–4. Springer (2014)
  • [2] Bacon, D., Van Dam, W.: Recent progress in quantum algorithms. Communications of the ACM 53(2), 84–93 (2010)
  • [3] Curtis, D., Meyer, D.A.: Towards quantum template matching. In: Optical Science and Technology, SPIE’s 48th Annual Meeting. p. 134–141. International Society for Optics and Photonics, http://proceedings.spiedigitallibrary.org/proceeding.aspx?articleid=768557
  • [4] Fijany, A., Williams, C.P.: Quantum Wavelet Transforms: Fast Algorithms and Complete Circuits. arXiv preprint quant-ph/9809004 (1998)
  • [5] Klappenecker, A., Rotteler, M.: Discrete cosine transforms on quantum computers. In: Image and Signal Processing and Analysis, 2001. ISPA 2001. Proceedings of the 2nd International Symposium on. p. 464–468. IEEE (2001)
  • [6] Latorre, J.I.: Image compression and entanglement. arXiv preprint quant-ph/0510031 (2005)
  • [7] Le, P.Q., Iliyasu, A.M., Dong, F., Hirota, K.: Fast geometric transformations on quantum images. IAENG International Journal of Applied Mathematics 40(3), 113–123 (2010)
  • [8] Le, P.Q., Iliyasu, A.M., Dong, F., Hirota, K.: Strategies for designing geometric transformations on quantum images. Theoretical Computer Science 412(15), 1406–1418 (2011)
  • [9] Lloyd, S., Mohseni, M., Rebentrost, P.: Quantum algorithms for supervised and unsupervised machine learning. arXiv preprint arXiv:1307.0411 (2013)
  • [10] Nielsen, M.A., Chuang, I.L.: Quantum computation and quantum information. Cambridge university press (2010)
  • [11] Schuld, M., Sinayskiy, I., Petruccione, F.: An introduction to quantum machine learning. Contemporary Physics (ahead-of-print), 1–14 (2014)
  • [12] Tseng, C.C., Hwang, T.M.: Quantum circuit design of 8 8 discrete cosine transform using its fast computation flow graph. In: Circuits and Systems, 2005. ISCAS 2005. IEEE International Symposium on. p. 828–831. IEEE (2005)
  • [13]

    Turk, M.A., Pentland, A.P.: Face recognition using eigenfaces. In: Computer Vision and Pattern Recognition, 1991. Proceedings CVPR’91., IEEE Computer Society Conference on. pp. 586–591. IEEE (1991)

  • [14] Venegas-Andraca, S.E., Bose, S.: Storing, processing, and retrieving an image using quantum mechanics. In: AeroSense 2003. p. 137–147. International Society for Optics and Photonics (2003)
  • [15] Wang, J., Jiang, N., Wang, L.: Quantum image translation. Quantum Information Processing p. 1–16 (2014), http://dx.doi.org/10.1007/s11128-014-0843-6
  • [16] Yuan, S., Mao, X., Chen, L., Xue, Y.: Quantum digital image processing algorithms based on quantum measurement. Optik-International Journal for Light and Electron Optics 124(23), 6386–6390 (2013)
  • [17] Yuan, S., Mao, X., Xue, Y., Chen, L., Xiong, Q., Compare, A.: SQR: a simple quantum representation of infrared images 13(6), 1353–1379, http://link.springer.com/article/10.1007/s11128-014-0733-y
  • [18] Zhang, Y., Lu, K., Gao, Y., Wang, M.: NEQR: a novel enhanced quantum representation of digital images. Quantum Information Processing 12(8), 2833–2860 (Mar 2013)
  • [19] Zhou, R.G., Sun, Y.J.: Quantum multidimensional color images similarity comparison. Quantum Information Processing p. 1–20 (2014), http://dx.doi.org/10.1007/s11128-014-0849-0