A quantum image segmentation method based on grayscale morphology

Through the NEQR quantum image representation model and the grayscale morphology quantum image segmentation method, the superposition and entanglement characteristics of quantum computing are utilized to achieve efficient segmentation of quantum images, solving the problem of low efficiency in existing technologies, especially significantly accelerating the segmentation effect when processing unevenly illuminated images.

CN116205931BActive Publication Date: 2025-09-30NANJING UNIV OF INFORMATION SCI & TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202211360028.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-11-02
Publication Date
2025-09-30
Estimated Expiration
2042-11-02

AI Technical Summary

Technical Problem

Existing quantum image segmentation algorithms are inefficient when processing large-scale image data and cannot meet real-time requirements, especially when processing quantum images with uneven lighting.

Method used

The NEQR quantum image representation model, grayscale morphology, quantum comparator, quantum subtractor and quantum binarization circuit are used to segment the quantum image through cyclic shift, bottom hat transformation or top hat transformation and binarization operations, achieving exponentially accelerated processing speed.

Benefits of technology

It significantly accelerates the processing speed of classical methods and can effectively segment quantum images with uneven illumination, solving the problem that existing quantum segmentation algorithms cannot process such images and meeting the requirements for accurate segmentation of quantum images.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116205931B_ABST
    Figure CN116205931B_ABST
Patent Text Reader

Abstract

The present invention discloses a grayscale morphological quantum image segmentation method, characterized by obtaining an original NEQR quantum image; performing a cyclic shift operation on the original NEQR quantum image according to a neighborhood window to obtain a quantum image set; performing a bottom-hat transformation or a top-hat transformation on the quantum image set to obtain a result image; and performing a binarization operation on the result image obtained by the bottom-hat transformation or the top-hat transformation to obtain a binary image. The quantum version of morphological theory is used for image segmentation, and quantum images containing uneven illumination are well segmented. Unlike classical methods, the method of the present invention, which utilizes quantum computing, can process the quantum state superposition of pixels in the quantum image, thereby significantly accelerating the speed of the classical method.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to a grayscale morphological quantum image segmentation method, belonging to the technical field of quantum computing and quantum image processing. Background Art

[0002] Image processing technology is the foundation of computer vision and is currently widely used. As image acquisition equipment improves, image quality continues to improve, and data volumes also increase, requiring more computational resources for image processing. However, due to various limitations, classical computers are currently approaching their limits. Therefore, large-scale data processing consumes a significant amount of time. Image processing often requires rapid computer response, which poses real-time challenges. In recent years, quantum image processing, as a cross-disciplinary field between image processing and quantum computing, has garnered widespread attention from researchers.

[0003] Due to the unique superposition and entanglement properties of quantum computing, quantum image processing can achieve exponential acceleration compared to classical image processing, which is very significant. Quantum image representation models are the primary task of quantum image processing. Many scholars have conducted research in this area and proposed many quantum image representation models. Currently, there are many quantum image representation models, which can be mainly divided into two categories. One is to encode the image's color value into the probability amplitude of the quantum state and the position information into the quantum ground state. This method can encode the image with fewer quantum bits, but when retrieving the image, it requires a large number of measurements. Another encoding method encodes the image information into a sequence of three entangled quantum bits, which allows for rapid image retrieval with only a few measurements. The most commonly used model is the novel enhanced quantum representation (NEQR) model.

[0004] With the development of quantum image representation models, corresponding quantum image processing algorithms have also developed rapidly. Current quantum image processing algorithms mainly include quantum image geometric transformation, quantum image steganography, quantum image feature extraction, quantum image scrambling, quantum image watermarking, quantum image filtering, quantum image matching, quantum image edge detection, and quantum image segmentation. However, most current QIP algorithms are only theoretically feasible because they utilize excessive quantum resources, which is unsuitable in the noisy intermediate-scale quantum (NISQ) era. Image segmentation is the foundation of image processing. Although classical image segmentation algorithms are relatively mature, quantum image segmentation algorithms are still in their infancy.

[0005] Mathematical morphology is a new theory in image processing. Research on quantum morphological image processing conducted in 2015 focused on the dilation and erosion of quantum binary and grayscale images. However, the complexity was exponential, which is very high. In 2016, improvements to the algorithm reduced the complexity to polynomial levels, but this approach has not yet found practical application. In 2019, research on gradient images, leveraging fundamental quantum morphological knowledge, further expanded quantum morphological research. Morphological theory has been applied in practical applications such as image edge detection and image enhancement. However, to date, there is no quantum version of morphological theory for image segmentation. Summary of the Invention

[0006] The technical problem to be solved by the present invention is to overcome the defects of the existing technology and provide a grayscale morphological quantum image segmentation method, which adopts the NEQR quantum image representation model, grayscale morphology, quantum comparator, quantum subtractor and quantum binarization circuit to segment the quantum image, achieving exponentially accelerated processing speed.

[0007] To achieve the above object, the present invention provides a grayscale morphological quantum image segmentation method, comprising:

[0008] Get the original NEQR quantum image;

[0009] Perform a cyclic shift operation on the original NEQR quantum image according to the neighborhood window to obtain a quantum image set;

[0010] Perform bottom-hat transformation or top-hat transformation on the quantum image set to obtain the result image;

[0011] The result image obtained by the bottom hat transformation or the top hat transformation is binarized to obtain a binary image.

[0012] Preferably, the quantum state representation of the original NEQR quantum image is:

[0013]

[0014] Where, according to the NEQR model, 2n is the capacity of the quantum bit to store position information, q represents the grayscale of the pixel, Y is the vertical coordinate of the pixel in the original NEQR quantum image, X is the horizontal coordinate of the pixel in the original image, and C YX is the gray value of the pixel at coordinate (X, Y) in the original NEQR quantum image; I YX is the original NEQR quantum image; represents 5 auxiliary qubits, The initial state is 0.

[0015] Preferably, a cyclic shift operation is performed on the original NEQR quantum image according to the neighborhood window to obtain a quantum image set, which is achieved by the following steps:

[0016] Perform a cyclic shift operation on the original NEQR quantum image to obtain a quantum image set and neighborhood window pixels;

[0017] Then, the QCL module is used to find the pixel with the largest grayscale among the neighborhood window pixels, and then the new neighborhood window pixels are obtained after resetting the other neighborhood window pixels.

[0018] The present invention copies the maximum grayscale value in the pixels of the new neighborhood window to the original NEQR quantum image by using a copy operation to obtain the original image.

[0019] Preferably, a cyclic shift operation is performed on the original NEQR quantum image, which is achieved by the following steps:

[0020] Move the original NEQR quantum image up one unit to obtain the original NEQR quantum image |I Y+1X >:

[0021]

[0022] Shift the original NEQR quantum image one unit to the left, and get the original NEQR quantum image |I YX+1 >:

[0023]

[0024] Shift the original NEQR quantum image down one unit to obtain the original NEQR quantum image |I Y-1X >:

[0025]

[0026] Shift the original NEQR quantum image one unit to the right, and get the original NEQR quantum image |I YX-1 >:

[0027]

[0028] Obtaining the quantum image set and neighborhood window pixels is achieved through the following steps:

[0029] Based on the original NEQR quantum image after the cyclic shift operation, the quantum image set is obtained:

[0030]

[0031] The pixel at position (x, y) in the quantum image set is composed of the neighborhood window pixels of the structural element window of the original NEQR quantum image, thereby obtaining the neighborhood window pixels.

[0032] Preferably, a bottom-hat transformation or a top-hat transformation is performed on the quantum image set to obtain a result image, including:

[0033] The bottom hat transformation of the quantum image set is achieved by the following steps:

[0034] If the original image is an image of a dark object against a bright background, dilation and erosion operations are performed on the original image to obtain a second image, and then the original NEQR quantum image is subtracted from the second image to obtain a result image;

[0035] The top-hat transformation of the quantum image set is achieved by the following steps:

[0036] If the original image is an image of a bright object against a dark background, an erosion operation and a dilation operation are performed on the original image to obtain a fourth image, and then the fourth image is subtracted from the original NEQR quantum image to obtain a result image.

[0037] Preferably, in the bottom hat transformation, the original image is subjected to dilation and erosion operations to obtain a second image, and then the second image is subtracted from the original NEQR quantum image to obtain a result image, which is achieved by the following steps:

[0038] Performing a dilation operation on the original image to obtain a first image;

[0039] preprocessing the first image;

[0040] Performing an erosion operation on the preprocessed first image to obtain a second image;

[0041] The original NEQR quantum image is subtracted from the second image to obtain the resulting image.

[0042] Preprocessing the first image includes:

[0043] The first image is processed using a circular shift operation and a copy operation.

[0044] Preferably, in the top-hat transformation, the original image is subjected to an erosion operation and a dilation operation to obtain a fourth image, and then the fourth image is subtracted from the original NEQR quantum image to obtain a result image, which is achieved by the following steps:

[0045] Performing a dilation operation on the original image to obtain a third image;

[0046] preprocessing the third image;

[0047] performing an erosion operation on the preprocessed third image to obtain a fourth image;

[0048] The fourth image is subtracted from the original NEQR quantum image to obtain a result image.

[0049] Preprocessing the third image includes:

[0050] The third image is processed using a circular shift operation and a copy operation.

[0051] Preferably, a binarization operation is performed on the result image obtained by the bottom hat transformation or the top hat transformation to obtain a binary image, which is achieved by the following steps:

[0052] Transform the resulting image using grayscale morphology;

[0053] The quantum comparator QC is used to compare the result image after grayscale morphological transformation with the set grayscale value threshold, and the grayscale values ​​of the pixels of the result image greater than or equal to the grayscale value threshold are converted to 1, and the grayscale values ​​of the pixels of the result image less than the grayscale value threshold are converted to 0;

[0054] When the quantum comparator QC outputs the result y=0 and the lowest bit c0 of the grayscale binary representation is 0, the CNOT gate and Toffoli gate are used to set c0 to 1;

[0055] When the quantum comparator QC outputs the result y=1 and c0=1, the CNOT gate and Toffoli gate are used to set c0 to 0, and finally a binary image is obtained. The binary image contains the pixel position (x, y) and gray value information c of the result image. q-1 ,...,c1,c0.

[0056] An electronic device comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of any one of the above methods when executing the program.

[0057] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of any of the above methods.

[0058] The beneficial effects achieved by the present invention are:

[0059] This invention uses a quantum version of morphological theory for image segmentation, effectively segmenting quantum images with uneven illumination. Unlike classical methods, the invention's method, which utilizes quantum computing, can process the quantum state superposition of pixels in quantum images, achieving exponentially accelerated processing speed, thereby significantly accelerating the speed of classical methods.

[0060] The present invention adopts the NEQR quantum image representation model, grayscale morphology, quantum comparator, quantum subtractor and quantum binarization circuit to segment quantum images, solving the real-time problem of classical digital image processing and the problem that existing quantum segmentation algorithms cannot segment images with uneven illumination, thereby achieving the purpose of accurate quantum image segmentation. BRIEF DESCRIPTION OF THE DRAWINGS

[0061] Figure 1 It is a principle block diagram of the present invention;

[0062] Figure 2 is a logical operation diagram of the QCS operation in the dilation operation or the erosion operation of the present invention;

[0063] Figure 3 is a logic operation diagram of the QCL operation in the expansion operation or the corrosion operation of the present invention;

[0064] Figure 4 It is a logical operation diagram of the expansion operation of the present invention;

[0065] Figure 5 It is a logic operation diagram of the present invention for performing the corrosion operation;

[0066] Figure 6 It is a logic operation diagram for bottom-hat conversion of the present invention;

[0067] Figure 7 It is a logic operation diagram of the top-hat transformation of the present invention;

[0068] Figure 8 It is a binary logic operation diagram in the present invention;

[0069] Figure 9 is a logic operation diagram of the quantum comparator in the present invention;

[0070] Figure 10 is a logic operation diagram of the quantum subtractor in the present invention;

[0071] Figure 11 is a schematic diagram of the original NEQR quantum image in the present invention;

[0072] Figure 12 is the probability histogram of the bottom-hat transformation result image in the present invention;

[0073] Figure 13 is a schematic diagram of the resulting image obtained by bottom hat transformation;

[0074] Figure 14 is the probability histogram of the top-hat transformation result image in the present invention;

[0075] Figure 15 is a schematic diagram of the resulting image obtained by top-hat transformation. DETAILED DESCRIPTION

[0076] The following examples are only used to more clearly illustrate the technical solutions of the present invention and are not intended to limit the scope of protection of the present invention.

[0077] The first step is to prepare the NEQR quantum image

[0078] like Figure 1As shown, according to the NEQR model, 2n qubits are required to store position information, q qubits to store grayscale value information, and 4q qubits to store the grayscale values ​​of neighboring pixels;

[0079] Because the order will be disrupted when the neighborhood window is processed, in order to process the original NEQR quantum image later, the original NEQR quantum image is as follows Figure 11 As shown, we need additional q quantum bits to store the grayscale information of the original NEQR quantum image.

[0080] The present invention provides a grayscale morphological quantum image segmentation method, comprising:

[0081] Get the original NEQR quantum image;

[0082] Perform a cyclic shift operation on the original NEQR quantum image according to the neighborhood window to obtain a quantum image set;

[0083] Perform bottom-hat transformation or top-hat transformation on the quantum image set to obtain the result image;

[0084] The result image obtained by the bottom hat transformation or the top hat transformation is binarized to obtain a binary image.

[0085] Furthermore, the quantum state expression of the original NEQR quantum image in this embodiment is:

[0086]

[0087] Where, according to the NEQR model, 2n is the capacity of the quantum bit to store position information, q represents the grayscale of the pixel, Y is the vertical coordinate of the pixel in the original NEQR quantum image, X is the horizontal coordinate of the pixel in the original image, and C YX is the gray value of the pixel at coordinate (X, Y) in the original NEQR quantum image; I YX is the original NEQR quantum image; represents 5 auxiliary qubits, The initial state is 0.

[0088] The second step is the circular shift operation

[0089] Furthermore, in this embodiment, a cyclic shift operation is performed on the original NEQR quantum image according to the neighborhood window to obtain a quantum image set, which is achieved by the following steps:

[0090] Perform a cyclic shift operation on the original NEQR quantum image to obtain a quantum image set and neighborhood window pixels;

[0091] Then, the QCL module is used to find the pixel with the largest grayscale among the neighborhood window pixels, and then the new neighborhood window pixels are obtained after resetting the other neighborhood window pixels.

[0092] The present invention copies the maximum grayscale value in the pixels of the new neighborhood window to the original NEQR quantum image by using a copy operation to obtain the original image.

[0093] Furthermore, specifically, in order to simultaneously process all pixels in the original NEQR quantum image, the present invention performs a cyclic shift operation on the original NEQR quantum image according to a neighborhood window, so that the present invention can prepare a quantum image set. In this embodiment, the cyclic shift operation on the original NEQR quantum image is achieved by the following steps:

[0094] Move the original NEQR quantum image up one unit to obtain the original NEQR quantum image |I Y+1X >:

[0095]

[0096] Shift the original NEQR quantum image one unit to the left, and get the original NEQR quantum image |I YX+1 >:

[0097]

[0098] Shift the original NEQR quantum image down one unit to obtain the original NEQR quantum image |I Y-1X >:

[0099]

[0100] Shift the original NEQR quantum image one unit to the right, and get the original NEQR quantum image |I YX-1 >:

[0101]

[0102] Obtaining the quantum image set and neighborhood window pixels is achieved through the following steps:

[0103] Based on the original NEQR quantum image after the cyclic shift operation, the quantum image set is obtained:

[0104]

[0105] The pixel at position (x, y) in the quantum image set is composed of the neighborhood window pixels of the structural element window of the original NEQR quantum image, thereby obtaining the neighborhood window pixels. In this way, when the present invention processes the pixels at the same position in the quantum image set, it processes the neighborhood pixels of the structural element window. In addition, before performing the next operation, the present invention needs to copy the original NEQR quantum image into the auxiliary quantum bit, so that the original image can be operated again after the expansion or corrosion operation. Furthermore, in this embodiment, the quantum image set is subjected to a bottom hat transformation or a top hat transformation to obtain a result image, including:

[0106] like Figure 6 As shown, the bottom hat transformation of the quantum image set is achieved by the following steps:

[0107] If the original image is an image of a dark object against a bright background, dilation and erosion operations are performed on the original image to obtain a second image, and then the original NEQR quantum image is subtracted from the second image to obtain a result image;

[0108] like Figure 7 As shown, the top hat transformation of the quantum image set is achieved by the following steps:

[0109] If the original image is an image of a bright object against a dark background, an erosion operation and a dilation operation are performed on the original image to obtain a fourth image, and then the fourth image is subtracted from the original NEQR quantum image to obtain a result image.

[0110] Furthermore, in the bottom hat transformation of this embodiment, the dilation operation and the erosion operation are performed on the original image to obtain a second image, and then the original NEQR quantum image is subtracted from the second image to obtain a result image, which is achieved by the following steps:

[0111] Performing a dilation operation on the original image to obtain a first image;

[0112] preprocessing the first image;

[0113] Performing an erosion operation on the preprocessed first image to obtain a second image;

[0114] The original NEQR quantum image is subtracted from the second image to obtain the resulting image.

[0115] Preprocessing the first image includes:

[0116] The first image is processed using a circular shift operation and a copy operation. The circular shift operation in this step is the same as the step of "performing a circular shift operation on the original NEQR quantum image" in step 2. The first image is copied to the auxiliary quantum bit using the copy operation.

[0117] Furthermore, in the top-hat transformation of this embodiment, the original image is subjected to an erosion operation and a dilation operation to obtain a fourth image, and then the fourth image is subtracted from the original NEQR quantum image to obtain a result image, which is achieved by the following steps:

[0118] Performing a dilation operation on the original image to obtain a third image;

[0119] preprocessing the third image;

[0120] performing an erosion operation on the preprocessed third image to obtain a fourth image;

[0121] The fourth image is subtracted from the original NEQR quantum image to obtain a result image.

[0122] Preprocessing the third image includes:

[0123] The third image is processed using a circular shift operation and a copy operation. The circular shift operation in this step is the same as the step of "performing a circular shift operation on the original NEQR quantum image" in step 2. The third image is copied to the auxiliary quantum bit using a copy operation.

[0124] The expansion operation and the erosion operation are combined, and the cyclically shifted original NEQR quantum image stored in the auxiliary quantum bit is added. Then, the quantum subtractor is used to subtract the obtained expanded original image from the original NEQR quantum image. In this way, the bottom hat transformation and the top hat transformation can be performed. The quantum subtractor is as follows: Figure 10 The specific quantum circuit is shown in the figure.

[0125] Specifically, after the cyclic shift, the present invention needs to perform a bottom hat transform / top hat transform on the image.

[0126] When performing a bottom-hat transformation operation, the present invention needs to use the neighborhood window pixels obtained by circular shift, and then use the QCL module to find the pixel with the largest grayscale in the neighborhood window. After performing a reset operation on other neighborhood window pixels, the present invention uses a copy operation to copy its maximum grayscale value to the original image (the center point of the neighborhood window), so that an expansion operation can be performed to obtain a quantum image |G>; then circular shift G is shifted again, and the neighborhood window pixels obtained by circular shift are used, and then the QCS module is used to find the pixel with the smallest grayscale value in the neighborhood window, and then it is copied to the original image, so that the image can be eroded to obtain a quantum image |F>; then a subtractor is used to subtract the original image, that is, |F>-|I>, to obtain a quantum image |S>.

[0127] The top-hat transform, in contrast to the bottom-hat transform, first erodes the image and then dilates it, ultimately subtracting the eroded and dilated image from the original image. Specifically, the image is eroded using a circular shift to obtain pixels in the neighborhood window. The QCS module is then used to find the pixel with the smallest grayscale value in the neighborhood window and copy it to the original image. This erodes the image to obtain the quantum image |G>. G is then circularly shifted again, and the neighborhood window pixels obtained using the circular shift are then used to find the pixel with the largest grayscale value in the neighborhood window using the QCL module. After resetting the remaining neighborhood pixels, the present invention copies their maximum grayscale value to the original image (the center point of the neighborhood window) using a copy operation. This allows for dilation to obtain the quantum image |F>. A subtractor is then used to reduce |I> to |F>, resulting in the quantum image |S>.

[0128] Processing the first image and the third image using a circular shift operation includes:

[0129] The first or third image is:

[0130]

[0131] G YX Moving up one unit, we get:

[0132]

[0133] G YX Shifting one unit to the left, we get:

[0134]

[0135] G YX Shifting down one unit, we get:

[0136]

[0137] G YX Shifting right one unit, we get:

[0138]

[0139] Furthermore, after performing the bottom hat transformation or the top hat transformation in this embodiment, the present invention completes the deletion of the uneven illumination in the original NEQR quantum image. The result image obtained by the bottom hat transformation or the top hat transformation is binarized, such as Figure 8 As shown, the binary image is obtained by the following steps:

[0140] Transform the resulting image using grayscale morphology;

[0141] The quantum comparator QC is used to compare the result image after grayscale morphological transformation with the set grayscale value threshold, and the grayscale values ​​of the pixels of the result image greater than or equal to the grayscale value threshold are converted to 1, and the grayscale values ​​of the pixels of the result image less than the grayscale value threshold are converted to 0; the quantum comparator QC is as follows Figure 9 As shown;

[0142] Finally, the present invention only measures the quantum bit c0 required by the present invention, so the gray value c q-1 ,...,c1 does not perform any operation. When the quantum comparator QC outputs the result y=0, and the lowest bit c0 of the grayscale binary representation is 0, the CNOT gate and Toffoli gate are used to set c0 to 1;

[0143] When the quantum comparator QC outputs the result y=1 and c0=1, the CNOT gate and Toffoli gate are used to set c0 to 0, and finally a binary image is obtained. The binary image contains the pixel position (x, y) and gray value information c of the result image. q-1 ,...,c1,c0.

[0144] An electronic device comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of any one of the above methods when executing the program.

[0145] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of any of the above methods.

[0146] Based on the given 4×4 original image, the present invention performs bottom hat transformation segmentation and top hat transformation segmentation to demonstrate the feasibility of the algorithm. In order to reduce the running time of the circuit, the present invention only measures the required quantum bits, that is, the grayscale value information and position information of the image. Figure 12 and Figure 14 is the probability histogram of the result image, where the horizontal axis is the measured quantum bit sequence and the vertical axis is the probability of each quantum bit sequence. In order from top to bottom, the third quantum bit is the grayscale value (0 or 1) of the pixel in the result image, and the next four quantum bits are the corresponding positions YX. The remaining quantum bits are used to form a complete circuit and do not need to pay attention to the results. Figure 13 and Figure 15 As shown in the figure, it can be seen that the algorithm of the present invention can accurately realize the function of grayscale morphological segmentation.

[0147] Analyze the performance of the method proposed in the present invention:

[0148] In quantum image processing, the complexity of the algorithm is determined by the basic quantum logic gates used in the circuit. Single-qubit gates and double-qubit gates can form quantum logic gates of arbitrary complexity. Therefore, this paper uses the number of single / double quantum logic gates to calculate the complexity of the circuit, assuming that its complexity is unit 1. Therefore, the quantum cost of a NOT gate, a reset gate, or a CNOT gate is 1. A Toffoli gate can be composed of 5 double-qubit gates, so its complexity is 5. n ×2 n , the grayscale value is [0,2 q -1] as an example, the present invention will discuss the complexity of the circuit in four steps.

[0149] In the research of quantum image processing, the present invention processes quantum images. However, since they cannot be directly obtained at this stage, it is necessary to prepare digital images into quantum images. Therefore, the complexity of the process of preparing quantum images is not included in the complexity of the quantum image processing algorithm. Therefore, the complexity of this stage is considered to be 0 in the present invention.

[0150] When the quantum image is cyclically shifted, the present invention needs to use the CT operation to prepare the quantum image set. The complexity of this operation is O(n 2 ); In addition, the present invention also requires a Copy operation (q CNOT gates) to copy the original image to the auxiliary quantum bit for standby use, and the complexity of this operation is O(q).

[0151] The quantum operations used for bottom-hat or top-hat transformation of an image are roughly the same, including a copy operation, a dilation operation, an erosion operation, and a subtraction operation. The dilation or erosion operation includes a circular shift operation, 4 QCL (QCS) operations, q reset operations, and 1 copy operation (CNOT gate group). The complexity of a QCL or QCS is O(q), and the complexity of the reset operation and 1 copy operation is also O(q). Therefore, the complexity of the dilation or erosion operation is O(n 2 +q+4q+q+q)=O(n 2 +q) The complexity of the subtractor operation is also O(q). Therefore, the complexity of the bottom hat transform or top hat transform is O(q+n 2 +q+n 2 +q+q)=O(n 2 +q). QCS operation is as follows Figure 2 As shown, the QCL operation is as Figure 3 As shown, the expansion operation is as Figure 4 As shown, the corrosion operation is as Figure 5 shown.

[0152] The quantum binarization circuit consists of a quantum comparator, two CNOT gates, a reset gate, and two Toffoli gates. In addition, q NOT gates are required to set the threshold. The complexity of a quantum comparator is O(q), so the overall complexity of this part is O(q + 2 + 1 + 10 + q) = O(q).

[0153] According to the above complexity analysis, the present invention can know that the complexity of the quantum image processing algorithm circuit based on grayscale morphology is O(q+n 2 +q+q)=O(n 2 +q). Classic grayscale morphological image segmentation requires processing each pixel individually, so its complexity is no less than O(2 2n ), so the algorithm of the present invention can achieve exponential acceleration compared to the classical algorithm, which can better solve the real-time problem encountered by the classical algorithm.

[0154] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the steps in the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0155] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.

[0156] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.

[0157] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the technical principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.

Claims

1. A grayscale morphological quantum image segmentation method, characterized in that: include: Get the original NEQR quantum image; Perform a cyclic shift operation on the original NEQR quantum image according to the neighborhood window to obtain a quantum image set; Perform bottom-hat transformation or top-hat transformation on the quantum image set to obtain the result image; Performing a binarization operation on the result image obtained by bottom hat transformation or top hat transformation to obtain a binary image; Perform a cyclic shift operation on the original NEQR quantum image according to the neighborhood window to obtain a quantum image set, which is achieved by the following steps: Perform a cyclic shift operation on the original NEQR quantum image to obtain a quantum image set and neighborhood window pixels; Then, the QCL module is used to find the pixel with the largest grayscale among the neighborhood window pixels, and then the new neighborhood window pixels are obtained after resetting the other neighborhood window pixels. The maximum grayscale value of the pixels in the new neighborhood window is copied to the original NEQR quantum image using a copy operation to obtain the original image; Perform bottom-hat transformation or top-hat transformation on the quantum image set to obtain the resulting image, including: The bottom hat transformation of the quantum image set is achieved by the following steps: If the original image is an image of a dark object against a bright background, dilation and erosion operations are performed on the original image to obtain a second image, and then the original NEQR quantum image is subtracted from the second image to obtain a result image; The top-hat transformation of the quantum image set is achieved by the following steps: If the original image is an image of a bright object against a dark background, an erosion operation and a dilation operation are performed on the original image to obtain a fourth image, and then the fourth image is subtracted from the original NEQR quantum image to obtain a result image.

2. The grayscale morphology quantum image segmentation method according to claim 1, characterized in that: The quantum state expression of the original NEQR quantum image is: , Where, according to the NEQR model, 2n is the capacity of the quantum bit to store position information, q represents the grayscale of the pixel, Y is the vertical coordinate of the pixel in the original NEQR quantum image, X is the horizontal coordinate of the pixel in the original image, and C YX is the grayscale value of the pixel at coordinate (X, Y) in the original NEQR quantum image; I YX is the original NEQR quantum image; represents 5 auxiliary qubits, The initial state is 0.

3. The grayscale morphology quantum image segmentation method according to claim 2, characterized in that: The cyclic shift operation on the original NEQR quantum image is achieved by the following steps: Move the original NEQR quantum image up one unit to get the original NEQR quantum image : ; Shift the original NEQR quantum image one unit to the left to obtain the original NEQR quantum image : ; Move the original NEQR quantum image down one unit to get the original NEQR quantum image : ; Shift the original NEQR quantum image one unit to the right to obtain the original NEQR quantum image : ; Obtaining the quantum image set and neighborhood window pixels is achieved through the following steps: Based on the original NEQR quantum image after the cyclic shift operation, the quantum image set is obtained: ; The pixel at position (x, y) in the quantum image set is composed of the neighborhood window pixels of the structural element window of the original NEQR quantum image, thereby obtaining the neighborhood window pixels.

4. The grayscale morphology quantum image segmentation method according to claim 1, characterized in that: In the bottom hat transformation, the original image is dilated and eroded to obtain a second image, which is then subtracted from the original NEQR quantum image to obtain the resulting image. This is achieved by the following steps: Performing a dilation operation on the original image to obtain a first image; preprocessing the first image; Performing an erosion operation on the preprocessed first image to obtain a second image; The original NEQR quantum image is subtracted from the second image to obtain a result image; Preprocessing the first image includes: The first image is processed using a circular shift operation and a copy operation.

5. The grayscale morphology quantum image segmentation method according to claim 1, characterized in that: In the top-hat transformation, the original image is eroded and expanded to obtain a fourth image, which is then subtracted from the original NEQR quantum image to obtain the resulting image. This is achieved by the following steps: Performing a dilation operation on the original image to obtain a third image; preprocessing the third image; performing an erosion operation on the preprocessed third image to obtain a fourth image; The fourth image is subtracted from the original NEQR quantum image to obtain a result image; Preprocessing the third image includes: The third image is processed using a circular shift operation and a copy operation.

6. The grayscale morphology quantum image segmentation method according to claim 1, characterized in that: The result image obtained by bottom hat transformation or top hat transformation is binarized to obtain a binary image, which is achieved by the following steps: Transform the resulting image using grayscale morphology; The quantum comparator QC is used to compare the result image after grayscale morphological transformation with the set grayscale value threshold, and the grayscale values ​​of the pixels of the result image greater than or equal to the grayscale value threshold are converted to 1, and the grayscale values ​​of the pixels of the result image less than the grayscale value threshold are converted to 0; When the quantum comparator QC outputs the result y=0 and the lowest bit c0 of the grayscale binary representation is 0, the CNOT gate and Toffoli gate are used to set c0 to 1; When the quantum comparator QC outputs the result y=1 and c0=1, the CNOT gate and Toffoli gate are used to set c0 to 0, and finally a binary image is obtained. The binary image contains the pixel position (x, y) and grayscale value information c of the result image. q-1 ,...,c1,c0.

7. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the steps of the method according to any one of claims 1 to 6 are implemented.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.