A quantum image multiplication operation method, device and electronic equipment
By optimizing the quantum image multiplication algorithm, designing a quantum multiplier using the NEQR model, Tofoli gates, and quantum full adders, and reusing auxiliary qubits, the problem of low performance in quantum image multiplication in existing technologies is solved, enabling efficient simulation and large-size image processing on classical computers.
Patent Information
- Application Number
- CN202210723453.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-24
- Publication Date
- 2026-02-03
- Estimated Expiration
- 2042-06-24
AI Technical Summary
Existing quantum image multiplication methods have shortcomings in multiplication methods, quantum adders, and quantum image preparation methods, resulting in low computational performance and difficulty in simulation on classical computers.
By optimizing the quantum image multiplication algorithm, multiple quantum images with shared position information and in a superposition state are prepared using the NEQR quantum image representation model. The binary multiplication-based algorithm is improved by combining the Toffoli gate and the quantum full adder, a quantum multiplier is designed, and the auxiliary qubits are reused.
It improves the performance and simulation efficiency of quantum image multiplication operations, making it easier to implement on classical computers and suitable for larger-scale quantum image processing.
Smart Images

Figure CN115049571B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of quantum computing, and more specifically, to a quantum image multiplication operation method, apparatus, and electronic device. Background Technology
[0002] The NEQR quantum image representation model extends the grayscale information stored in the single-qubit probability amplitude of the FRQI model to the multi-qubit basis vectors. While retaining its operational flexibility, it allows for precise control of grayscale information. It can accurately recover and read images in a finite number of quantum measurements, and therefore has wide applications in quantum multiplication and division operations. Quantum image multiplication is based on quantum multipliers and can be applied to image enhancement, target extraction, and other fields in quantum image processing.
[0003] Existing quantum image multiplication methods have certain shortcomings in terms of multiplication methods, quantum adders, and quantum image preparation methods, resulting in low performance during quantum image multiplication algorithms. Therefore, improving the performance of quantum image multiplication algorithms and making them easier to simulate on classical computers is an urgent problem to be solved. Summary of the Invention
[0004] To address the problem of low performance in existing quantum image multiplication algorithms, this invention aims to provide a quantum image multiplication method, apparatus, and electronic device. This invention optimizes the multiplication method, quantum adder, and quantum image preparation method in existing quantum image multiplication algorithms, and reuses auxiliary qubits in quantum circuits. Therefore, it improves the performance of the quantum image representation algorithm, making it easier to simulate on classical computers.
[0005] The above-mentioned technical objective of the present invention is achieved through the following technical solution:
[0006] In a first aspect, the present invention provides a quantum image multiplication operation method, comprising:
[0007] Multiple quantum images sharing location information and in a superposition state were prepared based on the NEQR quantum image representation model;
[0008] Based on the quantum multiplier, any two quantum images from the multiple quantum images are multiplied to obtain a matrix of pixel values of the quantum images;
[0009] Information about each pixel in the matrix of pixel values of the quantum image is extracted and converted into classical image information. The quantum multiplication operation steps are improved based on binary multiplication. The quantum multiplication based on binary multiplication is designed using Toffoli gates and quantum full adders to obtain a quantum multiplier. The information includes the grayscale information and position information of the pixels in the quantum image.
[0010] Furthermore, based on the NEQR quantum image representation model, multiple quantum images sharing positional information and existing in a superposition state are prepared, specifically including:
[0011] Multiple quantum images sharing position information and in a superposition state are prepared using the NEQR quantum image representation model prepared row by row. In the process of preparing the grayscale information of the quantum image, auxiliary qubits are used to transmit position information, so that the position information and grayscale information correspond one-to-one, and the auxiliary qubits are reused by the zeroing operation.
[0012] Furthermore, based on the quantum multiplier, any two quantum images from the multiple quantum images are multiplied to obtain a matrix of pixel values for the quantum images, specifically including:
[0013] Step S31: Set the size information and gray value of the two quantum images, use the gray value at the same position information of the two quantum images as the multiplicand and multiplier, and use a quantum multiplier to perform multiplication operation, wherein the two quantum images are two parallel quantum images;
[0014] Step S32: The grayscale information and position information of each pixel in the quantum image are in a superposition state. After multiplying the grayscale value of each pixel, the auxiliary bits and the result storage bits are reused by setting them to zero.
[0015] Step S33: Traverse all pixels in the two quantum images and execute steps S31-S32 to multiply the two quantum images.
[0016] Furthermore, information about each pixel in the matrix of pixel values of the quantum image is extracted, and this information is converted into classical image information, specifically as follows:
[0017] Using the open-source quantum computing toolkit QISKIT, the IBMQ simulation cloud platform, and the package and environment management functions provided by Anaconda, we simulated and implemented quantum image multiplication operations in Python.
[0018] Furthermore, the operation steps of quantum multiplication are improved based on binary multiplication. A quantum multiplier is designed using Toffoli gates and quantum full adders, specifically including:
[0019] Obtain the multiplier and multiplicand data to be operated on, wherein the multiplier data has m qubits and the multiplicand data has n qubits;
[0020] The m-bit number of qubits is multiplied by the n-bit number of qubits using the Toffoli gate to obtain the first result in the m-th row;
[0021] The first result of m rows is added according to the corresponding result positions using a quantum full adder to obtain the second result; where multiplication and addition are implemented by the corresponding Toffoli gate and quantum full adder in the quantum circuit, respectively.
[0022] Furthermore, the first result in rows m is added according to the corresponding positions using a quantum full adder to obtain the second result, specifically:
[0023] A quantum full adder is used to add the binary numbers of the first m rows obtained through the Toffoli gate layer by layer. Then, the CNOT gate is used to store the output of the quantum full adder and the carry information into the corresponding qubits. Finally, a right-to-left shift operation is used to multiply the two binary numbers.
[0024] Furthermore, in the process of adding the binary numbers of the first m rows obtained through the Toffoli gate layer by layer using a quantum full adder: the zeroing operation is used to multiplex the qubits representing carry information and control bit information, where the zeroing operation means setting the state of the qubit to the |0> state.
[0025] Furthermore, we use a right-to-left shift operation to multiply the two binary numbers, specifically:
[0026] An m+n constant qubit, |res0>-|res(n+m-1)>, initialized to the |0> state, is reserved to store the multiplication result. Its initial value is m+n zeros, which are arranged from low to high bits from right to left. During the first addition operation, the addend is aligned with the least significant bit of this m+n bit, and the result is stored in this m+n bit. During the next addition operation, the addend is aligned with the second least significant bit of this m+n bit.
[0027] Secondly, this application provides a quantum image multiplication operation device, comprising:
[0028] A quantum image preparation module is used to prepare multiple quantum images with shared positional information and in a superposition state based on the NEQR quantum image representation model;
[0029] The processing module is used to perform multiplication operations on any two quantum images from multiple quantum images based on a quantum multiplier to obtain a matrix of pixel values of the quantum images.
[0030] The information conversion module is used to extract information of each pixel in the pixel value matrix of the quantum image and convert the information into classical image information; wherein the operation steps of quantum multiplication are improved according to binary multiplication, and the quantum multiplication based on binary multiplication is designed using Toffoli gate and quantum full adder to obtain a quantum multiplier; the information includes grayscale information and position information of pixels in the quantum image.
[0031] Thirdly, this application provides an electronic device including a memory and a processor, wherein the memory stores a computer program and the processor is configured to run the computer program to perform the method described in the first aspect.
[0032] Compared with the prior art, the present invention has the following beneficial effects:
[0033] 1. This invention designs a highly parallel and better performing quantum image multiplication operation, which improves simulation efficiency and lays a solid foundation for the theoretical experiments of other quantum image processing algorithms.
[0034] 2. This invention utilizes zeroing operations to reuse auxiliary bits, which significantly reduces the number of qubits required for quantum multipliers and quantum image preparation, enabling the successful simulation of the algorithm. Attached Figure Description
[0035] The accompanying drawings, which are included to provide a further understanding of embodiments of the invention and form part of this application, do not constitute a limitation thereof. In the drawings:
[0036] Figure 1 A flowchart illustrating a quantum image multiplication operation method provided in an embodiment of the present invention;
[0037] Figure 2 A schematic diagram of binary multiplication operation provided in an embodiment of the present invention;
[0038] Figure 3a A schematic diagram of a NOT gate in a universal quantum gate provided in an embodiment of the present invention;
[0039] Figure 3b A schematic diagram of the Hadamard Gate in a universal quantum gate provided in an embodiment of the present invention;
[0040] Figure 3c A schematic diagram of a CNOT Gate in a universal quantum gate provided in an embodiment of the present invention;
[0041] Figure 3d A schematic diagram of the Toffoli Gate in a universal quantum gate provided in an embodiment of the present invention;
[0042] Figure 3e A schematic diagram of a Reset Gate in a universal quantum gate provided in an embodiment of the present invention;
[0043] Figure 4a A specific quantum circuit diagram of a one-bit quantum full adder provided in an embodiment of the present invention;
[0044] Figure 4b A simplified diagram of a one-bit quantum full adder provided in an embodiment of the present invention;
[0045] Figure 5 A circuit diagram of a quantum multiplier provided for an embodiment of the present invention;
[0046] Figure 6 The improved NEQR quantum image representation model provided in this embodiment of the invention is used to prepare quantum circuit diagrams with corresponding grayscale values.
[0047] Figure 7a A schematic diagram of a 4×4 quantum image participating in a multiplication operation, provided as an embodiment of the present invention;
[0048] Figure 7b A schematic diagram of another quantum image of size 4×4 participating in the multiplication operation provided in an embodiment of the present invention;
[0049] Figure 7c This is a schematic diagram of the quantum image output after multiplying two 4×4 quantum images provided in an embodiment of the present invention.
[0050] Figure 8 The probability histogram of the product of two 4×4 quantum images provided in an embodiment of the present invention. Detailed Implementation
[0051] To make the objectives, technical solutions, and advantages of the present invention clearer, the present invention will be further described in detail below with reference to the embodiments and accompanying drawings. The illustrative embodiments and descriptions of the present invention are only used to explain the present invention and are not intended to limit the present invention.
[0052] It should be understood that the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of this invention, "a plurality of" means two or more, unless otherwise explicitly specified.
[0053] Example 1
[0054] It's important to note that a quantum computer has a hybrid structure, comprising two main parts: a classical computer responsible for performing classical calculations and control, and a quantum device responsible for running quantum programs to achieve quantum computing. A quantum program is a sequence of instructions written in a quantum language such as QRunes that can run on a quantum computer, supporting operations on quantum logic gates and ultimately enabling quantum computing. Specifically, a quantum program is a sequence of instructions that operates on quantum logic gates according to a specific timing order.
[0055] In practical applications, due to limitations in the development of quantum device hardware, quantum computing simulations are often required to verify quantum algorithms, quantum applications, and so on. Quantum computing simulation is the process of simulating the execution of a quantum program corresponding to a specific problem using a virtual architecture (i.e., a quantum virtual machine) built with the resources of a conventional computer. Typically, it is necessary to construct a quantum program corresponding to a specific problem. The quantum program referred to in this embodiment of the invention is a program written in a classical language that represents qubits and their evolution, wherein qubits, quantum logic gates, etc., related to quantum computing all have corresponding classical code representations.
[0056] Quantum circuits, also known as quantum logic circuits, are a common manifestation of quantum programming and are the most widely used general-purpose quantum computing model. They represent circuits that operate on qubits under an abstract concept. They consist of qubits, circuits (timelines), and various quantum logic gates. Finally, the results are often read out through quantum measurement operations.
[0057] Unlike traditional circuits that use metal wires to transmit voltage or current signals, in quantum circuits, the circuits can be seen as being connected by time. That is, the state of a quantum bit evolves naturally over time, following the instructions of the Hamiltonian operator until it encounters a logic gate and is operated on.
[0058] A quantum program corresponds to a single quantum circuit. The quantum program described in this invention refers to this single quantum circuit, where the total number of qubits in the single quantum circuit is the same as the total number of qubits in the quantum program. This can be understood as follows: a quantum program can consist of a quantum circuit, measurement operations on the qubits within the quantum circuit, registers for storing measurement results, and control flow nodes (jump instructions). A single quantum circuit can contain dozens, hundreds, or even thousands of quantum logic gate operations. The execution of a quantum program is the process of executing all the quantum logic gates in a specific timing order. It should be noted that the timing order refers to the chronological sequence in which individual quantum logic gates are executed.
[0059] It's important to note that in classical computing, the most basic unit is the bit, and the most fundamental control mode is the logic gate. Circuit control can be achieved through combinations of logic gates. Similarly, the way to process qubits is through quantum logic gates. Using quantum logic gates, quantum states can evolve. Quantum logic gates are the foundation of quantum circuits. Quantum logic gates include single-qubit quantum logic gates, such as Hadamard gates (H gates), Pauli-X gates, Pauli-Y gates, Pauli-Z gates, RX gates, RY gates, and RZ gates; and multi-qubit quantum logic gates, such as CNOT gates, CR gates, iSWAP gates, and Tofoli gates. Quantum logic gates are generally represented using unitary matrices, and unitary matrices are not only matrix forms but also operations and transformations.
[0060] Currently, quantum image multiplication algorithms have certain shortcomings in terms of multiplication methods, quantum adders, and quantum image preparation methods, resulting in low performance during operation. Therefore, improving the performance of quantum image multiplication algorithms is an urgent problem to be solved.
[0061] like Figure 1 As shown, this application provides a quantum image multiplication operation method, including:
[0062] Multiple quantum images sharing location information and in a superposition state were prepared based on the NEQR quantum image representation model;
[0063] Specifically, the method of preparing the NEQR quantum image representation model is improved to prepare quantum images. The two quantum images obtained share position information and are in a superposition state, which lays the foundation for the parallelism of subsequent multiplication operations between the two quantum images.
[0064] It is important to understand that in practical applications, preparing multiple images based on the NEQR quantum image representation model requires additional qubits, which degrades the algorithm's performance. Therefore, in practical applications, only the number of images needed should be prepared.
[0065] In one implementation, multiple quantum images sharing location information and in a superposition state are prepared based on the NEQR quantum image representation model, specifically including:
[0066] Multiple quantum images sharing position information and in a superposition state are prepared using the NEQR quantum image representation model prepared row by row. In the process of preparing the grayscale information of the quantum image, auxiliary qubits are used to transmit position information, so that the position information and grayscale information correspond one-to-one, and the auxiliary qubits are reused by the zeroing operation.
[0067] Specifically, in this embodiment, the improved NEQR quantum image representation model uses a row-by-row preparation method to prepare quantum images, which reduces the number of quantum gates used. During the preparation of image grayscale information, auxiliary qubits are used to transmit position information, so that the position information corresponds one-to-one with the grayscale information. The auxiliary qubits are reused by zeroing operations, so that the number of auxiliary qubits does not increase with the increase of image size during the entire quantum image preparation process, thereby improving and optimizing the quantum image preparation process.
[0068] Using the two quantum images below as examples, this paper introduces the preparation of two superimposed quantum circuits using the expression of the NEQR quantum image representation model. The same method can be applied to prepare images of other grayscale sizes.
[0069] The matrices of these two 4×4 images are represented as follows:
[0070]
[0071]
[0072] Take the preparation process of pixel 0101 in two superimposed quantum images as an example. Figure 6 The portion between the two dashed lines represents the quantum circuitry used to construct this pixel. In the NEQR expression, this pixel is represented as the binary string 1010010101, where the last four bits represent position information, the first three bits represent the grayscale information of the first quantum image at that position, and the fourth to sixth bits represent the grayscale information of the second quantum image at that position.
[0073] Figure 6 The portion between the two dashed lines, from top to bottom, consists of the first three qubits (|qr0>-|qr2>) representing the grayscale information 101 of the first quantum image, and the next three qubits (|qr3>-|qr5>) representing the grayscale information 001 of the second quantum image. Therefore, the output of the first six quantum circuits should be 101001.
[0074] |qr6>_|qr9> represents the corresponding position information, with half representing the position information in the x-direction and half in the y-direction. Specifically, |qr6> and |qr7> represent the position information in the x-direction, while |qr8> and |qr9> represent the position information in the y-direction.
[0075] |qr 10 >、|qr 11 >and|qr 12The system consists of three auxiliary qubits. Since the qubit storing position information becomes a superposition of all positions after passing through the H gate, and the position information cannot be changed during image preparation, it is necessary to transfer the position information to the auxiliary qubits to ensure a one-to-one correspondence between the position information and the grayscale information.
[0076] The following will introduce the process. Figure 6 Quantum circuitry is used to fabricate pixel 1010010101.
[0077] S21: Generate a superposition state of position information. By adding H gates to the qubits |qr6>, |qr7>, |qr8>, and |qr9> that represent position information, a superposition state of four position information is obtained.
[0078] S22: Since the superposition state representing position information cannot be changed, position information is transmitted to auxiliary qubits to prepare for a one-to-one correspondence between position information and grayscale information. For example... Figure 6 The position information |qr6>=0, |qr7>=1, |qr8>=0, and |qr9>=1 are passed to auxiliary qubits, which control the qubits |qr0>_|qr2> and |qr3>_|qr5> representing the grayscale information at position 0101 in the two images, so that |qr0>_|qr2> and |qr3>_|qr5> output 101 and 001 respectively. The specific implementation is as follows:
[0079] It's important to understand that, generally, the control bits of a quantum gate are represented by solid black circles when drawing a diagram, while... Figure 6 The control bits of the CNOT and Tooffoli gates are partially hollow circles, indicating that two NOT gates have been added to both ends of the original solid black circles. This allows the CNOT and Tooffoli gates to be used as control bits even when the value of the qubit is |0>.
[0080] Initially, all three auxiliary bits are |0>, such as Figure 6 As shown, the state |qr6>=0 is transferred to the auxiliary qubit |qr through a CNOT gate. 10 >Up; after passing through the first Toffoli gate, the states |qr6>=0 and |qr7>=1 are transmitted together to the auxiliary qubit |qr 12 >Above, at this time |qr 10 The zeroing operation |0> is applied to the circuit to restore it to its initial state; after passing through the second Toffoli gate, the states |qr6>=0, |qr7>=1, and |qr8>=0 are transmitted together to the auxiliary qubit |qr. 10>Up; Finally, use the third Tofoli gate to pass the states |qr6>=0, |qr7>=1, |qr8>=0, and |qr9>=0 together to the auxiliary qubit |qr 11 >On; and in |qr 10 The above applies a zeroing operation. Only |qr 11 When the value is 1, |qr6>=0, |qr7>=1, |qr8>=0 and |qr9>=0 are simultaneously true, thus realizing the preparation of the position information |0>, |1> in the x-direction and the position information |0>, |0> in the y-direction.
[0081] Next, the position information |0>, |1> in the x-direction and the position information |0>, |1> in the y-direction are prepared using the NEQR quantum image preparation method, which prepares the image row by row. The position information in the x-direction remains unchanged; only the position information in the y-direction needs to be changed. For example... Figure 6 The portion between the two dashed lines remains unchanged for qubits |qr6> and |qr7>. The first Tofoli gate is used to transfer the states |qr6>=0, |qr7>=1, and |qr8>=0 to qubit |qr6>. 10 The second Tofoli gate is used to transfer the states |qr6>=0, |qr7>=1, |qr8>=0, and |qr9>=1 to the qubit |qr. 11 >on, and in |qr 10 The zeroing operation is applied to prepare the position pixel values of x-direction position information |0>, |1> and y-direction position information |0>, |1>.
[0082] S23: Obtain the grayscale value corresponding to the position. (The rest of the text appears to be a series of characters and symbols, possibly related to a function or process.) 11 As control bits, the grayscale values of the image are prepared using CNOT gates, and then processed in the quantum bits |qr 11 >The above applies a zeroing operation.
[0083] This completes the preparation of the pixel value at position 0101. Because the quantum bit |qr 12 The x-direction position information is stored on the qubit |qr. When the preparation of a row of pixel values is completed, i.e., when the x-direction position information needs to be changed, the position information needs to be changed in the x-direction. 12 >The above applies a zeroing operation.
[0084] It is important to note that regardless of the number of qubits representing position information, the position information can always be transferred through these three auxiliary qubits by repeatedly transferring it to one of the auxiliary qubits using the aforementioned method. Therefore, the number of auxiliary qubits does not increase with the increase of image size.
[0085] Based on the quantum multiplier, any two quantum images from the multiple quantum images are multiplied to obtain a matrix of pixel values of the quantum images;
[0086] Specifically, in this embodiment, based on two parallel quantum images and the designed quantum multiplier, the multiplication operation of the two quantum images is performed to obtain a matrix representing the pixel values of the quantum images.
[0087] In one implementation, a matrix of pixel values of the quantum images is obtained by multiplying any two quantum images from a plurality of quantum images using a quantum multiplier, specifically including:
[0088] Step S31: Set the size information and gray value of the two quantum images, use the gray value at the same position information of the two quantum images as the multiplicand and multiplier, and use a quantum multiplier to perform multiplication operation, wherein the two quantum images are two parallel quantum images;
[0089] Step S32: The grayscale information and position information of each pixel in the quantum image are in a superposition state. After multiplying the grayscale value of each pixel, the auxiliary bits and the result storage bits are reused by setting them to zero.
[0090] Step S33: Traverse all pixels in the two quantum images and execute steps S31-S32 to multiply the two quantum images.
[0091] Specifically, in this embodiment, after preparing two quantum images, the gray values at the same location in both images are used as multiplicands and multipliers, and a multiplier is used to perform multiplication. The gray-level information and position information of the entire quantum image are in a superposition state, generated through the previous preparation process. When designing image multiplication, to reduce the complexity of the quantum image, as few qubits as possible should be used. Therefore, the auxiliary qubits used in preparing the two images are reused after the preparation process is completed by setting them to zero, and can then be used in the quantum multiplier circuit. Let |c> and |c> represent the carry information of the n-bit quantum full adder. -1 >, and the qubits |qr in the quantum image preparation process 10 >、|qr 11 Using the same qubit, reuse is achieved by setting it to zero after each use. After multiplying the grayscale of a specific pixel, the qubit used to store the result also needs to be set to zero for reuse. By using the same method to iterate through all pixels, the multiplication of two quantum images can be achieved.
[0092] Information about each pixel in the matrix of pixel values of the quantum image is extracted and converted into classical image information, wherein the information includes grayscale information and position information of the pixels in the quantum image.
[0093] Specifically, the information of each pixel in the matrix of pixel values of the quantum image is extracted, and the information is converted into classical image information, specifically as follows:
[0094] Using the open-source quantum computing toolkit QISKIT, the IBMQ simulation cloud platform, and the package and environment management functions provided by Anaconda, we simulated and implemented quantum image multiplication operations in Python.
[0095] It should be noted that the simulation was implemented using a classical computer and a programmable quantum computer provided by IBM. Based on the open-source quantum computer toolkit QISKIT provided by IBM Labs and the environment management provided by Anaconda, the quantum circuit was written in Python, and the calculation and quantum measurement were performed according to the written circuit. Finally, the corresponding simulation results were output.
[0096] Based on the basic information of the image, and referring to the aforementioned quantum circuit design method, quantum registers and classical registers are defined. Various qubit gates are then added to the quantum circuit. The quantum circuit is then visualized, and each qubit is measured. The quantum grayscale image is then collapsed and output. Experiments show that, to ensure complete quantum image information is obtained and to shorten the measurement time, the number of measurements is generally about four times the size of the quantum image.
[0097] One application of quantum image multiplication is feature extraction, for example, to extract... Figure 7a The pixel values of the middle four pixels can be obtained through... Figure 7a and Figure 7b This is achieved through multiplication. Figure 7c This is the result of multiplying images. The multiplicand is... Figure 7a Its grayscale information is shown in equation (1) above, and it is used as the multiplicand. Figure 7b Its grayscale information is shown in equation (2) above. Figure 8 The result is the probability histogram after multiplying two 4×4 quantum images. The result at position 0101 is 000101, the result at position 0110 is 000001, the result at position 1001 is 000010, the result at position 1010 is 000110, and the result at the remaining positions is 000000, which is consistent with the expected result.
[0098] In one implementation scheme, the operation steps of quantum multiplication are improved based on binary multiplication. The quantum multiplier is designed using Toffoli gates and quantum full adders to obtain a quantum multiplier.
[0099] In this embodiment, the operation steps of quantum multiplication are improved based on the existing binary multiplication principle. By using Toffoli gates and quantum full adders to design quantum multiplication based on binary multiplication, a new quantum multiplier is obtained, which can be used to implement the multiplication operation of multiple binary numbers.
[0100] In one implementation, the operation steps of quantum multiplication are improved based on binary multiplication. A quantum multiplier is designed using Toffoli gates and quantum full adders to improve the binary multiplication process. Specifically, this includes:
[0101] Obtain the multiplier and multiplicand data to be operated on, wherein the multiplier data has m qubits and the multiplicand data has n qubits;
[0102] The m-bit number of qubits is multiplied by the n-bit number of qubits using the Toffoli gate to obtain the first result in the m-th row;
[0103] The first result of m rows is added according to the corresponding result positions using a quantum full adder to obtain the second result; where multiplication and addition are implemented by the corresponding Toffoli gate and quantum full adder in the quantum circuit, respectively.
[0104] Specifically, the first result in row m represents the result after multiplication. In this embodiment, binary numbers are multiplied... Figure 2 Taking 111 × 111 as an example, both the multiplicand and multiplier are 111. Binary multiplication is implemented using Toffoli gates, such as... Figure 3d As shown, the target bit only flips its state when both control bits are simultaneously 1. Therefore, when the initial value of the target bit is 0, the Toffoli gate functions the same as a binary multiplication operation. For an n-bit binary multiplicand multiplied by an m-bit binary multiplier, as shown... Figure 2 As shown, multiplying the n-bit and m-bit binary numbers in the first layer yields n*m binary numbers in the second layer. Figure 2 If both n and m are 3 in the first layer, then 9 binary numbers are obtained in the second layer.
[0105] In one implementation, a quantum full adder is used to add the first result in m rows according to the corresponding result positions to obtain the second result, specifically:
[0106] A quantum full adder is used to add the binary numbers of the first m rows obtained through the Toffoli gate layer by layer. Then, the CNOT gate is used to store the output of the quantum full adder and the carry information into the corresponding qubits. Finally, a right-to-left shift operation is used to multiply the two binary numbers.
[0107] Specifically, the second result represents the result of the addition operation. In this embodiment, the specific process of designing a one-bit quantum full adder is provided as follows: after multiplying n-bit and m-bit binary numbers, the n*m results obtained need to be added layer by layer according to the multiplication principle. Figure 4a For a specific quantum circuit diagram of a quantum full adder, |a i >and |b i > represent the qubits of the input addend and augend, respectively, |S i > indicates |a i +b i > Output result bits, |c -1 >, |c>, and |ass> are three constant auxiliary qubits, with |ass> used to store control bit information, and |c>... -1 > and |c> are auxiliary bits representing carry information, and both |c> and |ass> are initially set to 0. After passing through a quantum adder, the value of |c> is assigned to |c>. -1 >, to prepare for the next addition operation. Figure 4a The quantum full adder in the example uses five control NOT gates, two Toffoli gates, and four zero-set gates, such as... Figure 3e As shown. Figure 4b This is a simplified diagram of a one-dimensional quantum full adder, to highlight the addend |a| involved in the addition operation. i >with addend|b i >and input carry information|c -1 >and the calculation result |S i Here, only the qubits involved in the addition operation are marked with black dots.
[0108] In one implementation, during the process of adding the binary numbers of the first m rows obtained through the Toffoli gate layer by layer using a quantum full adder: a zeroing operation is used to multiplex the qubits representing carry information and control bit information, wherein the zeroing operation means setting the state of the qubit to the |0> state.
[0109] Specifically, in this embodiment, during the improvement of the quantum full adder, a zeroing operation is used to reuse the qubits representing carry information and control bit information. Reuse can significantly reduce the number of qubits required for quantum multipliers and quantum image preparation, enabling the smooth implementation of algorithm simulation. The zeroing operation keeps the auxiliary qubits unchanged, significantly reducing the number of qubits used by the quantum adder.
[0110] In one implementation, a right-to-left shift operation is used to multiply the two binary numbers, specifically:
[0111] An m+n constant qubit, |res0>_|res(n+m-1)>, initialized to the |0> state, is reserved to store the multiplication result. Its initial value is m+n zeros, which are arranged from low to high bits from right to left. During the first addition operation, the addend is aligned with the least significant bit of this m+n bit, and the result is stored in this m+n bit. During the next addition operation, the addend is aligned with the second least significant bit of this m+n bit.
[0112] Specifically, this embodiment provides a detailed process for implementing a right-to-left shift operation, as follows: If the multiplicand has n qubits and the multiplier has m qubits, then the maximum number of qubits required for multiplication is m+n. The main idea of the shift operation for multiplication is as follows: First, reserve m+n constant qubits initialized to the |0> state (|res0>-|res(n+m-1)>) to store the multiplication result. These qubits have an initial value of m+n zeros, arranged from low to high bits from right to left. According to the steps of the binary multiplication operation described above, during the first addition operation, the addend is aligned with the least significant bit (rightmost bit) of these m+n bits, and the result is stored in these m+n bits. During the next addition operation, the addend is aligned with the second least significant bit of these m+n bits. This alignment can be achieved by selecting the appropriate qubits to participate in the operation within the quantum circuit. Each addition operation involves a corresponding shift operation.
[0113] Based on the above-mentioned improved quantum multiplier technical solutions, the quantum multiplication implementation process of the improved quantum multiplier is as follows: The specific circuit of the quantum multiplier is as follows: Figure 5 As shown, the multiplier requires n qubits to represent the n-bit binary multiplicand; m qubits to represent the m-bit binary multiplier, or conversely, the n-bit multiplicand has n qubits and the m-bit multiplier has m qubits; the result is stored in m+n qubits; four qubits are used as auxiliary bits, two of which are used to represent the carry information |c> and |c> of the n-bit quantum full adder. -1 The two bits are used to store the result bit information |ass> and |t>. A quantum adder is used to add the binary numbers obtained through the Toffoli gate layer by layer. Then, a CNOT gate is used to store the result and carry information output by the quantum full adder into the corresponding qubits. Combined with the method described above for implementing shift operations, the multiplication of two or more binary numbers is achieved.
[0114] like Figure 2 As shown, if both the multiplicand n and the multiplier m are 3, then there are a total of 6 result storage qubits |res0>-|res5>. Figure 2The curly braces in the equation represent a single quantum adder operation, where f, e, d, c, b, and a correspond to qubits |res0>-|res5> respectively. First, a binary multiplication operation is performed using a Tofoli gate to obtain... Figure 2 The binary number in layer ① is placed into the result bits |res3>_|res5> in right-to-left order, that is... Figure 2 The binary number at position a is placed in |res5>, the binary number at position b in |res4>, and the binary number at position c in |res3>. Then, a Toffoli gate is used for binary multiplication to obtain the binary number at position b in the second layer. This is temporarily stored in an auxiliary bit |t>. The designed quantum adder adds the auxiliary bit |res4> and |t>, and the result is stored in the quantum bit |res4>. The auxiliary bit |t> is reset to zero after use. The binary numbers at positions c and d in the second layer are added sequentially to the values of the quantum bits |res3> and |res2>. After the addition of the quantum bit at position d, the carry information of the quantum adder is used... Figure 3c The CNOT gate shown is stored in the qubit |res1> for subsequent addition. This process is repeated for the additions in layers ② and ③. Finally, the carry information of the quantum adder is stored in the qubit |res0>, and |res0> - |res5> is the result obtained by the multiplier.
[0115] In summary, this invention provides a novel quantum image multiplication method. This method optimizes existing multiplication methods, quantum adders, and quantum image preparation methods, reuses auxiliary qubits in quantum circuits, greatly improves the performance of quantum image representation algorithms, makes them easier to simulate on classical computers, and enables the processing of larger quantum images, thereby enhancing the capabilities of quantum image algorithms.
[0116] Example 2
[0117] This application provides a quantum image multiplication operation device based on embodiment one, comprising:
[0118] A quantum image preparation module is used to prepare multiple quantum images with shared positional information and in a superposition state based on the NEQR quantum image representation model;
[0119] The processing module is used to perform multiplication operations on any two quantum images from multiple quantum images based on a quantum multiplier to obtain a matrix of pixel values of the quantum images.
[0120] The information conversion module is used to extract information of each pixel in the pixel value matrix of the quantum image and convert the information into classical image information; wherein the operation steps of quantum multiplication are improved according to binary multiplication, and the quantum multiplication based on binary multiplication is designed using Toffoli gate and quantum full adder to obtain a quantum multiplier; the information includes grayscale information and position information of pixels in the quantum image.
[0121] Compared with existing technologies, the quantum image multiplication operation device of this embodiment 2 optimizes the existing multiplication method, quantum adder and quantum image preparation method, reuses the auxiliary qubits in the quantum circuit, greatly improves the performance of the quantum image expression algorithm, makes it easier to simulate under classical computer, and makes it possible to process larger quantum images, thus improving the capability of the quantum image algorithm.
[0122] Example 3
[0123] Embodiment 3 of this application provides an electronic device, including a memory and a processor. The memory stores a computer program, and the processor is configured to run the computer program to perform the method described in Embodiment 1.
[0124] Specifically, the aforementioned electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the aforementioned processor, and the input / output device is connected to the aforementioned processor by a specific method.
[0125] Specifically, in this embodiment, the processor can be configured to perform the following steps via a computer program:
[0126] Multiple quantum images sharing location information and in a superposition state were prepared based on the NEQR quantum image representation model;
[0127] Based on the quantum multiplier, any two quantum images from the multiple quantum images are multiplied to obtain a matrix of pixel values of the quantum images;
[0128] Information about each pixel in the matrix of pixel values of the quantum image is extracted and converted into classical image information. The quantum multiplication operation steps are improved based on binary multiplication. The quantum multiplication based on binary multiplication is designed using Toffoli gates and quantum full adders to obtain a quantum multiplier. The information includes the grayscale information and position information of the pixels in the quantum image.
[0129] The specific embodiments described above further illustrate the purpose, technical solution, and beneficial effects of the present invention. It should be understood that the above description is only a specific embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A quantum image multiplication operation method, characterized in that, include: Multiple quantum images sharing position information and in a superposition state are prepared based on the NEQR quantum image representation model. Specifically, the preparation of multiple quantum images sharing position information and in a superposition state is carried out using the NEQR quantum image representation model prepared row by row. In the process of preparing the grayscale information of the quantum image, auxiliary qubits are used to transmit position information, so that the position information and grayscale information correspond one-to-one, and the auxiliary qubits are reused by the zeroing operation. Based on a quantum multiplier, any two quantum images from multiple quantum images are multiplied to obtain a matrix of pixel values of the quantum images. Specifically, obtaining the matrix of pixel values of the quantum images includes: Step S31, setting the size information and grayscale values of the two quantum images, using the grayscale values at the same location in the two quantum images as the multiplicand and multiplier, and performing a multiplication operation using a quantum multiplier, wherein the two quantum images are two parallel quantum images; Step S32, the grayscale information and location information of each pixel in the quantum image are in a superposition state, and after multiplying the grayscale values of each pixel, the auxiliary bits and the result storage bits are reused by setting them to zero; Step S33, traversing all pixels in the two quantum images and executing steps S31-S32 to achieve the multiplication of the two quantum images. Information about each pixel in the matrix of pixel values of the quantum image is extracted and converted into classical image information. The quantum multiplication process is improved based on binary multiplication, and a quantum multiplier is designed using Toffoli gates and a quantum full adder. The information includes the grayscale information and position information of the pixels in the quantum image. Specifically, the design of a quantum multiplier based on binary multiplication is achieved using Tofoli gates and quantum full adders, resulting in a quantum multiplier. This includes: Obtain the multiplier and multiplicand data to be operated on, wherein the multiplier data has m qubits and the multiplicand data has n qubits; The m-bit number of qubits is multiplied by the n-bit number of qubits using the Toffoli gate to obtain the first result in the m-th row; The first result of m rows is added according to the corresponding result positions using a quantum full adder to obtain the second result; where multiplication and addition are implemented by the corresponding Toffoli gate and quantum full adder in the quantum circuit, respectively.
2. The method according to claim 1, characterized in that, The information of each pixel in the matrix of pixel values of the quantum image is extracted, and the information is converted into classical image information, specifically as follows: Using the open-source quantum computing toolkit QISKIT, the IBMQ simulation cloud platform, and the package and environment management functions provided by Anaconda, we simulated and implemented quantum image multiplication operations in Python.
3. The method according to claim 1, characterized in that, The second result is obtained by adding the first result in m rows according to their corresponding positions using a quantum full adder, as follows: A quantum full adder is used to add the binary numbers of the first m rows obtained through the Toffoli gate layer by layer. Then, the CNOT gate is used to store the output of the quantum full adder and the carry information into the corresponding qubits. Finally, a right-to-left shift operation is used to multiply the two binary numbers.
4. The method according to claim 3, characterized in that, In the process of adding the binary numbers of the first m rows obtained through the Toffoli gate layer by layer using a quantum full adder: a zeroing operation is used to multiplex the qubits representing carry information and control bit information, where the zeroing operation means setting the state of the qubit to zero. state.
5. The method according to claim 3, characterized in that, Then, a right-to-left shift operation is used to multiply the two binary numbers, specifically: Reserve m+n bits for initialization constant state of quantum bits - Used to store the result of multiplication, its initial value is m+n zeros, which are arranged from low bit to high bit from right to left. When performing the first addition operation, the addend is aligned with the least significant bit of this m+n bit, and the result is stored in this m+n bit. When performing the next addition operation, the addend is aligned with the second least significant bit of this m+n bit.
6. A quantum image multiplication operation device, characterized in that, include: A quantum image preparation module is used to prepare multiple quantum images with shared position information in a superposition state based on the NEQR quantum image representation model. Specifically, preparing multiple quantum images with shared position information in a superposition state involves using a row-wise NEQR quantum image representation model to prepare multiple quantum images with shared position information in a superposition state. In the process of preparing the grayscale information of the quantum image, auxiliary qubits are used to transmit position information, so that the position information and grayscale information correspond one-to-one, and the auxiliary qubits are reused using a zeroing operation. The processing module is used to perform multiplication operations on any two quantum images from multiple quantum images based on a quantum multiplier to obtain a matrix of pixel values of the quantum images. Specifically, obtaining the matrix of pixel values of the quantum images includes: Step S31, setting the size information and grayscale values of the two quantum images, using the grayscale values at the same position information of the two quantum images as the multiplicand and multiplier, and performing a multiplication operation using a quantum multiplier, wherein the two quantum images are two parallel quantum images; Step S32, the grayscale information and position information of each pixel in the quantum image are in a superposition state, and after multiplying the grayscale values of each pixel, the auxiliary bits and the result storage bits are reused by setting them to zero; Step S33, traversing all pixels in the two quantum images and executing steps S31-S32 to achieve the multiplication of the two quantum images. The information conversion module is used to extract information of each pixel in the pixel value matrix of the quantum image and convert the information into classical image information; wherein the operation steps of quantum multiplication are improved according to binary multiplication, and the quantum multiplication based on binary multiplication is designed using Toffoli gates and quantum full adders to obtain a quantum multiplier; the information includes the grayscale information and position information of the pixels in the quantum image; Specifically, the design of a quantum multiplier based on binary multiplication is achieved using Tofoli gates and quantum full adders, resulting in a quantum multiplier. This includes: Obtain the multiplier and multiplicand data to be operated on, wherein the multiplier data has m qubits and the multiplicand data has n qubits; The m-bit number of qubits is multiplied by the n-bit number of qubits using the Toffoli gate to obtain the first result in the m-th row; The first result of m rows is added according to the corresponding result positions using a quantum full adder to obtain the second result; where multiplication and addition are implemented by the corresponding Toffoli gate and quantum full adder in the quantum circuit, respectively.
7. An electronic device comprising a memory and a processor, characterized in that, The memory stores a computer program, and the processor is configured to run the computer program to perform the method described in any one of claims 1 to 5.
Citation Information
Patent Citations
Quantum image multiplication design method and simulation implementation method thereof
CN111832734A
Quantum image adaptive segmentation method based on NEQR expression
CN112258543A