A quantum color image median filtering optimization method and system
Optimizing quantum color image processing through the OCQR model and auxiliary bit multiplexing solves the problem of large number of bits and redundant components in quantum circuits, achieves efficient quantum color image median filtering, and improves processing performance and algorithm capabilities.
Patent Information
- Application Number
- CN202210725572.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-24
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2042-06-24
AI Technical Summary
The large number of bits and redundant quantum components in quantum circuits in existing quantum image processing reduce the performance of quantum image expression algorithms and make it difficult to achieve efficient median filtering operations.
The OCQR model is used to prepare classic color images. Through the multiplexing of auxiliary bits and the optimization of color images, the number of qubits in the quantum circuit is reduced, redundant components are reduced, and the quantum color image median filtering algorithm is implemented, using quantum comparators. , controlled switches and adders, etc. for median calculation and noise detection.
It greatly improves the performance of quantum color image processing, making it easier to simulate under classical computers, and supports the processing of larger-sized quantum images, improving the processing capabilities of quantum image algorithms.
Smart Images

Figure CN115115543B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of quantum image processing, and more specifically, to a quantum color image median filtering optimization method and system. Background Art
[0002] Image processing on quantum platforms is to transfer classical image processing to quantum image processing. In classical image processing, image filtering is a common preprocessing operation, usually implemented by associating the image with a filter mask. Median filtering of an image is an important preprocessing step in image processing. In computer vision, it is often used to remove noise from images.
[0003] In the process of using median filtering to process images in the prior art, image processing is usually achieved through convolution operations, but convolution operations on quantum images are difficult to achieve and bring difficulties to the image filtering process. The prior art prepares quantum color images of classical color images and their neighborhood pixels to simulate mask calculations in classical image processing and achieves convolution-like operations. However, during the processing, the number of quantum bits in the quantum circuit is large and there are redundant quantum elements, which reduces the performance of the quantum image expression algorithm. Summary of the invention
[0004] The present invention solves the problem of a large number of bits and redundant quantum elements in a quantum circuit in an existing quantum image processing process, which reduces the performance of a quantum image expression algorithm. The purpose is to provide a quantum color image median filtering optimization method and system. The present invention provides a quantum color image median filtering method expressed by a new quantum image storage model OCQR. By reusing auxiliary bits and optimizing the color image preparation process, the number of quantum bits in the quantum circuit in the quantum image processing process is reduced, and redundant quantum elements are reduced, so that an improved quantum color image median filtering algorithm can be implemented, the performance of quantum color image processing is greatly improved, the simulation is easier to implement under a classical computer, and it provides the possibility of processing quantum images of larger sizes, thereby improving the processing capability of the quantum image algorithm.
[0005] The above technical objectives of the present invention are achieved through the following technical solutions:
[0006] On the one hand, an embodiment of the present application provides a quantum color image median filtering optimization method, comprising:
[0007] Obtain eight neighborhood color images of the classical color image, and prepare the classical color image and the eight neighborhood color images based on the OCQR model to obtain nine quantum color images to be processed;
[0008] According to the quantum circuit of the median filter algorithm, the median of the quantum color image is calculated to obtain the median of the quantum color image;
[0009] Performing mean calculation on the intensity information of the quantum color image to obtain a threshold for filtering the median, replacing the median corresponding to pixels in the quantum color image that exceed the threshold, and retaining the median corresponding to pixels in the quantum color image that do not exceed the threshold;
[0010] The quantum color image expression after the replacement and / or retention processing is measured, the information of each component is obtained from the quantum image expression, and the information of each component is converted into classical image information.
[0011] Furthermore, eight neighborhood color images of the classical color image are obtained, and the classical color image and the eight neighborhood color images are prepared based on the OCQR model to obtain nine quantum color images to be processed, including:
[0012] Acquire information of a to-be-processed classic color image, wherein the information includes intensity information, size information, and color channel information of each color channel of the classic color image;
[0013] Performing cyclic shift processing on the classical color image to be processed, each cyclic shift can obtain a neighborhood color image, and performing eight cyclic shifts can obtain eight neighborhood color images;
[0014] Setting corresponding quantum bits according to information of the classical color image to be processed;
[0015] According to the set quantum bits, the to-be-processed classical color image and eight neighborhood color images share the same position information and color channel information to control the intensity information of each image, and obtain a quantum sequence of unique mapping of the image's pixel position information, color channel information, and grayscale information to obtain a quantum color image.
[0016] Furthermore, the corresponding quantum bits are set according to the information of the quantum color image, specifically:
[0017] Set the grayscale value range of the classic color image to be processed to [0,2 m ], the size of the classic color image to be processed is 2 n ×2 n ; Among them, m quantum bits represent the intensity information corresponding to each color image, 2 quantum bits represent the three color channels of each color image, and 2n quantum bits and 4 auxiliary quantum bits are set to indicate that the quantum color image and the eight neighboring color images share the same position information.
[0018] Furthermore, according to the quantum circuit of the median filter algorithm, the median calculation is performed on the quantum color image to obtain the median of the quantum color image, which specifically includes:
[0019] The quantum color image and eight neighborhood color images are combined into nine neighborhood regions by using a quantum comparator, and each row of pixels in the nine neighborhood regions is compared and sorted, wherein the number of bits of the quantum comparator is m bits;
[0020] Compare and sort each column of pixels in the nine neighborhood areas after the comparison and sorting processing of each row of pixels, to obtain a first sorting result, wherein the first sorting result includes a row sorting result and a column sorting result of the pixels;
[0021] The maximum value of the first row, the middle value of the second row, and the minimum value of the last three rows of the sorting result are compared and sorted to obtain a second sorting result, wherein the middle value of the second sorting result is the median value of the pixels in the nine neighborhood areas.
[0022] Furthermore, the quantum color image and the eight neighborhood color images are combined into nine neighborhood regions using a quantum comparator, and each row of pixels in the nine neighborhood regions is compared and sorted, specifically including:
[0023] Using a quantum comparator to compare three pixels in each row of the nine-neighborhood area, and output a comparison result, wherein the control bit of the quantum controlled switch is based on the result bit output by the quantum comparator, and the first pixel and the second pixel are compared, and the larger value is arranged at the position where the second pixel is located, and then the second pixel is compared with the third pixel to obtain a first result;
[0024] The quantum controlled switch arranges the maximum value of the three pixel values at the position of the third pixel according to the first result, and then compares the first pixel with the second pixel to obtain the second result;
[0025] The quantum controlled switch arranges the middle value of the three pixel values at the position where the second pixel is located, and arranges the minimum value of the three pixel values at the position where the first pixel is located according to the second result.
[0026] Further, the intensity information of the quantum color image is averaged to obtain a threshold for filtering the median, the median corresponding to pixels exceeding the threshold in the quantum color image is replaced, and the median corresponding to pixels not exceeding the threshold in the quantum color image is retained, specifically including:
[0027] Using an n-bit quantum adder, the intensity information of the color channels at the corresponding positions of the quantum color image and the eight neighboring color images are added to obtain the sum of the intensity information of each color channel, wherein the sum of the intensity information is the quantum string output by the n-bit quantum adder;
[0028] A quantum divider is used to calculate the mean of the sum of the intensity information, and the difference between the integer quotient and the pixel to be processed is obtained, and the difference is used as a threshold, wherein when the threshold is compared with the median of the quantum color image, when the threshold is greater than the median, the pixel is regarded as a noise point, and the median is replaced with the pixel to be processed, otherwise it remains unchanged.
[0029] Furthermore, the quantum color image is added to the intensity information of the color channels at corresponding positions of the eight neighboring color images using an n-bit equal-bit quantum adder to obtain the sum of the intensity information of each color channel, specifically including:
[0030] First, the intensity information of each color channel at the corresponding position of the quantum color image and the eight neighboring color images is added through the Toffoli gate, and the carry information of the added intensity value is stored in the auxiliary bit;
[0031] Secondly, the sum of the intensity information of each color channel after addition is added through the CNOT gate, and the carry information after addition is stored in the first auxiliary bit;
[0032] The intensity values of the color channels at any two positions and the carry information stored in the first auxiliary bit are stored in the second auxiliary bit through the Toffoli gate again;
[0033] Finally, the carry information of the second auxiliary bit is added to the intensity value through the CNOT gate and stored in the third auxiliary bit, and the quotient is output to form a one-bit quantum full adder; wherein, the quantum bit representing the carry information is set to two constant auxiliary bits, and is reused after the one-bit addition operation is completed through the zeroing gate, so that n one-bit quantum full adders are superimposed together to complete the design of the n-bit quantum full adder, the median is used as the input of the n-bit quantum full adder, and the added carry information is stored in the quantum bit.
[0034] Further, a quantum divider is used to calculate the mean of the sum of the intensity information, and the difference between the integer quotient obtained and the pixel to be processed is used as a threshold, specifically including:
[0035] Step S31, using the output quantum string representing the sum of intensity information as the dividend, using a quantum comparator to compare the quantum bit and the pixel, and the comparison result is used as the control bit of the quantum controlled switch, wherein the value of the control bit is: when the quantum bit is less than the pixel value, the control bit is 0, otherwise it is 1; using the comparison result as the highest bit of the control bit control quotient, when the control bit result is 1, the quotient is assigned 1, and when the control bit result is 0, the quotient is assigned 0;
[0036] Step S32, using the comparison result as a control bit, wherein the minuend is a pixel, the subtrahend is a quantum bit, the subtractor controls the subtraction operation to obtain a difference result of the subtraction operation, aligning the quantum bit representing the divisor with the difference, wherein the highest bit is used as the control bit to assign a value to the quotient, and the highest bit is used as the control bit of the subtractor;
[0037] Step S33, using the difference result of the subtraction operation as the start of a new cycle, aligning the quantum bit representing the divisor with the second highest bit of the difference;
[0038] Step S34, repeating steps S31-S33, completing the division operation and rounding to an integer to obtain the corresponding quotient;
[0039] Step S35, compare the quotient and the pixel to be processed, and obtain the value of the comparison result bit: when the quotient is smaller than the pixel to be processed, the control bit is 0; otherwise it is 1, and the result bit is used as the control bit for sum exchange, where the larger value is used as the minuend and the smaller value is used as the subtrahend, and a subtraction operation is performed to obtain the threshold value.
[0040] Further, the quantum color image expression after the replacement and / or retention process is measured, the information of each component is obtained from the quantum image expression, and the information of each component is converted into classical image information, specifically including:
[0041] By using the open source quantum computing toolkit QISKIT, the IBMQ simulation cloud platform, and the package management and environment management functions provided by Anaconda, the Python language is used to simulate and implement the quantum color image median filtering algorithm to obtain classical image information.
[0042] On the other hand, an embodiment of the present application provides a quantum color image median filtering optimization system, comprising:
[0043] An image preparation module is used to obtain eight neighborhood color images of a classical color image, and to prepare the classical color image and the eight neighborhood color images based on the OCQR model to obtain nine quantum color images to be processed;
[0044] A median calculation module is used to perform median calculation on the quantum color image according to the quantum circuit of the median filter algorithm to obtain the median of the quantum color image;
[0045] The noise detection module is used to perform mean calculation on the intensity information of the quantum color image, obtain a threshold for filtering the median, replace the median corresponding to the pixels in the quantum color image that exceed the threshold, and retain the median corresponding to the pixels in the quantum color image that do not exceed the threshold.
[0046] The image information conversion module is used to measure the quantum color image expression after the replacement and / or retention processing, obtain the information of each component from the quantum image expression, and convert the information of each component into classical image information.
[0047] Compared with the prior art, the present invention has the following beneficial effects:
[0048] 1. The present invention reduces the number of quantum bits in the quantum circuit during quantum image processing and reduces redundant quantum elements by multiplexing auxiliary bits and optimizing the preparation process of color images, so that an improved quantum color image median filtering algorithm can be implemented, which greatly improves the performance of quantum color image processing, makes it easier to simulate on a classical computer, and provides the possibility of processing larger quantum images, thereby improving the processing capability of the quantum image algorithm.
[0049] 2. The present invention adopts a quantum gate circuit with lower complexity to design the overall quantum circuit, so that the complexity of the overall circuit is greatly reduced.
[0050] 3. The present invention obtains the setting of the threshold value through the mean value in the mask, so that non-noise points will not be filtered, thereby improving the performance of quantum color image processing.
[0051] 4. The present invention implements the quantum color image median filtering algorithm on a quantum simulator and verifies the overall quantum circuit. BRIEF DESCRIPTION OF THE DRAWINGS
[0052] The drawings described herein are used to provide a further understanding of the embodiments of the present invention, constitute a part of this application, and do not constitute a limitation of the embodiments of the present invention. In the drawings:
[0053] Figure 1 A schematic diagram of a flow chart of a quantum color image median filtering optimization method provided by an embodiment of the present invention;
[0054] Figure 2a A classic schematic diagram of a classic color image to be processed provided by an embodiment of the present invention;
[0055] Figure 2b A classic schematic diagram of eight neighborhood images provided by an embodiment of the present invention;
[0056] Figure 3 This is a diagram showing the output result after the image preparation quantum circuit provided by an embodiment of the present invention;
[0057] Figure 4 A pixel quantum circuit diagram of the same color channel at the same position of the image to be processed and its eight-neighborhood image prepared based on the OCQR expression provided in an embodiment of the present invention;
[0058] Figure 5 A specific circuit diagram of a three-bit quantum comparator provided by an embodiment of the present invention;
[0059] Figure 6 A specific circuit diagram of a quantum controlled switch provided by an embodiment of the present invention;
[0060] Figure 7a A specific circuit diagram for comparing and exchanging three pixel values provided in an embodiment of the present invention;
[0061] Figure 7b A quantum circuit diagram for finding a median in a 3×3 filter template provided by an embodiment of the present invention;
[0062] Figure 8a A schematic diagram of the structure of a quantum full adder provided in an embodiment of the present invention;
[0063] Figure 8b A schematic diagram of fully adding the intensity values of the corresponding pixel positions and color channels of nine quantum images provided in an embodiment of the present invention;
[0064] Fig. 9 A schematic diagram of the structure of a quantum full subtractor provided in an embodiment of the present invention;
[0065] Fig.10a A diagram of the operation steps of quantum division of six bits by four bits provided in an embodiment of the present invention;
[0066] Fig.10b A simplified diagram of the specific construction circuit of a six-bit by four-bit quantum divider provided in an embodiment of the present invention;
[0067] Fig.11 A schematic diagram of a circuit of a quantum noise detection module provided in an embodiment of the present invention;
[0068] Fig.12 The overall circuit diagram of the improved quantum color image provided by the embodiment of the present invention;
[0069] Fig.13 This is a diagram showing the output result of the improved quantum color image algorithm circuit provided by an embodiment of the present invention;
[0070] Fig.14a A probability histogram after improved quantum color image median filtering measurement provided by an embodiment of the present invention;
[0071] Fig.14b A classic schematic diagram of a color image having completed improved median filtering provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0072] In order to make the objectives, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with embodiments and drawings. The exemplary embodiments of the present invention and their description are only used to explain the present invention and are not intended to limit the present invention.
[0073] It should be understood that the terms "first" and "second" are used for descriptive purposes only and should not be understood to indicate or imply relative importance or implicitly indicate the number of technical features indicated. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features. In the description of the present invention, the meaning of "plurality" is two or more, unless otherwise clearly and specifically defined.
[0074] Embodiment 1:
[0075] like Figure 1 As shown, the embodiment of the present application provides a quantum color image median filtering optimization method, comprising the following steps:
[0076] Step S1, obtaining eight neighborhood color images of a classical color image, and preparing the classical color image and the eight neighborhood color images based on the OCQR model to obtain nine quantum color images to be processed;
[0077] In this embodiment, the classic color image may have different image formats and sources in different embodiments, such as jpg, png, tiff images, etc. Figure 2a The figure shows the RGB schematic diagram of a classical color image. Based on the quantum image storage model OCQR expression, the classical color image is prepared to obtain a quantum color image.
[0078] In one embodiment, eight neighborhood color images of a classical color image are obtained, and the classical color image and the eight neighborhood color images are prepared based on the OCQR model to obtain nine quantum color images to be processed, including:
[0079] Acquire information of a to-be-processed classic color image, wherein the information includes intensity information, size information, and color channel information of each color channel of the classic color image;
[0080] Performing cyclic shift processing on the classical color image to be processed, each cyclic shift can obtain a neighborhood color image, and performing eight cyclic shifts can obtain eight neighborhood color images;
[0081] Setting corresponding quantum bits according to information of the classical color image to be processed;
[0082] According to the set quantum bits, the to-be-processed classical color image and eight neighborhood color images share the same position information and color channel information to control the intensity information of each image, and obtain a quantum sequence of unique mapping of the image's pixel position information, color channel information, and grayscale information to obtain a quantum color image.
[0083] Specifically, in this embodiment, the information of the classic color image to be processed is obtained, and the grayscale information of the eight neighborhood color images is related to the color image to be median filtered. By circularly shifting the original image, eight domain color images are obtained, as follows: First, the classic color image is circularly shifted upward to obtain Figure 2b 2(c) of . Then, by cyclic shifting to the right, we get Figure 2b 2(d) of . Then perform a circular shift downward to obtain Figure 2b 2(f) part of . Then perform a circular shift downward to obtain Figure 2b 2(i) part of . Then perform a circular shift to the left to obtain Figure 2b 2(h) part of . Then circularly shift to the left, we get Figure 2b 2(g) part of . Then, by performing a circular shift upward, we get Figure 2b 2(e) part of the above. By circularly shifting upward, we get Figure 2b Section 2(b) of the
[0084] In one embodiment, the corresponding quantum bits are set according to the information of the quantum color image, specifically:
[0085] Set the grayscale value range of the classic color image to be processed to [0,2 m ], the size of the classic color image to be processed is 2 n ×2 n ; Among them, m quantum bits represent the intensity information corresponding to each color image, 2 quantum bits represent the three color channels of each color image, and 2n quantum bits and 4 auxiliary quantum bits are set to indicate that the quantum color image and the eight neighboring color images share the same position information.
[0086] Specifically, the corresponding quantum bits are set according to the information of the image to be processed and its eight neighboring color images. The grayscale information of the color image to be processed and the eight neighboring images has a total of 9×m quantum bits, 2 quantum bits are used as color channel information, 2n quantum bits are shared as position information, and 4 quantum bits are auxiliary bits. For example, the above-mentioned image to be processed is a 4×4 color image with 8 gray levels, that is, the grayscale information requires 27 quantum bits, the color channel information requires 2 quantum bits, the position information requires 4 quantum bits, and 4 quantum bits are required as auxiliary bits.
[0087] Prepare the position information of the image. It is known that the initial state of the position quantum bit is |0>, and an H-gate transformation is performed on it to prepare the position information of the image. For the color image to be processed in this embodiment, the position information and channel information, a total of 6 quantum bits, are transformed by an H-gate to obtain a superposition state with 16×4 components, which represent three different color channels, where 00 represents the R channel, 01 represents the G channel, 10 represents the B channel, and 11 is a redundant channel.
[0088] When the Qiskit quantum simulation system runs a quantum circuit, the output quantum sequence from left to right corresponds to the quantum circuit from bottom to top. According to the information represented by the quantum bits from bottom to top in the quantum circuit, it can be known that the first 27 bits of each component in each of the above 16 components represent the pixel value of the nine neighborhoods, the next two bits represent the color channel information, the next four bits are the position information, and the last two bits are auxiliary bits. The quantum sequences listed later are all presented in this order. That is, only the required position information and color channel information are obtained through the above H-gate transformation, while the grayscale information is still 0. Figure 3 Taking the second data 00100010110010101001001011111101111 as an example to illustrate the prepared image, it is inverted to 11110111111010010010101001101000100. At this time, the output of the quantum circuit from top to bottom corresponding to the image preparation is the first 27 bits 11110111111010010010101010011 is the grayscale information in the 3×3 filter template, the next 2 bits 01 are the color channel information, the next 4 bits 0001 are the position information bits, and the last 2 bits 00 are auxiliary bits. The auxiliary quantum bits are prepared to realize the unique mapping process of position information to grayscale information. The 64 quantum sequences in the quantum image system exist simultaneously when they are not collapsed.
[0089] The fourth step is to prepare the grayscale information of the image to be processed and its eight-neighborhood images. The pixel information of the nine color images is traversed, and quantum circuits are prepared based on the optimized images to achieve the unique mapping of pixel position information and grayscale information. The pixel information in the image (including grayscale information, color channel information and position information) is scanned in sequence, and the obtained pixel information is converted into the required quantum sequence to achieve the unique mapping process of grayscale information and position information.
[0090] Specifically, in this embodiment, the process of uniquely mapping pixel position information to grayscale information is as follows:
[0091] Step 1, the initial states of the position quantum bit and the color channel quantum bit are known to be |0>, and an H-gate transformation is performed on them to prepare the superposition state of the position information and the color channel of the image;
[0092] Step 2: The Y coordinate information of the first row of the image is transmitted to the auxiliary quantum bit |a3> through the quantum gate;
[0093] Step 3: Use the Toffoli gate that connects |a3> and the X coordinate information to realize the position encoding of the first pixel and transmit its information to the auxiliary qubit |a2>.
[0094] In step 4, the position information of |a2> and the color channel information “R” are encoded together and transmitted to the auxiliary qubit |a1>.
[0095] In step 5, a CNOT gate is added to |a1> and the intensity information |C>, so that the position information, color channel information and intensity information can correspond one to one, thereby sharing the position information and color channel information.
[0096] In step 6, when the intensity information of the “R” channel of the pixel is ready, the auxiliary qubits |a1> and a2> are set to zero using a reset operation, and steps 4 and 5 are repeated to encode the position information |a2> and the color channel information “G” and “B”, respectively, and prepare the corresponding intensity information, thereby sharing the position information.
[0097] Step 7, when a pixel is ready, |a2> is set to zero, and steps 3 to 5 are repeated to operate the first row of other pixel values in order to share the Y position information.
[0098] Step 8, when the first row of pixels is ready, |a3> is set to zero, and then steps 1 to 7 are repeated to start preparing the next row of pixels.
[0099] In this embodiment, a quantum circuit of each pixel in the nine neighborhood images of the image to be processed is given, such as Figure 4 Shown is a quantum circuit diagram with the preparation positions of Y=“00”, X=“00” and CH=“00”, and the grayscale value and corresponding quantum bit information of 000011011000001010011011011.
[0100] In this embodiment, no matter how many quantum bits represent the position information and color channel information, the position information can always be transmitted through these two auxiliary quantum bits, and transmitted to one of the auxiliary quantum bits using the above multiplexing method. Therefore, the number of auxiliary quantum bits in this embodiment does not increase with the increase of image size, and the complexity of the quantum circuit is greatly reduced.
[0101] Step S2, performing median calculation on the quantum color image according to the quantum circuit of the median filter algorithm to obtain the median of the quantum color image;
[0102] Specifically, in this embodiment, a quantum comparator and a quantum controlled-swap gate are used to complete the median filtering algorithm for quantum color images, and the result is stored in |C′ Y,X >.
[0103] In one implementation, according to the quantum circuit of the median filtering algorithm, the median value of the quantum color image is calculated to obtain the median value of the quantum color image, which specifically includes:
[0104] Using a quantum comparator to form a nine-neighborhood region with the quantum color image and eight neighboring color images, and comparing and sorting each row of pixels in the nine-neighborhood region, where the number of bits of the quantum comparator is m bits;
[0105] Comparing and sorting each column of pixels in the nine-neighborhood region after the comparison and sorting process of each row of pixels to obtain a first sorting result, where the first sorting result includes the row sorting result and the column sorting result of the pixels;
[0106] Comparing and sorting the maximum value in the first row, the middle value in the second row, and the minimum value in the third row of the sorting result to obtain a second sorting result, where the middle value of the second sorting result is the median value of the pixels in the nine-neighborhood region.
[0107] Specifically, the implementation principle of the quantum comparator is as follows: As Figure 5 shown, given a composite system |a>|b> composed of two n-bit quantum states, a quantum comparator (Quantum Bit String Comparator, QBSC) is used to implement the operation of the quantum bit string |a> = |a n-1 a n-2 ...a0> and the comparison string |b> = |b n-1 b n-2 ...b>0. QBSC is the unitary evolution shown below: U CMP |a>|b>|0>|0> = |a>|b>|0>|c>, where is the total number of quantum bits contained in the composite system. The implementation of the comparator also requires another 2 auxiliary quantum bits initialized to 0; does not carry any useful information, and the last quantum bit state carries the result information obtained by the comparison. and are the two quantum bit strings to be compared respectively. For example, when a < b, then c = 1 and; when a ≥ b, then c = 0. The increase in the number of bits of the quantum bit strings participating in the comparison in the implementation of the comparator will not cause an increase in the number of bits of the auxiliary quantum bits.
[0108] In one implementation scheme, using a quantum comparator to form a nine-neighborhood region with the quantum color image and eight neighboring color images, and comparing and sorting each row of pixels in the nine-neighborhood region, specifically including:
[0109] Using a quantum comparator to compare three pixels in each row of the nine-neighborhood area, and output a comparison result, wherein the control bit of the quantum controlled switch is based on the result bit output by the quantum comparator, and the first pixel and the second pixel are compared, and the larger value is arranged at the position where the second pixel is located, and then the second pixel is compared with the third pixel to obtain a first result;
[0110] The quantum controlled switch arranges the maximum value of the three pixel values at the position of the third pixel according to the first result, and then compares the first pixel with the second pixel to obtain the second result;
[0111] The quantum controlled switch arranges the middle value of the three pixel values at the position where the second pixel is located, and arranges the minimum value of the three pixel values at the position where the first pixel is located according to the second result.
[0112] Specifically, the principle of the quantum controlled switch is as follows:
[0113] Given a composite system consisting of two n-bit quantum states |a>|b>, a quantum controlled switch is used to implement the operation of quantum bit strings and bit strings when the input result is 1, such as Figure 6 As shown, the unitary evolution of its representation is: U swap |a>|b>=|b>|a>.
[0114] Quantum color image median filtering algorithm, the principle of this algorithm is as follows:
[0115] Let the original image be f (x,y) , g (x,y) For the output image, the algorithm can be described as: using a 3×3 filter window to perform median replacement on each pixel value in the original image. It can be seen that in the process of median replacement, a median calculation module composed of a comparison exchange module is required.
[0116] Using the quantum comparator and quantum controlled switch mentioned above, the three horizontal values in the 3×3 filter window are compared in pairs, and the larger value is placed on the right, so that the rightmost value is the maximum value of each row, as shown in Figure 7(b). Then the values sorted by the horizontal comparison are compared vertically, and the larger value is placed on the bottom, so that the value at the bottom of the four lines is the maximum value of each column. Then the maximum value of the first row, the middle value of the second row, and the minimum value of the third row are compared in pairs, and the middle value obtained is the middle value in the 3×3 filter window, as shown in Fig.12 The first half shows the unitary evolution of:
[0117] U sort |a>|b>|c>|e>|f>|g>|h>|i>|j>=|a′>|b′>|c′>|e′>|med>|g′>|h′>|i′>|j′>
[0118] The intensities of the corresponding positions and color channels of the nine color images in step S2 are accumulated and then divided by 9 to obtain the mean of the image. Then the mean and the original value |C Y,X > is used as a threshold value. When the threshold reference is compared with a specific value, if it is greater than this specific value, it is regarded as a noise point, and the median value obtained in step S2 is replaced with the pixel value to be processed, otherwise it remains unchanged.
[0119] In this embodiment, a quantum adder, a quantum controlled switch, a quantum divider and a quantum comparator are used to complete the threshold setting module.
[0120] Step S3, performing mean calculation on the intensity information of the quantum color image to obtain a threshold for filtering the median, replacing the median corresponding to the pixels in the quantum color image that exceed the threshold, and retaining the median corresponding to the pixels in the quantum color image that do not exceed the threshold.
[0121] Specifically, this embodiment accumulates the intensities of the color channels at corresponding positions of the nine color images processed by the median calculation in step S2, and then divides by 9 to obtain the mean of the image. Y,X > is used as the threshold. When the threshold is compared with a specific value, if it is greater than this specific value, the pixel point is regarded as a noise point, and the median value obtained by S2 is replaced with the value to be processed, otherwise it remains unchanged.
[0122] In one embodiment, the intensity information of the quantum color image is averaged to obtain a threshold for filtering the median, the median corresponding to pixels exceeding the threshold in the quantum color image is replaced, and the median corresponding to pixels not exceeding the threshold in the quantum color image is retained, specifically including:
[0123] Using an n-bit quantum adder, the intensity information of the color channels at the corresponding positions of the quantum color image and the eight neighboring color images are added to obtain the sum of the intensity information of each color channel, wherein the sum of the intensity information is the quantum string output by the n-bit quantum adder;
[0124] A quantum divider is used to calculate the mean of the sum of the intensity information, and the difference between the integer quotient and the pixel to be processed is obtained, and the difference is used as a threshold, wherein when the threshold is compared with the median of the quantum color image, when the threshold is greater than the median, the pixel is regarded as a noise point, and the median is replaced with the pixel to be processed, otherwise it remains unchanged.
[0125] Specifically, in this embodiment, the working principle of the n-bit quantum adder is as follows: Let |a> = |a n a n-1 …a2a1> and |b>=|b n bn-1 …b2b1> are two n-bit binary numbers, and the input quantum state is the two binary numbers to be processed and the 2-bit auxiliary quantum bits with the initial state of 0, that is, the input quantum state is The auxiliary quantum bit and the quantum bit representing |b> are used together to store the sum of two numbers. After the operation of the quantum full adder, the output quantum state is Figure 8a The specific construction circuit diagram of a one-bit quantum full adder is shown. If the quantum full adder operation is represented by the symbol QADD, the process of adding two numbers can be expressed as:
[0126]
[0127] In this embodiment, the quantum adder designed above is applied to the sequential addition of the corresponding positions and color channel intensity values of the nine images. Specifically, eight additions need to be completed, that is, eight adders are required, such as Figure 8b shown.
[0128] The working principle of the quantum subtractor is as follows: Let |a>=|a n a n-1 …a2a1> and |b>=|b n b n-1 …b2b1> are two n-bit binary numbers, and the input quantum state is the two binary numbers to be processed and the 2-bit auxiliary quantum bits with the initial state of 0, that is, the input quantum state is The quantum bit representing |a> is used to store the difference between two numbers. After the operation of the quantum subtractor, the output quantum state is Fig.10a The specific construction circuit diagram of a one-bit quantum full subtractor is shown. Figure 8b This is a simplified diagram of a one-bit quantum full subtractor. Assuming the quantum full adder operation is represented by the symbol QSUB, the process of adding two numbers can be expressed as:
[0129]
[0130] For the quantum divider, an example is given to explain the implementation of the divider loop. For example, the binary number "101011" is divided by the binary number "1001". In the first step, we align the highest bit of the divisor with the highest bit of the dividend, such as the divisor "1001" and the highest bit "1010" of the dividend "101011" in the example. In the second step, use the comparator to compare "1001" with "1010", and the comparison result is used as the control bit a. The value of the control bit a is: when 1010>1001, the control bit is 1. In the third step, a is used as a control bit to control the highest bit of the quotient S. When the result of the control bit is 1, the quotient is assigned a value of 1. In the fourth step, a is used as a control bit to control the subtraction operation under the action of the subtractor. In the fifth step, the result of the subtraction operation is "0001", the divisor and the second highest bit of "0001", the highest bit "0" of "0001" is used as the control bit to assign the second highest bit of the quotient, which is also the control bit of the subtraction. Step 6: The result of the subtraction operation in step 5 is 0001. 0001 is used as the start of a new cycle. The divisor "1001" is aligned with the second highest bit "0011" in "000111". Repeat the above steps to complete the division operation. It should be noted that the first time the quotient is assigned a value, it is assigned to the second highest bit of the quotient. The following quotients are assigned values in sequence. Fig.10a These are the steps for quantum division of six digits by four digits.
[0131] It is composed of a module for adding the intensity values of the pixel positions and color channels of the nine quantum images of 8b, the divider, subtractor, comparator and controlled switch mentioned above. Fig.11 The noise detection module, that is, the replacement or retention processing of step S3, is the process of noise detection, which can be described as: using a 3×3 filter window to calculate the mean value of each pixel value in the original image, and taking the difference between the mean value and the original value as the threshold of noise detection. (When the intensity value range is [0,255], this value is 32), it is regarded as a noise point, and the pixel point of the original image is replaced with the median point obtained above, otherwise it remains unchanged. Fig.12 The second half is shown.
[0132] In one embodiment, an n-bit equal-bit quantum adder is used to add the intensity information of the color channels at corresponding positions of the quantum color image and eight neighboring color images to obtain the sum of the intensity information of each color channel, specifically including:
[0133] First, the intensity information of each color channel at the corresponding position of the quantum color image and the eight neighboring color images is added through the Toffoli gate, and the carry information of the added intensity value is stored in the auxiliary bit;
[0134] Secondly, the sum of the intensity information of each color channel after addition is added through the CNOT gate, and the carry information after addition is stored in the first auxiliary bit;
[0135] The intensity values of the color channels at any two positions and the carry information stored in the first auxiliary bit are stored in the second auxiliary bit through the Toffoli gate again;
[0136] Finally, the carry information of the second auxiliary bit is added to the intensity value through the CNOT gate and stored in the third auxiliary bit, and the quotient is output to form a one-bit quantum full adder; wherein, the quantum bit representing the carry information is set to two constant auxiliary bits, and is reused after the one-bit addition operation is completed through the zeroing gate, so that n one-bit quantum full adders are superimposed together to complete the design of the n-bit quantum full adder, the median is used as the input of the n-bit quantum full adder, and the added carry information is stored in the quantum bit.
[0137] In one embodiment, a quantum divider is used to calculate the mean of the sum of the intensity information, and the difference between the integer quotient obtained and the pixel to be processed is used as a threshold, specifically including:
[0138] Step S31, using the output quantum string representing the sum of intensity information as the dividend, using a quantum comparator to compare the quantum bit and the pixel, and the comparison result is used as the control bit of the quantum controlled switch, wherein the value of the control bit is: when the quantum bit is less than the pixel value, the control bit is 0, otherwise it is 1; using the comparison result as the highest bit of the control bit control quotient, when the control bit result is 1, the quotient is assigned 1, and when the control bit result is 0, the quotient is assigned 0;
[0139] Step S32, using the comparison result as a control bit, wherein the minuend is a pixel, the subtrahend is a quantum bit, the subtractor controls the subtraction operation to obtain a difference result of the subtraction operation, aligning the quantum bit representing the divisor with the difference, wherein the highest bit is used as the control bit to assign a value to the quotient, and the highest bit is used as the control bit of the subtractor;
[0140] Step S33, using the difference result of the subtraction operation as the start of a new cycle, aligning the quantum bit representing the divisor with the second highest bit of the difference;
[0141] Step S34, repeating steps S31-S33, completing the division operation and rounding to an integer to obtain the corresponding quotient;
[0142] Step S35, compare the quotient and the pixel to be processed, and obtain the value of the comparison result bit: when the quotient is smaller than the pixel to be processed, the control bit is 0; otherwise it is 1, and the result bit is used as the control bit for sum exchange, where the larger value is used as the minuend and the smaller value is used as the subtrahend, and a subtraction operation is performed to obtain the threshold value.
[0143] Specifically, let the original image be f (x,y) , g (x,y) For the output image, the algorithm can be described as: using a 3×3 filter window to calculate the mean of each pixel value in the original image and perform noise detection.
[0144] Step S4, measuring the quantum color image expression after the replacement and / or retention processing, obtaining the information of each component from the quantum image expression, and converting the information of each component into classical image information.
[0145] In this embodiment, the package management and environment management functions provided by the open source quantum computing toolkit QISKIT, the IBMQ simulation cloud platform, and Anaconda are used to measure the quantum image expression after processing in step S3 to obtain the probability information of each state in the quantum image. The quantum image is converted into a classical image for display through the measurement operation, and the quantum color image median filter algorithm is simulated and implemented in Python language to obtain the classical image information.
[0146] The probability amplitude information of each state in the quantum image is obtained through measurement operations. After the first two steps, the probability amplitude information of each state can only be obtained after the quantum image system is measured. Fig.13 is the probability histogram of quantum measurement after median filtering, Fig.14a As a result of this quantum circuit diagram, Fig.14b This is a schematic diagram of the image after filtering out noise points. From the experimental results, we can see that the matrix representation of the processed image is for:
[0147]
[0148]
[0149]
[0150] Table 1 shows the image g with a size of 4×4 and a grayscale value range of [0,7]. 4×4 The simulation results of the quantum color image median filtering include the running compilation time, the number of measurements, and the number of basic quantum logic gates, which can provide an evaluation criterion for this quantum image processing operation.
[0151] Table 1
[0152] Quantum image manipulation Image size Time(s) Number of measurements Quantum color image processing 4×4 195.33 1024
[0153] From the above experimental process and its corresponding experimental data, it can be seen that the quantum color image median filtering algorithm has been implemented in quantum images with an image size of 4×4 and a grayscale value range of [0,7].
[0154] In summary, the optimization method of the present invention realizes the improved quantum color image median filtering algorithm by optimizing the multiplexing of auxiliary bits and the preparation method of color images, and greatly improves the performance of quantum color image processing, laying a foundation for subsequent quantum image processing.
[0155] Embodiment 2
[0156] Embodiment 2 of the present application provides a quantum color image median filtering optimization system based on embodiment 1, including:
[0157] An image preparation module is used to obtain eight neighborhood color images of a classical color image, and to prepare the classical color image and the eight neighborhood color images based on the OCQR model to obtain nine quantum color images to be processed;
[0158] A median calculation module is used to perform median calculation on the quantum color image according to the quantum circuit of the median filter algorithm to obtain the median of the quantum color image;
[0159] The noise detection module is used to perform mean calculation on the intensity information of the quantum color image, obtain a threshold for filtering the median, replace the median corresponding to the pixels in the quantum color image that exceed the threshold, and retain the median corresponding to the pixels in the quantum color image that do not exceed the threshold.
[0160] The image information conversion module is used to measure the quantum color image expression after the replacement and / or retention processing, obtain the information of each component from the quantum image expression, and convert the information of each component into classical image information.
[0161] The optimization system provided in Example 2 of the present application realizes an improved quantum color image median filtering algorithm by optimizing the multiplexing of auxiliary bits and the preparation method of color images, and greatly improves the performance of quantum color image processing, laying a foundation for subsequent quantum image processing.
[0162] The specific implementation methods described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific implementation method 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 in the scope of protection of the present invention.
Claims
1. A quantum color image median filtering optimization method, characterized in that: include: Obtain eight neighborhood color images of the classical color image, and prepare the classical color image and the eight neighborhood color images based on the OCQR model to obtain nine quantum color images to be processed; According to the quantum circuit of the median filter algorithm, the median of the quantum color image is calculated to obtain the median of the quantum color image; Performing mean calculation on the intensity information of the quantum color image to obtain a threshold for filtering the median, replacing the median corresponding to pixels in the quantum color image that exceed the threshold, and retaining the median corresponding to pixels in the quantum color image that do not exceed the threshold, specifically comprising: using an n-bit quantum adder to add the intensity information of the color channels at corresponding positions of the quantum color image and eight neighboring color images to obtain the sum of the intensity information of each color channel, wherein the sum of the intensity information is a quantum string output by the n-bit quantum adder; performing mean calculation on the sum of the intensity information by a quantum divider to obtain the difference between the integer quotient obtained and the pixel to be processed, and using the difference as a threshold, wherein when the threshold is compared with the median of the quantum color image, when the threshold is greater than the median, the pixel is regarded as a noise point, and the median is replaced with the pixel to be processed, otherwise it remains unchanged; The quantum color image is added to the intensity information of the color channels at the corresponding positions of the eight neighboring color images by using an n-bit equal-bit quantum adder to obtain the sum of the intensity information of each color channel. Specifically, the method includes: firstly, the quantum color image is added to the intensity information of each color channel at the corresponding positions of the eight neighboring color images by using a Toffoli gate, and the carry information of the added intensity value is stored in an auxiliary bit; secondly, the sum of the intensity information of each color channel after the addition is added by using a CNOT gate, and the carry information after the addition is stored in the first auxiliary bit; and thirdly, any two bits are added by using a Toffoli gate. The intensity value of the color channel set and the carry information stored in the first auxiliary bit are stored in the second auxiliary bit; finally, the carry information of the second auxiliary bit is added to the intensity value through the CNOT gate, and stored in the third auxiliary bit, and the quotient is output to form a one-bit quantum full adder; wherein, the quantum bit representing the carry information is set to two constant auxiliary bits, and is reused after the one-bit addition operation is completed through the zeroing gate, so that n one-bit quantum full adders are superimposed together to complete the design of the n-bit quantum full adder, the median is used as the input of the n-bit quantum full adder, and the added carry information is stored in the quantum bit; The quantum color image expression after the replacement and / or retention processing is measured, the information of each component is obtained from the quantum color image expression, and the information of each component is converted into classical image information.
2. The method according to claim 1, characterized in that Eight neighborhood color images of the classical color image are obtained, and nine quantum color images to be processed are obtained by preparing the classical color image and the eight neighborhood color images based on the OCQR model, including: Acquire information of a to-be-processed classic color image, wherein the information includes intensity information, size information, and color channel information of each color channel of the classic color image; Performing cyclic shift processing on the classical color image to be processed, each cyclic shift can obtain a neighborhood color image, and performing eight cyclic shifts can obtain eight neighborhood color images; Setting corresponding quantum bits according to information of the classical color image to be processed; According to the set quantum bits, the to-be-processed classical color image and eight neighborhood color images share the same position information and color channel information to control the intensity information of each image, and obtain a quantum sequence of unique mapping of the image's pixel position information, color channel information, and grayscale information to obtain a quantum color image.
3. The method according to claim 2, characterized in that The corresponding quantum bits are set according to the information of the classical color image to be processed, specifically: Set the grayscale value range of the classic color image to be processed to [0,2 m ], the size of the classic color image to be processed is ; Among them, m quantum bits represent the intensity information corresponding to each color image, 2 quantum bits represent the three color channels of each color image, and 2n quantum bits and 4 auxiliary quantum bits are set to indicate that the quantum color image and the eight neighboring color images share the same position information.
4. The method according to claim 1, characterized in that According to the quantum circuit of the median filter algorithm, the median calculation is performed on the quantum color image to obtain the median of the quantum color image, which specifically includes: The quantum color image and eight neighborhood color images are combined into nine neighborhood regions by using a quantum comparator, and each row of pixels in the nine neighborhood regions is compared and sorted, wherein the number of bits of the quantum comparator is m bits; Compare and sort each column of pixels in the nine neighborhood areas after the comparison and sorting processing of each row of pixels, to obtain a first sorting result, wherein the first sorting result includes a row sorting result and a column sorting result of the pixels; The maximum value of the first row, the middle value of the second row, and the minimum value of the last three rows of the sorting result are compared and sorted to obtain a second sorting result, wherein the middle value of the second sorting result is the median value of the pixels in the nine neighborhood areas.
5. The method according to claim 4, characterized in that The quantum color image and eight neighborhood color images are combined into nine neighborhood areas using a quantum comparator, and each row of pixels in the nine neighborhood areas is compared and sorted, including: Using a quantum comparator to compare three pixels in each row of the nine-neighborhood area, and output a comparison result, wherein the control bit of the quantum controlled switch is based on the result bit output by the quantum comparator, and the first pixel and the second pixel are compared, and the larger value is arranged at the position where the second pixel is located, and then the second pixel is compared with the third pixel to obtain a first result; The quantum controlled switch arranges the maximum value of the three pixel values at the position of the third pixel according to the first result, and then compares the first pixel with the second pixel to obtain the second result; The quantum controlled switch arranges the middle value of the three pixel values at the position where the second pixel is located, and arranges the minimum value of the three pixel values at the position where the first pixel is located according to the second result.
6. The method according to claim 1, characterized in that The sum of the intensity information is averaged by using a quantum divider to obtain a difference between the integer quotient and the pixel to be processed, and the difference is used as a threshold, specifically including: Step S31, using the output quantum string representing the sum of intensity information as the dividend, using a quantum comparator to compare the quantum bit and the pixel, and the comparison result is used as the control bit of the quantum controlled switch, wherein the value of the control bit is: when the quantum bit is less than the pixel value, the control bit is 0, otherwise it is 1; using the comparison result as the highest bit of the control bit control quotient, when the control bit result is 1, the quotient is assigned 1, and when the control bit result is 0, the quotient is assigned 0; Step S32, using the comparison result as a control bit, wherein the minuend is a pixel, the subtrahend is a quantum bit, the subtractor controls the subtraction operation to obtain a difference result of the subtraction operation, aligning the quantum bit representing the divisor with the difference, wherein the highest bit is used as the control bit to assign a value to the quotient, and the highest bit is used as the control bit of the subtractor; Step S33, using the difference result of the subtraction operation as the start of a new cycle, aligning the quantum bit representing the divisor with the second highest bit of the difference; Step S34, repeating steps S31-S33, completing the division operation and rounding to an integer to obtain the corresponding quotient; Step S35, compare the quotient and the pixel to be processed, and obtain the value of the comparison result bit: when the quotient is smaller than the pixel to be processed, the control bit is 0; otherwise it is 1, and the result bit is used as the control bit for sum exchange, where the larger value is used as the minuend and the smaller value is used as the subtrahend, and a subtraction operation is performed to obtain the threshold value.
7. The method according to claim 1, characterized in that Measuring the quantum color image expression after the replacement and / or retention processing, obtaining information of each component from the quantum color image expression, and converting the information of each component into classical image information, specifically including: By using the open source quantum computing toolkit QISKIT, the IBMQ simulation cloud platform, and the package management and environment management functions provided by Anaconda, the Python language is used to simulate and implement the quantum color image median filtering algorithm to obtain classical image information.
8. A quantum color image median filter optimization system, characterized in that: include: An image preparation module is used to obtain eight neighborhood color images of a classical color image, and to prepare the classical color image and the eight neighborhood color images based on the OCQR model to obtain nine quantum color images to be processed; A median calculation module is used to perform median calculation on the quantum color image according to the quantum circuit of the median filter algorithm to obtain the median of the quantum color image; The noise detection module is used to perform mean calculation on the intensity information of the quantum color image, obtain a threshold for filtering the median, replace the median corresponding to the pixels in the quantum color image that exceed the threshold, and retain the median corresponding to the pixels in the quantum color image that do not exceed the threshold; specifically comprising: using an n-bit quantum adder to add the intensity information of the color channels at corresponding positions of the quantum color image and eight neighboring color images to obtain the sum of the intensity information of each color channel, wherein the sum of the intensity information is a quantum string output by the n-bit quantum adder; using a quantum divider to perform mean calculation on the sum of the intensity information, obtain the difference between the integer quotient and the pixel to be processed, and use the difference as a threshold, wherein when the threshold is compared with the median of the quantum color image, when the threshold is greater than the median, the pixel is regarded as a noise point, and the median is replaced with the pixel to be processed, otherwise it remains unchanged; The quantum color image is added to the intensity information of the color channels at the corresponding positions of the eight neighboring color images by using an n-bit equal-bit quantum adder to obtain the sum of the intensity information of each color channel. Specifically, the method includes: firstly, the quantum color image is added to the intensity information of each color channel at the corresponding positions of the eight neighboring color images by using a Toffoli gate, and the carry information of the added intensity value is stored in an auxiliary bit; secondly, the sum of the intensity information of each color channel after the addition is added by using a CNOT gate, and the carry information after the addition is stored in the first auxiliary bit; and thirdly, any two bits are added by using a Toffoli gate. The intensity value of the color channel set and the carry information stored in the first auxiliary bit are stored in the second auxiliary bit; finally, the carry information of the second auxiliary bit is added to the intensity value through the CNOT gate, and stored in the third auxiliary bit, and the quotient is output to form a one-bit quantum full adder; wherein, the quantum bit representing the carry information is set to two constant auxiliary bits, and is reused after the one-bit addition operation is completed through the zeroing gate, so that n one-bit quantum full adders are superimposed together to complete the design of the n-bit quantum full adder, the median is used as the input of the n-bit quantum full adder, and the added carry information is stored in the quantum bit; The image information conversion module is used to measure the quantum color image expression after the replacement and / or retention processing, obtain the information of each component from the quantum color image expression, and convert the information of each component into classical image information.
