Quantum pixel representations and compression for N-dimensional images

We introduce a novel and uniform framework for quantum pixel representations that overarches many of the most popular representations proposed in the recent literature, such as (I)FRQI, (I)NEQR, MCRQI, and (I)NCQI. The proposed QPIXL framework results in more efficient circuit implementations and significantly reduces the gate complexity for all considered quantum pixel representations. Our method scales linearly in the number of pixels and does not use ancilla qubits. Furthermore, the circuits only consist of \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$R_y$$\end{document}Ry gates and \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\text {CNOT}$$\end{document}CNOT gates making them practical in the NISQ era. Additionally, we propose a circuit and image compression algorithm that is shown to be highly effective, being able to reduce the necessary gates to prepare an FRQI state for example scientific images by up to 90% without sacrificing image quality. Our algorithms are made publicly available as part of QPIXL++, a Quantum Image Pixel Library.


Introduction
The growth in scientific data size and heterogeneity overwhelms current statistical and learning approaches for analysis and understanding.More specifically, the analysis of image-based data becomes increasingly challenging using current classical algorithms.Consequently, finding more efficient ways of handling scientific data is an important research priority.
Quantum computing holds the promise of speeding up computations in a wide variety of fields [27], including image processing.One of the research challenges to make quantum computing a viable platform in the post-Moore era is to reduce the complexity of a quantum circuit to accommodate many qubits.The current and near-term quantum computers, known as noisy intermediate-scale quantum (NISQ) devices, are characterized by low qubit counts, high gate error rates, and suffer from short qubit decoherence times [28].Hence, optimizing quantum circuits into short-depth circuits is extremely important to successfully produce high-fidelity results on NISQ devices.
Quantum image processing (QIMP) extends the classical image processing operations to the quantum computing framework [37].QIMP algorithms are used on images that have been represented in a quantum state.A variety of quantum image representation (QIR) methods has been developed [36].The flexible representation of quantum images (FRQI) [18,19], the improved flexible representation of quantum images (IFRQI) [17], the novel enhanced quantum representation (NEQR) [41], the improved novel enhanced quantum representation (INEQR) [15], the multichannel representation of quantum images (MCRQI/MCQI) [33,32], the novel quantum repre-sentation of color digital images (NCQI) [29], and the improved novel quantum representation of color digital images (INCQI) [31] are among the most powerful existing QIR methods.These QIR methods became extremely popular due to two main factors.First, their flexibility in encoding the positions and colors in a normalized quantum state.Second, image processing operations can be performed simultaneously on all pixels in the image by exploiting the superposition phenomenon of quantum mechanics.
In this paper, we introduce a uniform framework called the quantum pixel representation (QPIXL) that overarches all previously mentioned quantum image representations and probably many more.Furthermore, we propose a novel technique for preparing QPIXL representations that requires fewer quantum gates for all the different representations, compared to earlier results, and without introducing ancilla qubits.The proposed method makes use of an efficient synthesis technique for the uniformly controlled rotations [25] and uses only R y gates and controlled-NOT (CNOT) gates, making the resulting circuits practical in the NISQ era.For example, the original FRQI state preparation method [18] for an image with N = 2 n grayscale pixels uses n + 1 qubits in total, i.e., n qubits for encoding the position and 1 qubit for the color, and has a O(N 2 ) gate complexity.Recently, the FRQI gate complexity has been reduced to O(N log 2 N ) at the price of introducing several extra ancilla qubits [17].In contrast, our QPIXL method for preparing an FRQI state has only a gate complexity of O(N ) and does not require extra ancilla qubits.Additionally, we introduce a compression strategy to further reduce the gate complexity of QPIXL representations.In our experiments, the compression algorithm allows us to further reduce the gate complexity by up to 90% without significantly sacrificing image quality.An implementation of our algorithms is publicly available as part of the Quantum Image Pixel Library (QPIXL++) [5] at https://github.com/QuantumComputingLab.QPIXL++ is build based on QCLAB++ [6,34], which allows for creating and representing quantum circuits.
The remainder of the paper is organized as follows.Section 2 discusses the relevant related work in the literature.Section 3 defines the quantum pixel representation formalism that encompasses different image representations with specific color mappings.Section 4 reviews the FRQI format for grayscale image data as a specific case of a quantum pixel representation, and its circuit design using pixel-by-pixel multi-controlled rotation gates [18].In Section 5, we introduce the uniformly controlled rotation approach as a replacement of the pixel-by-pixel one and show that it improves the gate complexity to all earlier results [18,17].Section 6 introduces a novel compression technique to further reduce the gate complexity of the uniformly controlled rotation circuit.In Section 7, we extend our formalism to MCRQI for color images, and to IFRQI and NEQR formats, which have various advantages compared to FRQI.We show how a compressed uniformly controlled rotation circuit can be used to improve the gate complexity for all these representations.Section 8 provides simulated examples obtained with QPIXL++ that demonstrate the significant reduction in gate complexity obtained with our method and the efficacy of the compression algorithm.Finally, Section 9 summarizes the proposed work and discusses future research.

Related work
Almost every image processing algorithm [12] developed in the classical sense can also be developed in the quantum environment.These quantum versions may be computationally faster and may handle data more effectively by taking advantage of properties such as coherence, superposition, and entanglement associated with quantum science.How an image is represented on a quantum computer dramatically influences the image processing operations that can be applied.Hence, QIR has become a vital area of study in QIMP.Early approaches are the qubit lattice representation [35] and the flexible representation of quantum images (FRQI) [18].The latter, which is the FRQI method forms the foundation of our work.The former is a quantum counterpart of classical image representation models without any significant performance improvement, while FRQI is based on quantum mechanical phenomena and captures both the color and geometry of an image in one quantum state.Besides its flexibility and the use of fewer qubits, FRQI can also perform both geometric and color operations on the image concurrently [30].
Since the FRQI only uses one qubit for storing the color information, the number of measurements to accurately retrieve an image can be very large.The NEQR addresses this issue by storing the color information in orthogonal states allowing for color retrieval in a single measurement.Although the NEQR allows for accurate image retrieval, it requires significantly more qubits and does not utilize the superposition principle in the color qubit sequence, i.e., qubits basis states are used for images with bit depth .On the other hand, the IFRQI combines both ideas and utilizes limited and discrete levels of superposition that are maximally distinguishable.The IFRQI therefore ensures accurate image retrieval with a small number of measurements, however, it requires log 2 (N ) − 2 extra ancilla qubits.Other existing quantum image representation models are the quantum image representation for log-polar images (QUALPI) [42], the n-qubit normal arbitrary superposition state (NASS) [22], and the generalized quantum image representation (GQIR) [14].
Several quantum image processing algorithms have been introduced in the literature using these QIRs.For example, Zhang et al. [40,43] introduced an image edge extraction algorithm (QSobel) based on FRQI and also a quantum feature extraction framework based on NEQR.Jiang et al. [16] recently proposed a new quantum image median filtering based on the NEQR.There are image segmentation algorithms that utilizes different QIRs along with the quantum Fourier transform [27,7].Jiang et al. [14] developed a new quantum image scaling up algorithm based on the GQIR.Li et al. [21] developed a quantum version of the wavelet packet transforms based on the NASS.Zhou et al. [44] proposed a quantum realization of the bilinear interpolation method for NEQR.There are several other examples in major application areas including image filtering [8,38,23,39], image segmentation [9,10,24], and machine learning [26,13,1,4,11].
In order to run a quantum algorithm on a NISQ device, it first needs to be synthesized into elementary 1-and 2-qubit gates.The original implementation of the FRQI [18] required O(N 2 ) elementary gates, while the more recent implementation by Khan [17] reduced the complexity to O(64N log 2 N ) elementary gates by introducing log 2 (N )−2 extra ancilla qubits.We propose a novel QPIXL synthesis approach that reduces the FRQI gate complexity to O(2N ), i.e., N rotation R y gates and N CNOT gates, and does not require ancillary qubits.Furthermore, our QPIXL synthesis approach also reduces the original IFRQI gate complexity from O(pN log 2 N ) to only O(pN ) and also gets rid of the ancilla qubits.Similar gains are obtained for preparing (I)NEQR, MCRQI, and (I)NCQI states.

QPIXL: Quantum pixel representations
Some of the most widely used representations for quantum images, such as (I)FRQI [18,17], (I)NEQR [41,15], MCRQI [32], and (I)NCQI [29,31], can all be described by the following general definition for quantum image representations.This representation is similar to the pixel representation for images on traditional computers and captures both pixel colors and positions into a single quantum state |I that we call a quantum pixel representation, QPIXL in short.
Definition 1 (Square QPIXL).The quantum state for the QPIXL representation of a 2 m × 2 m image P = [p ij ], where each pixel p ij has color c ij , is given by the normalized state where |k are the computational basis states on 2m-qubits and |c k is an encoding of the color information c ij in a quantum state on one or more qubits.The color values |c k should be regarded as a vectorized version of the 2D color values c ij , i.e., We observe that the QPIXL state |I creates an equal superposition over the computational basis states of the 2m-qubits in the first register, which encodes the pixel positions, and applies a tensor product with the state on the second register that encodes the color information.Definition 1 is general because it allows for flexibility in the type of color information and color encoding that is used.The mentioned QPIXL representations differ in their approach to map c ij to |c k .
Since Definition 1 can trivially be extended to rectangular, 3D, and higher dimensional images, we will use the following more general definition.
Definition 2 (General QPIXL).The quantum state for the QPIXL representation of an image of N pixels p k is given by the normalized quantum state where n = log 2 N , |c k is an encoding of the color information of pixel p k , and |k are the computational basis states on n-qubits.
Remark that in case the number of pixels N is not a power of 2, Definition 2 appends zerovalued pixels for k = N, N + 1, . . ., 2 log 2 N − 1.Consequently, the state (2) is fully determined by the N pixel values p k .Without loss of generality, we will assume that N = 2 n in the remainder of the paper.

QPIXL quantum circuit implementation
The preparation of a QPIXL state on a quantum computer can be considered as a state preparation procedure, i.e., |I is the result of a quantum circuit U QPIXL applied to the all-zero state |0 ⊗n+ , where n qubits are used to encode the pixel position and qubits are used for the color information.

|I
All QPIXL states are prepared in two steps: first creating an equal superposition over the n qubits that determine the pixel positions and afterwards adding the color information to the state by means of a unitary U |c .In matrix notation, this procedure yields where H ⊗n ⊗ I ⊗ creates an equal superposition over the first n qubits:

FRQI in the QPIXL framework
The FRQI [18,19] fits Definitions 1 and 2 of the QPIXL framework and is applicable to grayscale image data.An FRQI encoding uses only 1 qubit for the pixel intensity information |c k with a color mapping that is defined as follows.
Definition 3 (FRQI mapping).For a grayscale image of N pixels p k where each pixel has a grayscale value g k ∈ [0, K], i.e., an integer value between 0 and the maximum intensity K, the QPIXL state with the FRQI mapping |I FRQI is defined by Definition 2 with the color mapping used in (2) given by Observe that the FRQI representation of an N -pixel grayscale image requires n + 1 qubits in total: n qubits for the pixel positions in |k and 1 qubit for encoding the corresponding pixel intensity information in |c k .By Eq. ( 5), we have that θ k ∈ 0, π 2 and Definition 3 is flexible because the grayscale value of each pixel p k can be encoded by choosing the angles θ k accordingly.For example, consider an 8-bit grayscale image where each pixel p k has a grayscale value g k between 0 and 255, then the angles θ k in Eq. ( 5) are given by On the other hand, repeated measurement of the quantum state |c k yields the probabilities α 2 k = cos 2 (θ k ) and β 2 k = sin 2 (θ k ) for the basis states |0 and |1 , respectively.Hence, we can retrieve the grayscale values from these measurements by We assume until Section 7 that all image data is in grayscale and that we use the FRQI encoding from Definition 3.

QPIXL-FRQI quantum circuit implementation
The circuit structure introduced in Section 3.1 can be used to prepare the FRQI state on a quantum computer.In this case we have = 1 and U |c that implements the mapping from Definition 3, we will denote this unitary as U R .This specification yields with, according to Eq. ( 4), We define with Since U R is by definition a block diagonal matrix with N 2 × 2 blocks and the prepared FRQI state (9) becomes which is a vector of length 2N holding the cosine and sine values of the angles of all the pixels.It can be directly verified that this definition of U R agrees with Definition 3. We can implement the U R circuit on a quantum computer by using N multi-controlled R y gates [18].We use the notation C n (R y ) for an R y gate with n control qubits.To illustrate this, we consider the FRQI encoding of a 2 × 2 image.This 4 pixels image can be implemented as follows using 3 qubits and 4 C 2 (R y ) gates: The angles θ i correspond to the pixel values p i for i = 0, 1, 2, 3 according to Eq. ( 5).The decomposition of the block diagonal matrix U R into multi-controlled R y gates corresponds to the following matrix decomposition where each multi-controlled gate sets a single 2 × 2 block on the diagonal.In order to actually run the U FRQI circuit on a quantum computer, we need to further synthesize the multi-controlled R y gates into elementary 1-and 2-qubit gates.For the case of C 2 (R y ) gates this can be done as follows [3]: yielding the following U FRQI circuit for the 4 pixels image example: By further decomposing the C 1 (R y ) gates into 3 R y and 2 CNOT gates as follows [27], • the directly implementable quantum circuit for U FRQI requires 44 single-qubit and 32 CNOT gates in total.In the general case for images with N = 2 n pixels, every individual pixel value is encoded by a C n (R y ) gate.Decomposing these gates into 1-and 2-qubit gates by the method of Barenco et al. [3] requires O(N ) gates for every C n (R y ) gate.This results in an overall circuit complexity for U FRQI that scales quadratically in N , i.e., O(N 2 ) elementary gates are required to implement the full U FRQI circuit for an N pixels image on a quantum computer [18].Khan [17] recently improved the asymptotic complexity to O(N log 2 N ) by using n − 2 ancilla qubits.

Optimal linear gate complexity
The complexity of implementing U FRQI is determined by the complexity of the circuit for U R , a block diagonal matrix with 2 × 2 blocks corresponding to the pixel values.In this section, we derive an alternative circuit implementation for U R that requires quadratically fewer gates compared to the method proposed by Le et al. [18], i.e., the asymptotic complexity of our novel implementation requires only O(N ) quantum gates for a N -pixel image.Our new approach thus has optimal asymptotic scaling.It is also logarithmically faster compared to the method proposed by Khan [17] and requires no ancilla qubits.We start by reviewing a special case of the method introduced by Möttönen et al. [25] to implement a block diagonal matrix in a quantum circuit.In that work, these circuits are called uniformly controlled R y rotations because they uniformly use all possible computational basis states in the control register.Let us define the nomenclature and diagrammatic notation for uniformly controlled R y rotations.Definition 4 (Uniformly controlled R y rotations).Given θ ∈ R N , a vector of rotation angles, the uniformly controlled R y rotation is defined as and represented diagrammatically as The dashed line indicates the n = log 2 (N ) qubits required for controlling the different diagonal positions in U R .The diagram on the right hand side uses a square control node to indicate that it is uniformly controlled by the first n qubits.
We know from the previous section that we can implement U R by using N C n (R y ) gates.Here, we show that we can do this more efficiently by using a circuit that only consists of R y and CNOT gates.As an illustrative example, let us consider the following circuit for 4 arbitrary angles θ0 , . . ., θ3 : The following two properties of R y rotations are immediate: where X is a NOT gate [ 0 1 1 0 ] that appears in the CNOT gates above.We can analyze the circuit above using these two simple properties and show that the circuit does create a block diagonal matrix with 2 × 2 blocks on the diagonal: the R y rotations on the 3rd qubit are all block diagonal matrices and the CNOT gates permute some of the blocks depending on the index of the first two control qubits.If we list the four 2 × 2 diagonal blocks in binary order, or equivalently the state of the 1st and 2nd qubit, we see that the circuit has the following effect on each block: To implement a block diagonal matrix with this circuit, where the angles of the R y blocks correspond to (θ 0 , . . ., θ 3 ), we get that the angles have to satisfy . This is a linear system with a specific structure, that we can rewrite as where Ĥ = 1 1 1 −1 is a scaled version of the Hadamard gate and P G is the permutation matrix that transforms binary ordering to Gray code ordering.
It follows that, if we solve the linear system (18) for ( θ0 , . . ., θ3 ), we can implement U R for any 2 × 2 image with only 8 elementary gates: 4 R y rotations and 4 CNOT gates.The U R circuit for the 2 × 2 example in the previous section required 74 gates: 42 1-qubit and 32 CNOT gates.Indeed, we have a quadratic improvement in gate complexity.
This strategy generalizes to block diagonal matrices U R that have 2 n R y blocks on their diagonal [25].The circuit structure consists of a sequence of length 2 n alternating between R y gates and CNOT gates.The R y gates act on the (n + 1)st qubit, and thus correspond to block diagonal matrices with 2 × 2 blocks.The target qubit of the CNOT gates is set to the (n + 1)st qubit and the control qubit for the th CNOT gate is set to the bit where the th and ( + 1)st Gray code differ.If U R is determined by the angles θ = (θ 0 , . . ., θ 2 n −1 ), the angles of the circuit θ = ( θ0 , . . ., θ2 n −1 ) can be computed through the linear system: In QPIXL++, Eq. ( 19) is solved with a matrix-free approach: the Gray permutation P G is performed in place and the scaled Walsh-Hadamard transform Ĥ⊗n is implemented through a variant of the fast Walsh-Hadamard transform which requires O(N log N ) operations.This approach scales to large-scale images and we report some results in Section 8.
Our new U R circuit requires only N R y rotation and N CNOT gates for an image with N pixels.As this scales linearly in the number of pixels, the asymptotic complexity of our approach is optimal.This is a quadratic improvement compared to the approach proposed by Le et al. [18] that we described in Section 4. The asymptotic complexities of both approaches are summarized in Table 1.We remark that as we require just 2 gates for every pixel, our constant prefactor is also considerably smaller compared to the works by Le et al. [18] and Khan [17].

Gate complexity Ancilla qubits Total qubits
Le et al. [18] O(N 2 ) 0 n + 1 Khan [17] O Table 1: Summary of gate complexities and qubit count for preparing the FRQI state |I FRQI for an image with N = 2 n pixels with the approaches of Le et al. [18] and Khan [17] compared to our method.

Compression
The proposed implementation of U R as presented in Section 5 lends itself to an efficient circuit and thus image compression technique.As an example, we describe this idea for an FRQI image with 8 pixels.Assume that the FRQI angle representation of an image is given by the vector θ ∈ R 8 and that we have computed the transformed vector θ ∈ R 8 according to Eq. (19).The coefficients of θ are then used in the following circuit for U R : For conciseness, we omit the R y labels and only state the rotation angle for the R y gates.Now assume that the image after the permuted Walsh-Hadamard transform is of the form θ = ( θ0 , θ1 , δ, δ, δ, δ, δ, θ7 ), where δ are angles that can be considered negligible according to some compression criterion.A good approximation of the image is then given by θ = ( θ0 , θ1 , 0, 0, 0, 0, 0, θ7 ).This corresponds to the circuit below on the left where all R y rotations that have 0 angle after compression have been removed.This step results in a sequence of consecutive CNOT gates all with the same target qubit and different control qubits.All these CNOT gates commute with each other, so we can place them in arbitrary order.Furthermore, two consecutive CNOT gates that have the same control qubit cancel each other since their product is the identity.The circuit below on the left has in the middle 1 CNOT with the first qubit as control, 2 CNOTs with the second qubit as control that cancel out, and 3 CNOTs with the third qubit as control of which two cancel with each other.It follows that the circuit on the left is equivalent to the circuit on the right with the redundant CNOT gates removed.
As we describe next, this procedure easily generalizes to images of arbitrary size.After having computed θ, apply a compression criterion to set the negligible coefficients θi to 0. Next, remove the corresponding R y rotations with 0 angle from the U R circuit.Finally, perform a parity check on the control qubits of consecutive CNOTs in the U R circuit: no CNOT is required for control qubits with even parity, one CNOT is required for control qubits with odd parity.
This algorithm is implemented in QPIXL++ [5].The compression criterion that we adopted selects a fixed percentage of the coefficients θi with largest magnitude and thus of most importance.For example, a compression setting of 0% retains all nonzero coefficients in θ, while a compression of 40% sets the 40% smallest coefficients | θi | to zero.As we show in Section 8, this method can achieve high compression ratios while maintaining many features of the uncompressed image.The advantage of our approach is that we can discard coefficients after the Walsh-Hadamard transformation has been applied.In this way nonlocal correlations can be approximated with fewer coefficients compared to the untransformed data which can allow for improved compressibility.

Other QPIXL mappings
In this section, we extend our novel circuit implementation for U FRQI for grayscale data to different image representations that fit in Definitions 1 and 2. The key difference between all representations is the definition of the color encoding in the quantum state |c k from Definition 2. As long as we express this color mapping in terms of a combination of R y rotations, we can use our compressed implementation for the uniformly controlled R y rotations.

IFRQI
The improved FRQI method introduced by Khan [17] combines ideas from the FRQI and NEQR representations.It improves upon the measurement problem for FRQI by allowing for only 4 discrete superpositions that are maximally distinguishable upon projective measurement in the computational basis.The IFRQI color mapping for a grayscale image with bit depth 2p is defined as follows.
Definition 5 (IFRQI mapping).For a grayscale image of N pixels where each pixel p k has a grayscale value , the IFRQI state |I IFRQI is defined by Definition 2 with the color mapping used in (2) given by where, for i = 0, • • • , p − 1 .
We observe that the IFRQI mapping combines two bits of color information into one rotation.It follows that for an image with bit-depth 2p, we can prepare |I IFRQI using the circuit presented in Figure 1(a) with p uniformly controlled R y rotations.The rotation angles θ i correspond to bits 2i and 2i + 1 of all N pixels according to the values defined in Definition 5.These uniformly controlled rotations can be compressed independently with our compression algorithm.The gate and qubit complexites for IFRQI with our method compared to Khan [17] are listed in Table 2.

NEQR
The idea for NEQR is to use a color mapping that directly encodes the length bitstring for the grayscale information in the computational basis states on qubits.The NEQR states for different colors are thus orthogonal and can be distinguished with a single projective measurement in the computational basis.In our QPIXL framework, the NEQR mapping can be defined as follows.
Definition 6 (NEQR mapping).For a grayscale image of N pixels where each pixel p k has a value , the NEQR state |I NEQR is defined by Definition 2 with the color mapping used in (2) given by where .
By choosing the rotation angles θ i k orthogonal, we ensure that the color information in |I NEQR can be retrieved through a single projective measurement.The NEQR state can be prepared through the circuit shown in Figure 1(b), where the uniformly controlled rotations can again be compressed with our method.The gate complexities for the uncompressed circuits are listed in Table 2.

MCRQI
If we want to extend the applicability of the FRQI from grayscale to color image data, we have to allow for different color channels.This approach was dubbed multi-channel representation of quantum images (MCRQI) [32].We adapt their definition for RGB image data to our formalism and make some minor modifications.Definition 7 (MCRQI mapping).For a color image of N RGB pixels, where the color of each pixel p k is given by an RGB triplet (r k , g k , b k ) ∈ [0, K], the MCRQI state |I MCRQI is defined by Definition 2 with the color mapping used in (2) given by where We see that to encode the color information for an RGB image, we only require 2 additional qubits compared to grayscale data, which is a significant improvement over the classical case.Furthermore, we encode the color mapping as a tensor product of three qubit states, while Sun et al. [32] encodes the information in the coefficients of the color qubits, which entangles their state.Our implementation has the advantage that the different color channels are easily treated separately, while the color information can still be retrieved thanks to the normalization constraint.
The circuit implementation of |I MCRQI for the RGB mapping defined in Definition 7 then simply combines three uniformly controlled rotation circuits with different target qubits and coefficient vectors determined by the respective color intensities as shown in Figure 1(c).As the RGB color channels are independent of each other and the uniformly controlled R y gates have different target qubits, each of them can be compressed separately.The asymptotic gate complexity of our method compared to the work by Sun et al. [32] is listed in Table 2.As that work essentially uses the construction of Le et al. [18], we obtain a quadratic improvement before compression.

INCQI
Similarly to the NEQR, the (I)NCQI uses a color mapping directly encoding the length bitstring for each color value in a RGBα image in the computational basis stated on qbits.Consequently, this QIR can also be easily represented by our QPIXL framework through the mapping defined as follows.
Definition 8 (INCQI mapping).For a color image of N RGBα pixels, where the color of each pixel p k is given by a tuple (r k , g k , b k , α k ) and each channel value in the range [0, 2 − 1] has a binary representation, the INCQI state |I INCQI is defined by Definition 2 with the color mapping used in (2) given by where The definition above applies very similarly to the NCQI [29], only removing channel α from the equation.The INCQI state can be prepared through the circuit shown in Figure 1(d).This circuit is built using an NEQR circuit for each channel of the ICNQI.Similarly to previous QIRs, the uniformly controlled rotations used here can also be compressed with our method.The gate complexities for the uncompressed circuits are listed in Table 2 MCRQI Sun et al. [33] O(3N 2 ) Table 2: Summary of gate complexities and qubit count for preparing the different QIR states covered in this paper and QPIXL for an image with N = 2 n pixels.For the IFRQI state, the bit depth is given by 2p and for the (I)NEQR, MCRQI, and (I)NCQI states the bit depth is given by .

Further extensions
We remark that multiple extensions and combinations of the ideas presented in this section are possible.For example, where MCRQI is a color version of FRQI and (I)NCQI is a color version of NEQR, we can similarly define a color version of IFRQI.We can also adapt IFRQI to group an arbitrary number of bits instead of the two bit pairing from Definition 5.This reduces the required number of qubits and gates at the cost of quantum states that are less distinguishable and thus require more measurements.It is even possible to use different QPIXL mappings for different RGB color channels.For example, we can use an FRQI mapping for the red channel, an IFRQI mapping for the green channel, and an NEQR mapping for the blue channel.
Finally, although we have presented this discussion for image data in an RGB(α) space, as in the work by Sun et al. [32], our approach can be readily adapted to different color spaces and even multi-spectral or hyper-spectral data.In fact, different scientific applications frequently use images in different color spaces depending on the type of analysis needed.For example, the Y'CbCr space is known for its applicability to image compression.The I1I2I3 was created targeting specifically image segmentation.The HED space is advantageous in the medical field for the analysis of specific tissues.
Similarly, multi-spectral and hyper-spectral data are used in areas such as geosciences and biology, for example, where experts acquire different satellite images and mass spectrometry images respectively.In all these cases, our general definition of quantum pixel representations can be directly applied.

Experiments
This section describes a series of experiments that illustrate our proposed tools implemented in QPIXL++ [5].The current version of QPIXL++ supports the FRQI mapping from Definition 3 for grayscale image data of arbitrary dimensions.
Our first experiment replicates a result from Le et al. [19] with our U R circuit and compares the gate complexities.In this test, we consider 10 images with an 8 × 4 resolution containing representations of the digits 0 to 9 as shown in Figure 2.These binary images only contain black and white pixels.We require 5 qubits to encode the pixel location as we have 32 pixels in total.2: 8×4 image data containing digits 0 to 9, experiment replicated from Le et al. [19].Gate complexities for the 6-qubit U R circuits that prepare an exact representation of the image data.The last two rows provide the reduction in gate count for our method compared to Le et al. [18,19].All circuits contain 5 Hadamard gates to create an equal superposition over the first register.
The method of Le et al. [18] requires one C 5 (R y ) gate for every pixel, bringing the total up to 32 C 5 (R y ) gates.Every C 5 (R y ) gate is further decomposed into 93 R y and 92 CNOT gates.The experiment described by Le et al. [19] reduces the number of C 5 (R y ) gates through a compression algorithm that groups pixels with the same grayscale value.This method is effective for the binary data in Figure 2 as they report lossless compression ratios between 68.75% and 90.63%.Figure 2 compares the number of 1-qubit R y and CNOT gates for our method with the results from Le et al. [19].We ran our compression algorithm with a compression level of 0% to the U R circuit.Thus only coefficients in θ that are exactly 0 are removed, which means that our circuits are exact.
Figure 2 shows that our method always provides more than 95% reduction in gate count compared to the method from Le et al. [18,19] for this example.The advantage of our method becomes even more outspoken for larger images due to the quadratic improvement.
The next example we present concerns an image taken from the MNIST database [20] of handwritten digits.The image of the digit "3" has a resolution of 28 × 28 pixels that is zero padded to an image with 1024 pixels in QPIXL++ which means that roughly 75% of the coefficients are used for the actual image data.Figure 3 shows the images that are simulated with QPIXL++ at 5 different compression levels.There are no visual artifacts at 30% compression and also the image at 60% compression is close to the original quality.The image with a 75% compression ratio has more visual artifacts but is still clearly recognizable, while at 90% compression the quality begins to drop significantly.The corresponding gate complexities for the U R circuits are also listed in Figure 3, all circuits contain 10 Hadamard gates to create the superposition in the first register.We observe that the reduction in R y gates is in perfect agreement with the compression ratio, but that there is generally a smaller reduction in CNOT gates.This is in line with the expectations for our proposed compression algorithm described in Section 6: not all CNOT gates along a sequence of removable R y gates will cancel out.This experiment in particular clearly identifies a potential application of our QIR with compression to classification algorithms based on machine learning in quantum computers.
Our final example image stems from scientific data.This is a 256 × 256 pixels region from a cross-section of a ceramic matrix composite (fiber reinforced polymer) [2] imaged with X-ray micro computed tomography (microCT) at the LBNL ALS beamline 8.3.2.This type of image is frequently acquired by material scientists to study the development of material deformation under stress.Consequently, image analysis algorithms to detect the circular patterns present in the image for example (cross-sections of fibers) become extremely important.As the dimensions of this grayscale image are already a power of 2, it does not need to be zero-padded.It contains both large scale structure and fine scale details.We require 16 qubits to encode the pixel locations and 1 for the grayscale intensities such that the U FRQI circuit has a total of 17 qubits.The uncompressed U R circuit contains 2 16 or 65,536 CNOT and R y gates.We ran our compression algorithm on the data and the results are summarized in Figure 4.
As can be observed, the compression algorithm is very effective for this image.Up to 75% compression can be achieved while still maintaining both the large scale structure and the finer details.The large scale structure is still preserved at 95% compression, but the acuteness in the finer details is lost at this compression level.It is only at 99% compression that the image becomes completely dominated by compression artifacts.It becomes clear from this last example that our compression approach becomes extremely interesting when analyzing scientific data: (1) the amount of data to be processed is reduced, and (2) the approach maintains details in the image necessary  for further analysis, such as feature extraction for example.
To conclude the experiments section, we present benchmark data for solving the linear system (19) with the matrix-free methods that are implemented in QPIXL++.These timing results are obtained on an AMD Ryzen Threadripper 3990X 64-Core Processor @ 2.9 GHz with 256 GB RAM.The results are shown in Figure 5 for randomly generated image data ranging from 2 3 pixels up to 2 34 pixels.The latter corresponds to the equivalent of an image with a resolution of more than 17 gigapixels, a 4K video fragment with 2070 frames, or a 1080p video fragment with 8285 frames.Computing the coefficients for the uncompressed FRQI circuit with 2 34 pixels requires just over 5 minutes.The bottleneck is the memory required to store the image data.This experiment shows that our method easily scales to high resolution image and video data.

Conclusion
We have introduced an overarching framework for quantum pixel representations and showed how previously introduced image representations can be incorporated in the QPIXL framework.Among these methods are (I)FRQI, (I)NEQR, MCRQI, and (I)NCQI.We have proposed a novel circuit synthesis technique for preparing the quantum pixel representations on a quantum computer.This technique makes use of uniformly controlled R y rotations and significantly reduces the gate complexity for all aforementioned methods.Hence, the obtained circuits only require R y and CNOT gates which makes them feasible for the NISQ era.Our method requires the solution of a particular linear system which can be solved classically in O(N log N ) time with a matrix-free approach.Furthermore, it allows for an efficient image compression algorithm that works on the transformed image data.Our experiments show that this compression approach is very effective for the FRQI mapping and can further reduce the number of gates by as much as 90% while still retaining the most prominent features of the image in the FRQI state.We repeatedly show how our method can have great impact on the analysis of scientific data and for quantum machine learning applications in the future.We have implemented and tested our algorithms in a publicly available software package QPIXL++ [5] which supports QASM output.Benchmark timings show that QPIXL++ has excellent scaling properties and can handle high resolution image and video data.

Figure 3 :
Figure 3: 28 × 28 image data from the MNIST database simulated with QPIXL++ at various compression levels and corresponding gate counts of the 11-qubit U R circuit.The final two rows list the reduction in R y and CNOT gates compared to the uncompressed circuits.

Figure 4 :
Figure 4: 256×256 image data from of a ceramic matrix composite sample acquired using microCT simulated with QPIXL++ at various compression levels and corresponding gate counts of the 17-qubit U R circuit.The final two rows list the reduction in R y and CNOT gates compared to the uncompressed circuits.