[go: up one dir, main page]

CN114638845A - Quantum image segmentation method and device based on double thresholds and storage medium - Google Patents

Quantum image segmentation method and device based on double thresholds and storage medium Download PDF

Info

Publication number
CN114638845A
CN114638845A CN202210275476.0A CN202210275476A CN114638845A CN 114638845 A CN114638845 A CN 114638845A CN 202210275476 A CN202210275476 A CN 202210275476A CN 114638845 A CN114638845 A CN 114638845A
Authority
CN
China
Prior art keywords
quantum
threshold
gray value
value
auxiliary
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202210275476.0A
Other languages
Chinese (zh)
Other versions
CN114638845B (en
Inventor
刘文杰
王璐
邓志良
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Nanjing University of Information Science and Technology
Original Assignee
Nanjing University of Information Science and Technology
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Nanjing University of Information Science and Technology filed Critical Nanjing University of Information Science and Technology
Priority to CN202210275476.0A priority Critical patent/CN114638845B/en
Publication of CN114638845A publication Critical patent/CN114638845A/en
Application granted granted Critical
Publication of CN114638845B publication Critical patent/CN114638845B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/11Region-based segmentation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N10/00Quantum computing, i.e. information processing based on quantum-mechanical phenomena
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/136Segmentation; Edge detection involving thresholding

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Data Mining & Analysis (AREA)
  • Computational Mathematics (AREA)
  • Condensed Matter Physics & Semiconductors (AREA)
  • Artificial Intelligence (AREA)
  • Evolutionary Computation (AREA)
  • Mathematical Analysis (AREA)
  • Mathematical Optimization (AREA)
  • Pure & Applied Mathematics (AREA)
  • Computing Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Mathematical Physics (AREA)
  • Software Systems (AREA)
  • Image Processing (AREA)

Abstract

本发明公开了一种基于双阈值的量子图像分割方法、装置及存储介质,其方法包括:获取灰度数字图像,并制备相应的NEQR量子图像;设置高阈值以及低阈值,并构建高阈值量子分割电路、低阈值量子分割电路以及高低阈值间量子分割电路;构建比较器,并基于比较器将NEQR量子图像的每个像素划分为灰度值大于等于高阈值的像素、灰度值小于低阈值的像素以及灰度值大于等于低阈值且小于高阈值的像素;通过高阈值量子分割电路、低阈值量子分割电路以及高低阈值间量子分割电路分别对灰度值大于高阈值的像素、灰度值小于低阈值的像素以及灰度值大于等于低阈值且小于等于高阈值的像素进行分割;本发明复杂较低,同时能够得到准确清晰的分割图。

Figure 202210275476

The invention discloses a quantum image segmentation method, device and storage medium based on double thresholds. The method includes: acquiring a grayscale digital image and preparing a corresponding NEQR quantum image; setting a high threshold and a low threshold, and constructing a high threshold quantum image Segmentation circuit, low-threshold quantum segmentation circuit, and quantum segmentation circuit between high and low thresholds; construct a comparator, and based on the comparator, divide each pixel of the NEQR quantum image into pixels whose gray value is greater than or equal to the high threshold, and whose gray value is less than the low threshold The pixels whose gray value is greater than or equal to the low threshold and less than the high threshold value; the high-threshold quantum segmentation circuit, the low-threshold quantum segmentation circuit and the quantum segmentation circuit between high and low thresholds respectively divide the pixels whose gray value is greater than the high threshold and the gray value Pixels smaller than the low threshold and pixels whose gray value is greater than or equal to the low threshold and less than or equal to the high threshold are segmented; the present invention is less complicated and can obtain an accurate and clear segmentation map at the same time.

Figure 202210275476

Description

一种基于双阈值的量子图像分割方法、装置及存储介质A kind of quantum image segmentation method, device and storage medium based on double threshold

技术领域technical field

本发明涉及一种基于双阈值的量子图像分割方法、装置及存储介质,属于量子图像处理技术领域。The invention relates to a quantum image segmentation method, device and storage medium based on double thresholds, and belongs to the technical field of quantum image processing.

背景技术Background technique

量子图像处理作为量子计算与图像处理的交叉学科,因为其结合了量子计算的并行性和纠缠性的高性能、实现了量子加速,提高了计算能力。这使得可以在量子计算机上解决一些经典计算机解决不了的问题。虽然量子图像处理技术的研究正在逐步深入,但是整体上还是属于起步阶段,并且发展方向不平衡。而且目前能做的只是对图像进行像滤波、特征提取和边缘检测这些简单的操作,更深层次的图像处理算法还需要进一步的研究。图像分割是图像分析的第一步,是计算机视觉的基础,是图像理解的重要组成部分。最常见的图像分割方法有:基于阈值的分割、基于区域的分割、基于边缘检测的分割和结合特定工具的分割。由于目前量子图像分割的研究还相对较少,技术还不太成熟,所以目前的量子图像分割算法对经典方法的实现还较少。2013年,Li等人提出了基于量子搜索算法的量子图像分割,在他们的算法中,没有提供用于振幅放大的Oracle运算符,这使得模拟非常困难。2014年,Caraiman等人提出了一种基于直方图的量子图像分割算法,他们利用量子傅里叶变换和量子振幅放大的性能,相比经典算法获得了指数级加速,但是GRover算子使用了量子Oracle,这是没办法确定的,并且在实际的量子算法中需要具体的Oracle运算符进行电路实现。一年后,Caraiman等人提出了一种基于单阈值的量子图像分割方法,他们讨论了Oracle运算符的电路实现,并提供了分割合成图像和真实图像的示例,但是该算法的实现需要50个量子比特,这使得在现有的量子计算平台很难模拟。这些量子图像分割算法都不是在量子模拟器上实现的。2019年,xia等人提出了新型多位量子比较器及其在图像二值化中的应用,他们选用一个阈值对量子图像进行二值分割,需要的量子比特数也相对较多,并且算法复杂度较高。上述算法都没有在量子模拟器中模拟。2020年,Yuan等人提出了双阈值的量子图像分割算法,量子比特数较少,并且在量子模拟器中进行了模拟。但算法复杂度随着图像灰度级的增加而增加,并且分割后的图像灰度级较多,对于一些需要详细分割的图形分割效果不明显。Quantum image processing is an interdisciplinary subject of quantum computing and image processing, because it combines the parallelism of quantum computing and the high performance of entanglement, realizes quantum acceleration, and improves computing power. This makes it possible to solve some problems on quantum computers that cannot be solved by classical computers. Although the research on quantum image processing technology is gradually deepening, it is still in its infancy as a whole, and the development direction is uneven. And what can be done at present is to perform simple operations such as filtering, feature extraction and edge detection on the image, and deeper image processing algorithms still need further research. Image segmentation is the first step in image analysis, the foundation of computer vision, and an important part of image understanding. The most common image segmentation methods are: threshold-based segmentation, region-based segmentation, edge detection-based segmentation, and segmentation combined with specific tools. Due to the relatively few researches on quantum image segmentation and the immature technology, the current quantum image segmentation algorithms have less implementation of classical methods. In 2013, Li et al. proposed quantum image segmentation based on quantum search algorithm, in their algorithm, the Oracle operator for amplitude amplification is not provided, which makes the simulation very difficult. In 2014, Caraiman et al. proposed a histogram-based quantum image segmentation algorithm. They used the performance of quantum Fourier transform and quantum amplitude amplification, and achieved exponential speedup compared to the classical algorithm, but the GRover operator used quantum Oracle, there is no way to determine, and specific Oracle operators are required for circuit implementation in actual quantum algorithms. A year later, Caraiman et al. proposed a single-threshold-based quantum image segmentation method, they discussed the circuit implementation of the Oracle operator, and provided an example of segmenting synthetic images and real images, but the implementation of the algorithm requires 50 Qubits, which make it difficult to simulate on existing quantum computing platforms. None of these quantum image segmentation algorithms are implemented on a quantum simulator. In 2019, xia et al. proposed a new type of multi-bit quantum comparator and its application in image binarization. They chose a threshold for binary segmentation of quantum images, which required a relatively large number of qubits and complex algorithms. higher degree. None of the above algorithms have been simulated in a quantum simulator. In 2020, Yuan et al. proposed a double-threshold quantum image segmentation algorithm with fewer qubits and simulated it in a quantum simulator. However, the complexity of the algorithm increases with the increase of the gray level of the image, and the segmented image has many gray levels, and the segmentation effect is not obvious for some graphics that require detailed segmentation.

发明内容SUMMARY OF THE INVENTION

本发明的目的在于克服现有技术中的不足,提供一种基于双阈值的量子图像分割方法、装置及存储介质,解决经典数字图像处理的实时性问题和现有的量子分割算法复杂度较高的问题,以及满足对量子图像准确分割的目的。The purpose of the present invention is to overcome the deficiencies in the prior art, provide a quantum image segmentation method, device and storage medium based on double thresholds, solve the real-time problem of classical digital image processing and the high complexity of the existing quantum segmentation algorithm problem, and meet the purpose of accurate segmentation of quantum images.

为达到上述目的,本发明是采用下述技术方案实现的:To achieve the above object, the present invention adopts the following technical solutions to realize:

第一方面,本发明提供了一种基于双阈值的量子图像分割方法,包括:In a first aspect, the present invention provides a double-threshold-based quantum image segmentation method, including:

获取灰度数字图像,并制备相应的NEQR量子图像;Acquire grayscale digital images and prepare corresponding NEQR quantum images;

设置高阈值以及低阈值,并构建高阈值量子分割电路、低阈值量子分割电路以及高低阈值间量子分割电路;Set high threshold and low threshold, and construct high threshold quantum segmentation circuit, low threshold quantum segmentation circuit and quantum segmentation circuit between high and low thresholds;

构建比较器,并基于比较器将NEQR量子图像的每个像素划分为灰度值大于等于高阈值的像素、灰度值小于低阈值的像素以及灰度值大于等于低阈值且小于高阈值的像素;Build a comparator and divide each pixel of the NEQR quantum image into pixels with a gray value greater than or equal to the high threshold, pixels with gray values less than the low threshold, and pixels with gray values greater than or equal to the low threshold and less than the high threshold based on the comparator ;

通过高阈值量子分割电路、低阈值量子分割电路以及高低阈值间量子分割电路分别对灰度值大于等于高阈值的像素、灰度值小于低阈值的像素以及灰度值大于等于低阈值且小于高阈值的像素进行分割。Through the high-threshold quantum segmentation circuit, the low-threshold quantum segmentation circuit, and the quantum segmentation circuit between high and low thresholds, the pixels whose gray value is greater than or equal to the high threshold, the pixels whose gray value is less than the low threshold, and the pixels whose gray value is greater than or equal to the low threshold and less than the high threshold are respectively analyzed. Threshold the pixels for segmentation.

可选的,所述灰度数字图像的尺寸为2n×2n,灰度范围为[0,2q-1];所述灰度数字图像需要2n+q个量子比特进行存储,则所述NEQR量子图像的表达式为:Optionally, the size of the grayscale digital image is 2n × 2n , and the grayscale range is [ 0,2q -1]; the grayscale digital image needs 2n+q qubits to be stored, then the The expression of the NEQR quantum image is:

Figure BDA0003555720070000021
Figure BDA0003555720070000021

其中,

Figure BDA0003555720070000022
表示量子图像灰度值,k=q-1,q-2,…,0;
Figure BDA0003555720070000031
|XY)=|Y)|X>=|Yn-1,Yn-2…Yi…Y0>|Xn-1,Xn-2…Xi…X0>表示量子图像的位置,Yi,Xi∈{0,1}。in,
Figure BDA0003555720070000022
Represents the quantum image gray value, k=q-1,q-2,...,0;
Figure BDA0003555720070000031
|XY)=|Y)|X>=|Y n-1 , Y n-2 ... Y i ... Y 0 >|X n-1 , X n-2 ... X i ... X 0 > represents the position of the quantum image , Y i , Xi {0, 1}.

可选的,所述比较器为:Optionally, the comparator is:

Figure BDA0003555720070000032
Figure BDA0003555720070000032

其中,a和b为比较器输入,y为比较器的输出;Among them, a and b are the comparator inputs, and y is the comparator output;

所述基于比较器将NEQR量子图像的每个像素划分为灰度值大于等于高阈值的像素、灰度值小于低阈值的像素以及灰度值大于等于低阈值且小于高阈值的像素包括:The comparator-based division of each pixel of the NEQR quantum image into pixels with a grayscale value greater than or equal to a high threshold, pixels with a grayscale value less than a low threshold, and pixels with a grayscale value greater than or equal to the low threshold and less than the high threshold include:

获取NEQR量子图像的每个像素的灰度值,将每个像素的灰度值和阈值由十进制转换为二进制,并将二进制的灰度值和阈值输入比较器;Obtain the gray value of each pixel of the NEQR quantum image, convert the gray value and threshold of each pixel from decimal to binary, and input the binary gray value and threshold into the comparator;

所述比较器从二进制的低位到高位逐个进行比较:The comparator compares one by one from the low to high bits of the binary:

第一位:将第一位二进制数a0b0输入比较器,并将输出y0赋值给辅助量子位h2The first bit: input the first binary number a 0 b 0 into the comparator, and assign the output y 0 to the auxiliary qubit h 2 ;

第二位:将第二位二进制数a1b1输入比较器,并将输出y1赋值给辅助量子位h1;对第一位和第二位的比较结果进行分析:The second bit: input the second binary number a 1 b 1 into the comparator, and assign the output y 1 to the auxiliary qubit h 1 ; analyze the comparison results of the first and second bits:

若辅助量子位h1为1时,则将辅助量子位h1作为输出y1If the auxiliary qubit h 1 is 1, the auxiliary qubit h 1 is used as the output y 1 ;

若辅助量子位h1为0时且a1b1非10时,通过CNOT门和Toffoli门组合输出辅助量子位h1,具体为:If the auxiliary qubit h 1 is 0 and a 1 b 1 is not 10, the auxiliary qubit h 1 is output through the combination of CNOT gate and Toffoli gate, specifically:

通过CNOT门连接辅助量子位h1h0The auxiliary qubit h 1 h 0 is connected through the CNOT gate,

若辅助量子位h1为0时,辅助量子位h0为1;If the auxiliary qubit h 1 is 0, the auxiliary qubit h 0 is 1;

若辅助量子位h1为1时,辅助量子位h0为0;If the auxiliary qubit h 1 is 1, the auxiliary qubit h 0 is 0;

通过Toffoli门连接辅助量子位h2h0The auxiliary qubits h 2 h 0 are connected through Toffoli gates,

若辅助量子位h2h0为11,对辅助量子位h1进行异或处理,将处理结果作为输出y1If the auxiliary qubit h 2 h 0 is 11, perform XOR processing on the auxiliary qubit h 1 , and use the processing result as the output y 1 ;

若辅助量子位h1为0时且a1b1为10时,通过Toffoli门输出辅助量子位h1,具体为:If the auxiliary qubit h 1 is 0 and a 1 b 1 is 10, the auxiliary qubit h 1 is output through the Toffoli gate, specifically:

对辅助量子位h0进行异或处理;XOR the auxiliary qubit h 0 ;

通过Toffoli门连接辅助量子位h2h0The auxiliary qubits h 2 h 0 are connected through Toffoli gates,

若辅助量子位h2h0为11,对辅助量子位h1进行异或处理,将处理结果作为输出y1;并对辅助量子位h2h0进行复位操作;If the auxiliary qubit h 2 h 0 is 11, perform XOR processing on the auxiliary qubit h 1 , and use the processing result as the output y 1 ; perform a reset operation on the auxiliary qubit h 2 h 0 ;

剩余位按照第二位方法依次执行直至所有位比较完成。The remaining bits are executed sequentially according to the second bit method until all bits are compared.

可选的,所述高阈值量子分割电路将灰度值大于等于高阈值的像素进行分割包括:Optionally, the high-threshold quantum segmentation circuit segmenting pixels whose grayscale values are greater than or equal to the high-threshold includes:

将所述灰度值大于等于高阈值的像素的灰度值的量子位均置1,具体过程包括:The qubits of the gray value of the pixel whose gray value is greater than or equal to the high threshold are all set to 1, and the specific process includes:

当灰度值大于等于高阈值的像素的灰度值的量子位为0时,使用CNOT门对辅助量子比特进行置1;When the qubit of the gray value of the pixel whose gray value is greater than or equal to the high threshold is 0, use the CNOT gate to set the auxiliary qubit to 1;

当两个辅助量子比特均为1时,使用Toffoli门对灰度值的量子位进行异或操作;When the two auxiliary qubits are both 1, use the Toffoli gate to perform XOR operation on the qubits of the gray value;

操作完成后,将辅助量子位置0;After the operation is completed, the auxiliary quantum position will be 0;

重复上述步骤,直至灰度值大于等于高阈值的像素的灰度值的所有量子位操作完成。The above steps are repeated until all qubit operations whose gray value is greater than or equal to the gray value of the high threshold pixel are completed.

可选的,所述低阈值量子分割电路将灰度值小于低阈值的像素进行分割包括:Optionally, the low-threshold quantum segmentation circuit for segmenting pixels whose grayscale values are less than the low-threshold includes:

将所述灰度值小于低阈值的像素的灰度值的量子位均置0,具体过程包括:The qubits of the gray value of the pixel whose gray value is less than the low threshold are all set to 0, and the specific process includes:

当灰度值小于低阈值的像素的灰度值的量子位为1时,使用CNOT门对辅助量子比特进行置1;When the qubit of the gray value of the pixel whose gray value is less than the low threshold is 1, use the CNOT gate to set the auxiliary qubit to 1;

当两个辅助量子比特均为1时,使用Toffoli门对灰度值的量子位进行异或操作;When the two auxiliary qubits are both 1, use the Toffoli gate to perform XOR operation on the qubits of the gray value;

操作完成后,将辅助量子位置0;After the operation is completed, the auxiliary quantum position will be 0;

重复上述步骤,直至灰度值小于低阈值的像素的灰度值的所有量子位操作完成。The above steps are repeated until all qubit operations of the gray value of the pixel whose gray value is less than the low threshold are completed.

可选的,所述高低阈值间量子分割电路将灰度值大于等于低阈值且小于高阈值的像素进行分割包括:Optionally, the quantum segmentation circuit between high and low thresholds divides pixels whose grayscale values are greater than or equal to the low threshold and less than the high threshold, including:

将所述灰度值大于等于低阈值且小于高阈值的像素的灰度值的第一量子位置1,剩余量子位置0;具体过程包括:The first quantum position of the gray value of the pixel whose gray value is greater than or equal to the low threshold and less than the high threshold is set to 1, and the remaining quantum positions are 0; the specific process includes:

当灰度值大于等于低阈值且小于高阈值的像素的灰度值的最后量子位之外的量子位为1时,使用CNOT门对辅助量子比特进行置1;When the qubits other than the last qubit of the gray value of the pixel whose gray value is greater than or equal to the low threshold and less than the high threshold are 1, use the CNOT gate to set the auxiliary qubit to 1;

当两个辅助量子比特均为1时,使用Toffoli门对灰度值的量子位进行异或操作;When the two auxiliary qubits are both 1, use the Toffoli gate to perform XOR operation on the qubits of the gray value;

操作完成后,将辅助量子位置0;After the operation is completed, the auxiliary quantum position will be 0;

重复上述步骤,直至灰度值大于等于低阈值且小于高阈值的像素的灰度值的最后量子位之外的量子位均操作完成;Repeat the above steps until all qubits except the last qubit of the gray value of the pixel whose gray value is greater than or equal to the low threshold and less than the high threshold are completed;

当灰度值大于等于低阈值且小于高阈值的像素的灰度值的最后量子位为0时,使用CNOT门对辅助量子比特进行置1;When the last qubit of the gray value of the pixel whose gray value is greater than or equal to the low threshold and less than the high threshold is 0, use the CNOT gate to set the auxiliary qubit to 1;

当两个辅助量子比特均为1时,使用Toffoli门对灰度值的量子位进行异或操作。When both auxiliary qubits are 1, the gray-valued qubits are XORed using a Toffoli gate.

第二方面,本发明提供了一种基于双阈值的量子图像分割装置,所述装置包括:In a second aspect, the present invention provides a double-threshold-based quantum image segmentation device, the device comprising:

图像制备模块,用于获取灰度数字图像,并制备相应的NEQR量子图像;Image preparation module for acquiring grayscale digital images and preparing corresponding NEQR quantum images;

分割电路模块,用于设置高阈值以及低阈值,并构建高阈值量子分割电路、低阈值量子分割电路以及高低阈值间量子分割电路;The segmentation circuit module is used to set high threshold and low threshold, and construct high threshold quantum segmentation circuit, low threshold quantum segmentation circuit and quantum segmentation circuit between high and low thresholds;

像素分割模块,用于构建比较器,并基于比较器将NEQR量子图像的每个像素划分为灰度值大于等于高阈值的像素、灰度值小于低阈值的像素以及灰度值大于等于低阈值且小于高阈值的像素;The pixel segmentation module is used to construct a comparator, and based on the comparator, each pixel of the NEQR quantum image is divided into pixels whose gray value is greater than or equal to the high threshold, pixels whose gray value is less than the low threshold, and pixels whose gray value is greater than or equal to the low threshold and less than the high threshold pixels;

图像分割模块,用于通过高阈值量子分割电路、低阈值量子分割电路以及高低阈值间量子分割电路分别对灰度值大于等于高阈值的像素、灰度值小于低阈值的像素以及灰度值大于等于低阈值且小于高阈值的像素进行分割。The image segmentation module is used to separate the pixels whose gray values are greater than or equal to the high threshold, the pixels whose gray values are less than the low threshold, and those whose gray values are greater than Pixels equal to the low threshold and less than the high threshold are segmented.

第三方面,本发明提供了一种基于双阈值的量子图像分割装置,包括处理器及存储介质;In a third aspect, the present invention provides a dual-threshold-based quantum image segmentation device, including a processor and a storage medium;

所述存储介质用于存储指令;the storage medium is used for storing instructions;

所述处理器用于根据所述指令进行操作以执行根据上述方法的步骤。The processor is adapted to operate in accordance with the instructions to perform steps in accordance with the above-described method.

第四方面,本发明提供了计算机可读存储介质,其上存储有计算机程序,其特征在于,该程序被处理器执行时实现上述方法的步骤。In a fourth aspect, the present invention provides a computer-readable storage medium on which a computer program is stored, characterized in that, when the program is executed by a processor, the steps of the above method are implemented.

与现有技术相比,本发明所达到的有益效果:Compared with the prior art, the beneficial effects achieved by the present invention:

本发明提供了一种基于双阈值的量子图像分割方法、装置及存储介质,通过灰度数字图像制备NEQR量子图像,通过设置高阈值、低阈值和比较器,对NEQR量子图像的像素进行分割,针对分割后的每个像素通过构建不同的分割电路进行分割,复杂较低,同时能够得到准确清晰的分割图。The invention provides a quantum image segmentation method, device and storage medium based on double thresholds. A NEQR quantum image is prepared by a grayscale digital image, and the pixels of the NEQR quantum image are segmented by setting a high threshold, a low threshold and a comparator. For each segmented pixel, different segmentation circuits are constructed for segmentation, which is less complex and can obtain an accurate and clear segmentation map at the same time.

附图说明Description of drawings

图1是本发明实施例一提供的一种基于双阈值的量子图像分割方法流程示意图;1 is a schematic flowchart of a method for dividing a quantum image based on double thresholds provided in Embodiment 1 of the present invention;

图2是本发明实施例一提供的比较器示意图;2 is a schematic diagram of a comparator provided in Embodiment 1 of the present invention;

图3是本发明实施例一提供的高阈值量子分割电路示意图;3 is a schematic diagram of a high-threshold quantum segmentation circuit provided in Embodiment 1 of the present invention;

图4是本发明实施例一提供的低阈值量子分割电路示意图;4 is a schematic diagram of a low-threshold quantum segmentation circuit provided in Embodiment 1 of the present invention;

图5是本发明实施例一提供的高低阈值间量子分割电路示意图;5 is a schematic diagram of a quantum division circuit between high and low thresholds provided by Embodiment 1 of the present invention;

图6是本发明实施例一提供的完整的量子图像分割电路示意图;6 is a schematic diagram of a complete quantum image segmentation circuit provided by Embodiment 1 of the present invention;

图7是本发明实施例一提供的示例的灰度数字图像示意图;7 is a schematic diagram of a grayscale digital image of an example provided by Embodiment 1 of the present invention;

图8是本发明实施例一提供的示例的灰度数字图像制备量子图示意图;8 is a schematic diagram of a quantum diagram for preparing an example grayscale digital image provided in Embodiment 1 of the present invention;

图9是本发明实施例一提供的示例的比较示意图;FIG. 9 is a comparative schematic diagram of an example provided by Embodiment 1 of the present invention;

图10是本发明实施例一提供的示例的高阈值量子分割示意图;10 is a schematic diagram of an example high-threshold quantum partitioning provided by Embodiment 1 of the present invention;

图11是本发明实施例一提供的示例的低阈值量子分割示意图;11 is a schematic diagram of an example low-threshold quantum segmentation provided by Embodiment 1 of the present invention;

图12是本发明实施例一提供的示例的高低阈值间量子分割示意图;12 is a schematic diagram of quantum division between high and low thresholds of an example provided by Embodiment 1 of the present invention;

图13是本发明实施例一提供的示例的分割结果示意图。FIG. 13 is a schematic diagram of an example segmentation result provided by Embodiment 1 of the present invention.

具体实施方式Detailed ways

下面结合附图对本发明作进一步描述。以下实施例仅用于更加清楚地说明本发明的技术方案,而不能以此来限制本发明的保护范围。The present invention will be further described below in conjunction with the accompanying drawings. The following examples are only used to illustrate the technical solutions of the present invention more clearly, and cannot be used to limit the protection scope of the present invention.

实施例一:Example 1:

如图1所示,本发明实施例提供了一种基于双阈值的量子图像分割方法,包括:As shown in FIG. 1 , an embodiment of the present invention provides a quantum image segmentation method based on double thresholds, including:

1、获取灰度数字图像,并制备相应的NEQR量子图像。1. Acquire a grayscale digital image and prepare the corresponding NEQR quantum image.

灰度数字图像的尺寸为2n×2n,灰度范围为[0,2q-1];灰度数字图像需要2n+q个量子比特进行存储,则NEQR量子图像的表达式为:The size of the grayscale digital image is 2n × 2n , and the grayscale range is [0, 2q-1]; the grayscale digital image needs 2n+ q qubits for storage, then the expression of the NEQR quantum image is:

Figure BDA0003555720070000071
Figure BDA0003555720070000071

其中,

Figure BDA0003555720070000072
表示量子图像灰度值,k=q-1,q-2,…,0,
Figure BDA0003555720070000073
|XY>=|Y>|X>=|Yn-1,Yn-2…Yi…Y0>|Xn-1,Xn-2…Xi…X0>表示量子图像的位置,Yi,Xi∈{0,1}。in,
Figure BDA0003555720070000072
Represents the gray value of the quantum image, k=q-1, q-2, ..., 0,
Figure BDA0003555720070000073
|XY>=|Y>|X>=|Y n-1 , Y n-2 …Y i …Y 0 >|X n-1 , X n-2 …X i … X 0 >represents the position of the quantum image , Y i , Xi {0, 1}.

2、设置高阈值以及低阈值,并构建高阈值量子分割电路、低阈值量子分割电路以及高低阈值间量子分割电路。2. Set high threshold and low threshold, and construct high-threshold quantum division circuit, low-threshold quantum division circuit, and quantum division circuit between high and low thresholds.

3、构建比较器,并基于比较器将NEQR量子图像的每个像素划分为灰度值大于等于高阈值的像素、灰度值小于低阈值的像素以及灰度值大于等于低阈值且小于高阈值的像素。3. Build a comparator, and based on the comparator, divide each pixel of the NEQR quantum image into pixels whose gray value is greater than or equal to the high threshold, pixels whose gray value is less than the low threshold, and pixels whose gray value is greater than or equal to the low threshold and less than the high threshold of pixels.

如图2所示,比较器为:As shown in Figure 2, the comparator is:

Figure BDA0003555720070000074
Figure BDA0003555720070000074

其中,a和b为比较器输入,y为比较器的输出;Among them, a and b are the comparator inputs, and y is the comparator output;

基于比较器将NEQR量子图像的每个像素划分为灰度值大于等于高阈值的像素、灰度值小于低阈值的像素以及灰度值大于等于低阈值且小于高阈值的像素包括:Based on the comparator, each pixel of the NEQR quantum image is divided into pixels whose gray value is greater than or equal to the high threshold, pixels whose gray value is less than the low threshold, and pixels whose gray value is greater than or equal to the low threshold and less than the high threshold, including:

获取NEQR量子图像的每个像素的灰度值,将每个像素的灰度值和阈值由十进制转换为二进制,并将二进制的灰度值和阈值输入比较器;Obtain the gray value of each pixel of the NEQR quantum image, convert the gray value and threshold of each pixel from decimal to binary, and input the binary gray value and threshold into the comparator;

比较器从二进制的低位到高位逐个进行比较:The comparator compares one by one from the low-order to high-order bits of the binary:

第一位:将第一位二进制数a0b0输入比较器,并将输出y0赋值给辅助量子位h2The first bit: input the first binary number a 0 b 0 into the comparator, and assign the output y 0 to the auxiliary qubit h 2 ;

第二位:将第二位二进制数a1b1输入比较器,并将输出y1赋值给辅助量子位h1;对第一位和第二位的比较结果进行分析:The second bit: input the second binary number a 1 b 1 into the comparator, and assign the output y 1 to the auxiliary qubit h 1 ; analyze the comparison results of the first and second bits:

若辅助量子位h1为1时,则将辅助量子位h1作为输出y1If the auxiliary qubit h 1 is 1, the auxiliary qubit h 1 is used as the output y 1 ;

若辅助量子位h1为0时且a1b1非10时,通过CNOT门和Toffoli门组合输出辅助量子位h1,具体为:If the auxiliary qubit h 1 is 0 and a 1 b 1 is not 10, the auxiliary qubit h 1 is output through the combination of CNOT gate and Toffoli gate, specifically:

通过CNOT门连接辅助量子位h1h0The auxiliary qubit h 1 h 0 is connected through the CNOT gate,

若辅助量子位h1为0时,辅助量子位h0为1;If the auxiliary qubit h 1 is 0, the auxiliary qubit h 0 is 1;

若辅助量子位h1为1时,辅助量子位h0为0;If the auxiliary qubit h 1 is 1, the auxiliary qubit h 0 is 0;

通过Toffoli门连接辅助量子位h2h0The auxiliary qubits h 2 h 0 are connected through Toffoli gates,

若辅助量子位h2h0为11,对辅助量子位h1进行异或处理,将处理结果作为输出y1If the auxiliary qubit h 2 h 0 is 11, perform XOR processing on the auxiliary qubit h 1 , and use the processing result as the output y 1 ;

若辅助量子位h1为0时且a1b1为10时,通过Toffoli门输出辅助量子位h1,具体为:If the auxiliary qubit h 1 is 0 and a 1 b 1 is 10, the auxiliary qubit h 1 is output through the Toffoli gate, specifically:

对辅助量子位h0进行异或处理;XOR the auxiliary qubit h 0 ;

通过Toffoli门连接辅助量子位h2h0The auxiliary qubits h 2 h 0 are connected through Toffoli gates,

若辅助量子位h2h0为11,对辅助量子位h1进行异或处理,将处理结果作为输出y1;并对辅助量子位h2h0进行复位操作;If the auxiliary qubit h 2 h 0 is 11, perform XOR processing on the auxiliary qubit h 1 , and use the processing result as the output y 1 ; perform a reset operation on the auxiliary qubit h 2 h 0 ;

剩余位按照第二位方法依次执行直至所有位比较完成。The remaining bits are executed sequentially according to the second bit method until all bits are compared.

4、通过高阈值量子分割电路、低阈值量子分割电路以及高低阈值间量子分割电路分别对灰度值大于等于高阈值的像素、灰度值小于低阈值的像素以及灰度值大于等于低阈值且小于高阈值的像素进行分割。4. Through the high-threshold quantum segmentation circuit, the low-threshold quantum segmentation circuit, and the quantum segmentation circuit between high and low thresholds, the pixels whose gray value is greater than or equal to the high threshold, the pixels whose gray value is less than the low threshold, and the pixels whose gray value is greater than or equal to the low threshold and Pixels smaller than a high threshold are segmented.

4.1、如图3所示,高阈值量子分割电路将灰度值大于等于高阈值的像素(yH=0)进行分割包括:4.1. As shown in Figure 3, the high-threshold quantum segmentation circuit divides the pixels whose gray value is greater than or equal to the high threshold (y H = 0), including:

将灰度值大于等于高阈值的像素的灰度值的量子位均置1,具体过程包括:The qubits of the gray value of the pixel whose gray value is greater than or equal to the high threshold are all set to 1, and the specific process includes:

当灰度值大于等于高阈值的像素的灰度值的量子位(C0C1…Cq-1)为0时,使用CNOT门对辅助量子比特进行置1;When the qubit (C 0 C 1 . . . C q-1 ) of the gray value of the pixel whose gray value is greater than or equal to the high threshold is 0, use the CNOT gate to set the auxiliary qubit to 1;

当两个辅助量子比特均为1时,使用Toffoli门对灰度值的量子位进行异或操作;When the two auxiliary qubits are both 1, use the Toffoli gate to perform XOR operation on the qubits of the gray value;

操作完成后,将辅助量子位置0;After the operation is completed, the auxiliary quantum position will be 0;

重复上述步骤,直至灰度值大于等于高阈值的像素的灰度值的所有量子位操作完成。The above steps are repeated until all qubit operations whose gray value is greater than or equal to the gray value of the high threshold pixel are completed.

4.2、如图4所示,低阈值量子分割电路将灰度值小于低阈值的像素(yL=1)进行分割包括:4.2. As shown in Figure 4, the low-threshold quantum segmentation circuit divides the pixels whose gray value is less than the low threshold (yL=1), including:

将灰度值小于低阈值的像素的灰度值的量子位(C0C1…Cq-1)均置0,具体过程包括:The qubits (C 0 C 1 . . . C q-1 ) of the gray value of the pixel whose gray value is less than the low threshold are all set to 0, and the specific process includes:

当灰度值小于低阈值的像素的灰度值的量子位为1时,使用CNOT门对辅助量子比特进行置1;When the qubit of the gray value of the pixel whose gray value is less than the low threshold is 1, use the CNOT gate to set the auxiliary qubit to 1;

当两个辅助量子比特均为1时,使用Toffoli门对灰度值的量子位进行异或操作;When the two auxiliary qubits are both 1, use the Toffoli gate to perform XOR operation on the qubits of the gray value;

操作完成后,将辅助量子位置0;After the operation is completed, the auxiliary quantum position will be 0;

重复上述步骤,直至灰度值小于低阈值的像素的灰度值的所有量子位(C0C1…Cq-1)操作完成。The above steps are repeated until all qubits (C 0 C 1 . . . C q-1 ) of the gray value of the pixel whose gray value is less than the low threshold are completed.

4.3、如图5所示,高低阈值间量子分割电路将灰度值大于等于低阈值且小于高阈值的像素(yH=1且yL=0)进行分割包括:4.3. As shown in Figure 5, the quantum segmentation circuit between high and low thresholds divides the pixels (y H =1 and y L =0) whose gray value is greater than or equal to the low threshold and less than the high threshold (y H =1 and y L =0) including:

将灰度值大于等于低阈值且小于高阈值的像素的灰度值的第一量子位C0置1,剩余量子位C1…Cq-1置0;具体过程包括:The first qubit C 0 of the gray value of the pixel whose gray value is greater than or equal to the low threshold and less than the high threshold is set to 1, and the remaining qubits C 1 . . . C q-1 are set to 0; the specific process includes:

当灰度值大于等于低阈值且小于高阈值的像素的灰度值的最后量子位之外的量子位C0C1…Cq-2为1时,使用CNOT门对辅助量子比特进行置1;When the qubits C 0 C 1 . ;

当两个辅助量子比特均为1时,使用Toffoli门对灰度值的量子位进行异或操作;When the two auxiliary qubits are both 1, use the Toffoli gate to perform XOR operation on the qubits of the gray value;

操作完成后,将辅助量子位置0;After the operation is completed, the auxiliary quantum position will be 0;

重复上述步骤,直至灰度值大于等于低阈值且小于高阈值的像素的灰度值的最后量子位之外的量子位C0C1…Cq-2均操作完成;Repeat the above steps until all the qubits C 0 C 1 . . . C q-2 except the last qubit of the gray value of the pixel whose gray value is greater than or equal to the low threshold and less than the high threshold are completed;

当灰度值大于等于低阈值且小于高阈值的像素的灰度值的最后量子位Cq-1为0时,使用CNOT门对辅助量子比特进行置1;When the last qubit C q-1 of the gray value of the pixel whose gray value is greater than or equal to the low threshold and less than the high threshold is 0, use the CNOT gate to set the auxiliary qubit to 1;

当两个辅助量子比特均为1时,使用Toffoli门对灰度值的量子位进行异或操作。When both auxiliary qubits are 1, the gray-valued qubits are XORed using a Toffoli gate.

5、如图6所示,将比较器UC、高阈值量子分割电路S1、低阈值量子分割电路S2以及高低阈值间量子分割电路S3整合为完整的量子图像分割电路,TH和TL分别为高阈值和低阈值。5. As shown in FIG. 6 , the comparator U C , the high-threshold quantum dividing circuit S 1 , the low-threshold quantum dividing circuit S 2 , and the quantum dividing circuit S 3 between high and low thresholds are integrated into a complete quantum image dividing circuit, TH and TL are the high and low thresholds, respectively.

6、完整的量子图像分割电路的复杂度分析:6. Complexity analysis of the complete quantum image segmentation circuit:

单量子比特门和双量子比特门作为基础量子逻辑门,可以对任意量子比特进行操作。我们使用基础逻辑门的数量评估算法复杂度。基于图中电路的量子图像分割算法的电路量子代价分析。假设量子图像的大小为2n×2n,灰度范围为0~2q-1。所需的基本量子门的计算方法如下。一个量子比较器需要3q-2个Toffoli门、q-1个CNOT门和2q-2个复位门,共包含18q-13个基本量子逻辑门,我们需要两个量子比较器。此外,分割操作需要3q+1个Toffoli门,3q+2个CNOT门和3q+3个复位门。此外,还需要2q个NOT门和q个复位门来设置阈值。通常,NEQR量子图像的准备和测量过程不被认为是量子图像处理的一部分。因此,双阈值量子图像分割算法总共需要60q-6个基本的量子逻辑门。因此,电路的量子成本为60q-6,电路的复杂度为O(q),这意味着复杂度只与灰度值q有关,电路的复杂度不会随着量子图像大小的增加而增加。Single-qubit gates and two-qubit gates are fundamental quantum logic gates that can operate on arbitrary qubits. We evaluate algorithm complexity using the number of underlying logic gates. Circuit quantum cost analysis of a quantum image segmentation algorithm based on circuits in graphs. It is assumed that the size of the quantum image is 2 n × 2 n , and the grayscale range is 0 to 2 q -1. The required basic quantum gates are calculated as follows. A quantum comparator needs 3q-2 Toffoli gates, q-1 CNOT gates and 2q-2 reset gates, which contains 18q-13 basic quantum logic gates in total, and we need two quantum comparators. Furthermore, the split operation requires 3q+1 Toffoli gates, 3q+2 CNOT gates and 3q+3 reset gates. In addition, 2q NOT gates and q reset gates are required to set the threshold. In general, the preparation and measurement process of NEQR quantum images is not considered part of quantum image processing. Therefore, the double-threshold quantum image segmentation algorithm requires a total of 60q-6 basic quantum logic gates. Therefore, the quantum cost of the circuit is 60q-6, and the complexity of the circuit is O(q), which means that the complexity is only related to the gray value q, and the complexity of the circuit does not increase with the increase of the quantum image size.

如图7所示,以随机选择一幅灰度数字图像为例,该图像的尺寸为22×22,灰度范围为[0,7],用4+3个量子比特来存储,得到量子图像|IYX>,如图8所示。As shown in Figure 7, taking a grayscale digital image randomly selected as an example, the size of the image is 2 2 × 2 2 , the grayscale range is [0, 7], and 4+3 qubits are used to store it, we get Quantum image |I YX >, as shown in Figure 8.

设置高阈值为100。Set the high threshold to 100.

如图9所示,根据所选图像,我们用3量子比特的量子比较器对图像的灰度值和阈值进行比较,并且我们只需要知道a≥b和a<b这两种关系即可。如下图9所示,图中a和b作为输入,表示需要比较的两个数,y为比较结果输出。如果a≥b,则y=0;如果a<b,则y=1。h表示辅助量子位,我们从低位到高位逐个进行比较。当a0=0,b0=1时,也就是a0<b0时,h2=1,否则h2=0。此时第一位比较结束,第二位按照同样的比较方法进行比较,比较结束之后我们需要对两位的比较结果进行分析。当第二位比较结果为1时,直接输出结果;当第二位比较结果为0且a1b1不为10时,我们用CNOT门和Toffoli门组合输出比较结果;当第二位比较结果为0且a1b1为10时,此时表示a<b,需要使用Toffoli门对这种情况进行单独处理之后再进行输出。按照这种比较方法,我们比较3量子位的序列。As shown in Figure 9, according to the selected image, we use a 3-qubit quantum comparator to compare the grayscale value and threshold of the image, and we only need to know the two relations a≥b and a<b. As shown in Figure 9 below, in the figure a and b are used as inputs, indicating the two numbers to be compared, and y is the output of the comparison result. If a≥b, then y=0; if a<b, then y=1. h represents auxiliary qubits, and we compare them one by one from low to high. When a 0 =0, b 0 =1, that is, when a 0 <b 0 , h 2 =1, otherwise h 2 =0. At this time, the first comparison is over, and the second is compared according to the same comparison method. After the comparison, we need to analyze the comparison results of the two. When the second comparison result is 1, the result is output directly; when the second comparison result is 0 and a 1 b 1 is not 10, we use the CNOT gate and Toffoli gate to combine the output comparison result; when the second comparison result is 0 and a 1 b 1 is not 10 When a 1 b 1 is 0 and a 1 b 1 is 10, it means a<b, and the Toffoli gate needs to be used to deal with this situation separately before outputting. Following this comparison method, we compare sequences of 3 qubits.

如图10所示,阈值比较之后,根据比较结果yH=0,把那些大于等于高阈值的像素进行分割,把它们的灰度值设为111。当yH=0时,使用CNOT门对辅助量子比特置1。把灰度值信息量子位逐个进行变换。具体操作如下图10所示。当C=0时,使用CNOT门对辅助量子比特进行置1,当两个辅助量子比特都为1时,使用Toffoli门对C进行异或操作。当一个灰度值量子位操作完成后,只需要把辅助量子位设置为0,即可继续对下一个灰度值量子位进行变换操作。As shown in FIG. 10 , after the threshold comparison, according to the comparison result y H =0, those pixels that are greater than or equal to the high threshold are divided, and their grayscale values are set to 111. When y H =0, the auxiliary qubit is set to 1 using the CNOT gate. The gray value information qubits are transformed one by one. The specific operation is shown in Figure 10 below. When C=0, use the CNOT gate to set the auxiliary qubit to 1, and when both auxiliary qubits are 1, use the Toffoli gate to perform the XOR operation on C. When the operation of one gray value qubit is completed, it is only necessary to set the auxiliary qubit to 0, and then the transformation operation of the next gray value qubit can be continued.

设置低阈值为010。Set the low threshold to 010.

如图11所示,阈值比较之后,根据比较结果yL=1,把那些小于低阈值的像素进行分割,把它们的灰度值设为000。当yL=1时,使用CNOT门对辅助量子比特置1。把灰度值信息量子位逐个进行变换。具体操作如下图11所示。当C=1时,使用CNOT门对辅助量子比特进行置1,当两个辅助量子比特都为1时,使用Toffoli门对C进行异或操作。当一个灰度值量子位操作完成后,只需要把辅助量子位设置为0,即可继续对下一个灰度值量子位进行变换操作。As shown in FIG. 11 , after the threshold comparison, according to the comparison result y L =1, those pixels smaller than the low threshold are divided, and their grayscale values are set to 000. When y L =1, the auxiliary qubit is set to 1 using the CNOT gate. The gray value information qubits are transformed one by one. The specific operation is shown in Figure 11 below. When C=1, use the CNOT gate to set the auxiliary qubit to 1, and when both auxiliary qubits are 1, use the Toffoli gate to perform the XOR operation on C. When the operation of one gray value qubit is completed, it is only necessary to set the auxiliary qubit to 0, and then the transformation operation of the next gray value qubit can be continued.

如图12所示,阈值比较之后,根据比较结果且,把那些高低阈值之间的像素进行分割,把它们的灰度值设为100。当yL=0且yH=1时,使用Toffoli门对辅助量子比特置1。把灰度值信息量子位逐个进行变换。具体操作如下图12所示。当C2=0时,使用CNOT门对辅助量子比特进行置1,当两个辅助量子比特都为1时,使用Toffoli门对C进行异或操作。当C0C1=11时,使用CNOT门对辅助量子比特进行置1,当两个辅助量子比特都为1时,使用Toffoli门对C进行异或操作。当一个灰度值量子位操作完成后,只需要把辅助量子位设置为0,即可继续对下一个灰度值量子位进行变换操作。As shown in Figure 12, after the threshold comparison, according to the comparison result, the pixels between the high and low thresholds are divided, and their gray value is set to 100. When y L =0 and y H =1, the auxiliary qubit is set to 1 using a Toffoli gate. The gray value information qubits are transformed one by one. The specific operation is shown in Figure 12 below. When C 2 =0, use the CNOT gate to set the auxiliary qubit to 1, and when both auxiliary qubits are 1, use the Toffoli gate to perform the XOR operation on C. When C 0 C 1 =11, the CNOT gate is used to set the auxiliary qubit to 1, and when both auxiliary qubits are 1, the Toffoli gate is used to perform the XOR operation on C. When the operation of one gray value qubit is completed, it is only necessary to set the auxiliary qubit to 0, and then the transformation operation of the next gray value qubit can be continued.

如图13所示,为分割后的图像。As shown in Figure 13, it is the image after segmentation.

实施例二:Embodiment 2:

本发明实施例提供了一种基于双阈值的量子图像分割装置,装置包括:An embodiment of the present invention provides a double-threshold-based quantum image segmentation device, the device comprising:

图像制备模块,用于获取灰度数字图像,并制备相应的NEQR量子图像;Image preparation module for acquiring grayscale digital images and preparing corresponding NEQR quantum images;

分割电路模块,用于设置高阈值以及低阈值,并构建高阈值量子分割电路、低阈值量子分割电路以及高低阈值间量子分割电路;The segmentation circuit module is used to set high threshold and low threshold, and construct high threshold quantum segmentation circuit, low threshold quantum segmentation circuit and quantum segmentation circuit between high and low thresholds;

像素分割模块,用于构建比较器,并基于比较器将NEQR量子图像的每个像素划分为灰度值大于等于高阈值的像素、灰度值小于低阈值的像素以及灰度值大于等于低阈值且小于高阈值的像素;The pixel segmentation module is used to construct a comparator, and based on the comparator, each pixel of the NEQR quantum image is divided into pixels whose gray value is greater than or equal to the high threshold, pixels whose gray value is less than the low threshold, and pixels whose gray value is greater than or equal to the low threshold and less than the high threshold pixels;

图像分割模块,用于通过高阈值量子分割电路、低阈值量子分割电路以及高低阈值间量子分割电路分别对灰度值大于等于高阈值的像素、灰度值小于低阈值的像素以及灰度值大于等于低阈值且小于高阈值的像素进行分割。The image segmentation module is used to separate the pixels whose gray values are greater than or equal to the high threshold, the pixels whose gray values are less than the low threshold, and those whose gray values are greater than Pixels equal to the low threshold and less than the high threshold are segmented.

实施例三:Embodiment three:

基于实施例一,本发明实施例提供了一种基于双阈值的量子图像分割装置,包括处理器及存储介质;Based on the first embodiment, an embodiment of the present invention provides a dual-threshold-based quantum image segmentation device, including a processor and a storage medium;

存储介质用于存储指令;storage medium for storing instructions;

处理器用于根据指令进行操作以执行根据上述方法的步骤。A processor is operable in accordance with the instructions to perform steps in accordance with the above-described method.

实施例四:Embodiment 4:

基于实施例一,本发明提供了计算机可读存储介质,其上存储有计算机程序,其特征在于,该程序被处理器执行时实现上述方法的步骤。Based on the first embodiment, the present invention provides a computer-readable storage medium on which a computer program is stored, characterized in that, when the program is executed by a processor, the steps of the above method are implemented.

本领域内的技术人员应明白,本申请的实施例可提供为方法、系统、或计算机程序产品。因此,本申请可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本申请可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。As will be appreciated by those skilled in the art, the embodiments of the present application may be provided as a method, a system, or a computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein.

本申请是参照根据本申请实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the present application. It will be understood that each flow and/or block in the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to the processor of a general purpose computer, special purpose computer, embedded processor or other programmable data processing device to produce a machine such that the instructions executed by the processor of the computer or other programmable data processing device produce Means for implementing the functions specified in a flow or flow of a flowchart and/or a block or blocks of a block diagram.

这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory result in an article of manufacture comprising instruction means, the instructions The apparatus implements the functions specified in the flow or flow of the flowcharts and/or the block or blocks of the block diagrams.

这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。These computer program instructions can also be loaded on a computer or other programmable data processing device to cause a series of operational steps to be performed on the computer or other programmable device to produce a computer-implemented process such that The instructions provide steps for implementing the functions specified in the flow or blocks of the flowcharts and/or the block or blocks of the block diagrams.

以上所述仅是本发明的优选实施方式,应当指出,对于本技术领域的普通技术人员来说,在不脱离本发明技术原理的前提下,还可以做出若干改进和变形,这些改进和变形也应视为本发明的保护范围。The above are only the preferred embodiments of the present invention. It should be pointed out that for those skilled in the art, without departing from the technical principles of the present invention, several improvements and modifications can be made. These improvements and modifications It should also be regarded as the protection scope of the present invention.

Claims (9)

1. A quantum image segmentation method based on double thresholds is characterized by comprising the following steps:
acquiring a gray digital image and preparing a corresponding NEQR quantum image;
setting a high threshold value and a low threshold value, and constructing a high threshold value quantum partitioning circuit, a low threshold value quantum partitioning circuit and an inter-high-low-threshold value quantum partitioning circuit;
constructing a comparator, and dividing each pixel of the NEQR quantum image into a pixel with a gray value larger than or equal to a high threshold value, a pixel with a gray value smaller than a low threshold value and a pixel with a gray value larger than or equal to the low threshold value and smaller than the high threshold value on the basis of the comparator;
the pixels with the gray values larger than or equal to the high threshold value, the pixels with the gray values smaller than the low threshold value and the pixels with the gray values larger than or equal to the low threshold value and smaller than the high threshold value are respectively divided by the high-threshold-value quantum dividing circuit, the low-threshold-value quantum dividing circuit and the high-low-threshold-value quantum dividing circuit.
2. The dual-threshold-based quantum image segmentation method as claimed in claim 1, wherein the size of the grayscale digital image is 2n×2nThe gray scale range is [0,2 ]q-1](ii) a The gray-scale digital image requires 2n + q qubits for storage, and the expression of the NEQR quantum image is:
Figure FDA0003555720060000011
wherein,
Figure FDA0003555720060000012
represents the quantum image gray scale value, k-q-1, q-2, …, 0;
Figure FDA0003555720060000013
|XY>=|Y>|X>=|Yn-1,Yn-2…Yi…Y0>|Xn-1,Xn-2…Xi…X0>indicating the position of the quantum image, Yi,Xi∈{0,1}。
3. The quantum image segmentation method based on the background subtraction method as claimed in claim 1, wherein the comparator is:
Figure FDA0003555720060000014
where a and b are comparator inputs and y is the comparator output;
the dividing of each pixel of the NEQR quantum image into a pixel with a gray value greater than or equal to a high threshold, a pixel with a gray value less than a low threshold, and a pixel with a gray value greater than or equal to the low threshold and less than the high threshold based on the comparator comprises:
acquiring the gray value of each pixel of the NEQR quantum image, converting the gray value and the threshold value of each pixel into binary system from decimal system, and inputting the binary gray value and the threshold value into a comparator;
the comparators compare one by one from the low bit to the high bit of the binary system:
the first bit: the first binary digit a0b0Input to a comparator and output y0Assign to the auxiliary qubit h2
Second position: a second binary digit a1b1Input to a comparator and output y1Assign to the auxiliary qubit h1(ii) a Analyzing the comparison result of the first bit and the second bit:
if the auxiliary qubit h1When 1, the auxiliary qubit h will be1As an output y1
If the auxiliary qubit h1Is 0 and a1b1When the frequency is not 10, auxiliary quantum bit h is output through the combination of CNOT gate and Toffoli gate1The method specifically comprises the following steps:
connecting auxiliary qubits h through CNOT gates1h0
If the auxiliary qubit h1When 0, the auxiliary qubit h0Is 1;
if the auxiliary qubit h1When 1, the auxiliary qubit h0Is 0;
connecting auxiliary qubits h by Toffoli gate2h0
If auxiliary qubit h2h0To 11, for the auxiliary qubit h1Exclusive OR processing is carried out, and the processing result is taken as output y1
If the auxiliary qubit h1Is 0 and a1b1At 10, the auxiliary qubit h is output via the Toffoli gate1The method specifically comprises the following steps:
for auxiliary qubit h0Carrying out XOR processing;
connecting auxiliary qubits h by Toffoli gate2h0
If auxiliary qubit h2h0To 11, for the auxiliary qubit h1Exclusive OR processing is carried out, and the processing result is taken as output y1(ii) a And for the auxiliary qubit h2h0Carrying out reset operation;
the remaining bits are sequentially executed according to the second bit method until all bit comparisons are completed.
4. The method of claim 1, wherein the high-threshold quantum segmentation circuit segments the pixels with gray values equal to or greater than the high threshold value by:
setting the quantum bits with the gray value greater than or equal to the gray value of the pixel with the high threshold value to be 1, and the specific process comprises the following steps:
when the quantum bit with the gray value larger than or equal to the gray value of the pixel with the high threshold is 0, the CNOT gate is used for setting the auxiliary quantum bit to be 1;
when the two auxiliary qubits are both 1, performing exclusive-or operation on the qubits of the gray value by using a Toffoli gate;
after the operation is finished, the auxiliary quantum position is 0;
and repeating the steps until all the qubit operations of which the gray value is greater than or equal to the gray value of the pixel with the high threshold are completed.
5. The method of claim 1, wherein the low-threshold quantum segmentation circuit segments the pixels with gray values smaller than the low threshold value by:
setting the quantum bits of the gray values of the pixels with the gray values smaller than the low threshold value to be 0, and the specific process comprises the following steps:
when the qubit of the gray value of the pixel with the gray value smaller than the low threshold value is 1, using the CNOT gate to set the auxiliary qubit to 1;
when the two auxiliary qubits are both 1, performing exclusive-or operation on the qubits of the gray value by using a Toffoli gate;
after the operation is finished, the auxiliary quantum position is 0;
and repeating the steps until all the qubit operations of the gray value of the pixel with the gray value smaller than the low threshold value are completed.
6. The method of claim 1, wherein the inter-high-and-low-threshold quantum partitioning circuit partitions the pixels having gray values equal to or greater than the low threshold and less than the high threshold, and comprises:
enabling the gray value to be greater than or equal to the first quantum position 1 and the remaining quantum position 0 of the gray value of the pixel with the low threshold and smaller than the high threshold; the specific process comprises the following steps:
when the quantum bits except the last quantum bit of the gray value of the pixel with the gray value being more than or equal to the low threshold and less than the high threshold are 1, using the CNOT gate to set the auxiliary quantum bit to be 1;
when the two auxiliary qubits are both 1, performing exclusive-or operation on the qubits of the gray value by using a Toffoli gate;
after the operation is finished, the auxiliary quantum position is 0;
repeating the steps until all the qubits except the last qubit of the gray value of the pixel with the gray value being more than or equal to the low threshold and less than the high threshold are operated;
when the last qubit of the gray value of the pixel with the gray value being more than or equal to the low threshold and less than the high threshold is 0, using the CNOT gate to set the auxiliary qubit to 1;
when both the two auxiliary qubits are 1, the qubits of the grey value are xor-ed using a Toffoli gate.
7. A dual-threshold based quantum image segmentation apparatus, the apparatus comprising:
the image preparation module is used for acquiring the gray digital image and preparing a corresponding NEQR quantum image;
the dividing circuit module is used for setting a high threshold value and a low threshold value and constructing a high threshold value quantum dividing circuit, a low threshold value quantum dividing circuit and an inter-high-low-threshold value quantum dividing circuit;
the pixel segmentation module is used for constructing a comparator and dividing each pixel of the NEQR quantum image into a pixel with a gray value larger than or equal to a high threshold value, a pixel with a gray value smaller than a low threshold value and a pixel with a gray value larger than or equal to the low threshold value and smaller than the high threshold value on the basis of the comparator;
and the image segmentation module is used for respectively segmenting the pixels with the gray values larger than or equal to the high threshold, the pixels with the gray values smaller than the low threshold and the pixels with the gray values larger than or equal to the low threshold and smaller than the high threshold through the high-threshold quantum segmentation circuit, the low-threshold quantum segmentation circuit and the high-low inter-threshold quantum segmentation circuit.
8. A quantum image segmentation device based on double thresholds is characterized by comprising a processor and a storage medium;
the storage medium is used for storing instructions;
the processor is configured to operate in accordance with the instructions to perform the steps of the method according to any one of claims 1 to 6.
9. Computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the steps of the method according to any one of claims 1 to 6.
CN202210275476.0A 2022-03-21 2022-03-21 A quantum image segmentation method, device and storage medium based on double thresholds Active CN114638845B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210275476.0A CN114638845B (en) 2022-03-21 2022-03-21 A quantum image segmentation method, device and storage medium based on double thresholds

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210275476.0A CN114638845B (en) 2022-03-21 2022-03-21 A quantum image segmentation method, device and storage medium based on double thresholds

Publications (2)

Publication Number Publication Date
CN114638845A true CN114638845A (en) 2022-06-17
CN114638845B CN114638845B (en) 2024-08-06

Family

ID=81949369

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210275476.0A Active CN114638845B (en) 2022-03-21 2022-03-21 A quantum image segmentation method, device and storage medium based on double thresholds

Country Status (1)

Country Link
CN (1) CN114638845B (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115311315A (en) * 2022-07-19 2022-11-08 南京信息工程大学 A Quantum Image Segmentation Method Based on Local Adaptive Thresholding
CN116051597A (en) * 2023-02-08 2023-05-02 南京信息工程大学 Quantum moving target segmentation method, device and storage medium in video
CN116205931A (en) * 2022-11-02 2023-06-02 南京信息工程大学 Quantum image segmentation method for gray morphology

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109741236A (en) * 2018-12-12 2019-05-10 四川大学 A Quantum Image Threshold Segmentation Method Implemented on IBM Quantum Experiment Platform
CN110648348A (en) * 2019-09-30 2020-01-03 重庆邮电大学 Quantum image segmentation method based on NEQR expression
US20200034972A1 (en) * 2018-07-25 2020-01-30 Boe Technology Group Co., Ltd. Image segmentation method and device, computer device and non-volatile storage medium
CN111369557A (en) * 2020-03-31 2020-07-03 浙江大华技术股份有限公司 Image processing method, image processing device, computing equipment and storage medium

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20200034972A1 (en) * 2018-07-25 2020-01-30 Boe Technology Group Co., Ltd. Image segmentation method and device, computer device and non-volatile storage medium
CN109741236A (en) * 2018-12-12 2019-05-10 四川大学 A Quantum Image Threshold Segmentation Method Implemented on IBM Quantum Experiment Platform
CN110648348A (en) * 2019-09-30 2020-01-03 重庆邮电大学 Quantum image segmentation method based on NEQR expression
CN111369557A (en) * 2020-03-31 2020-07-03 浙江大华技术股份有限公司 Image processing method, image processing device, computing equipment and storage medium

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
YUAN SUZHEN, CHAOHANG BO, ET AL: "The dual-threshold quantum image segmentation algorithm and its simulation", 《QUANTUM INFORMATION PROCESSING》, vol. 19, no. 12, 23 November 2020 (2020-11-23), pages 1 - 21 *
任凤娟,等: "基于IBM Q平台的量子图像算法研究", 《四川大学学报(自然科学版)》, vol. 2020, no. 01, 20 March 2020 (2020-03-20), pages 89 - 95 *

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115311315A (en) * 2022-07-19 2022-11-08 南京信息工程大学 A Quantum Image Segmentation Method Based on Local Adaptive Thresholding
CN116205931A (en) * 2022-11-02 2023-06-02 南京信息工程大学 Quantum image segmentation method for gray morphology
CN116051597A (en) * 2023-02-08 2023-05-02 南京信息工程大学 Quantum moving target segmentation method, device and storage medium in video

Also Published As

Publication number Publication date
CN114638845B (en) 2024-08-06

Similar Documents

Publication Publication Date Title
Tsai et al. A light-weight neural network for wafer map classification based on data augmentation
Fang et al. Tinier-YOLO: A real-time object detection method for constrained environments
Gao et al. A convolutional neural network and graph convolutional network based framework for classification of breast histopathological images
CN114638845A (en) Quantum image segmentation method and device based on double thresholds and storage medium
CN111767962B (en) One-stage target detection method, system and device based on generative adversarial network
Liu et al. Quantum image edge detection based on eight-direction Sobel operator for NEQR
Jiang et al. Cascaded subpatch networks for effective CNNs
Yu et al. Real-time object detection towards high power efficiency
CN114581454A (en) A quantum image segmentation method, device and storage medium based on background difference method
CN114419406A (en) Image change detection method, training method, device and computer equipment
Ji et al. Semantic image segmentation with propagating deep aggregation
CN111930725B (en) A method and device for compressing and fusing power distribution data
US20230029163A1 (en) Wafer map analysis system using neural network and method of analyzing wafer map using the same
Wang et al. A quantum segmentation algorithm based on local adaptive threshold for NEQR image
Wang et al. An improved two-threshold quantum segmentation algorithm for NEQR image
CN114764619B (en) Convolution operation method and device based on quantum circuit
Yetis et al. A new framework for quantum image processing and application of binary template matching
Semmler et al. N-Dimensional Image Encoding on Quantum Computers
CN104320659B (en) Background modeling method, device and equipment
Pandey et al. Investigating the efficacy of a newly proposed activation function on deep neural networks
Ahmed et al. Tiny Deep Ensemble: Uncertainty Estimation in Edge AI Accelerators via Ensembling Normalization Layers with Shared Weights
CN116469103A (en) Automatic labeling method for medical image segmentation data
CN109635702A (en) Forestry biological hazards monitoring method and system based on satellite remote sensing images
CN116245902A (en) Complex scene cloud detection method and system based on image segmentation neural network
Meghana et al. Enhanced Semantic Image Segmentation Through Convolutional and Atrous Convolution Techniques

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant