HTML conversions sometimes display errors due to content that did not convert correctly from the source. This paper uses the following packages that are not yet supported by the HTML conversion tool. Feedback on these issues are not necessary; they are known and are being worked on.
failed: newunicodechar
Authors: achieve the best HTML results from your LaTeX submissions by following these best practices.
License: CC BY 4.0
arXiv:2404.06889v1 [quant-ph] 10 Apr 2024
Edge Detection Quantumized: A Novel Quantum Algorithm for Image Processing
Syed Emad Uddin Shubha
Department of Electrical and Computer Engineering, North South University, Bashundhara, Dhaka
Mir Muzahedul Islam
Department of Electrical and Computer Engineering, North South University, Bashundhara, Dhaka
Tanvir Ahahmed Sadi
Department of Electrical and Computer Engineering, North South University, Bashundhara, Dhaka
Md. Hasibul Hasan Miraz
Department of Electrical and Computer Engineering, North South University, Bashundhara, Dhaka
M.R.C. Mahdy
Department of Electrical and Computer Engineering, North South University, Bashundhara, Dhaka
Abstract
Quantum image processing is a research field that explores the use of quantum computing and algorithms for image processing tasks such as image encoding and edge detection. Although classical edge detection algorithms perform reasonably well and are quite efficient, they become outright slower when it comes to large datasets with high-resolution images. Quantum computing promises to deliver a significant performance boost and breakthroughs in various sectors. Quantum Hadamard Edge Detection (QHED) algorithm, for example, works at constant time complexity, and thus detects edges much faster than any classical algorithm. However, the original QHED algorithm is designed for Quantum Probability Image Encoding (QPIE) and mainly works for binary images. This paper presents a novel protocol by combining the Flexible Representation of Quantum Images (FRQI) encoding and a modified QHED algorithm. An improved edge outline method has been proposed in this work resulting in a better object outline output and more accurate edge detection than the traditional QHED algorithm.
In modern technology, image processing is an indispensable tool, employing sophisticated algorithms to extract valuable insights from visual data. Its applications are vast and diverse, spanning fields such as image segmentation, enhancement, computer vision, recognition, and medical imaging. With the emergence of quantum image processing algorithms, significant strides have been made in critical operations like edge detection and beyond [1, 2].
Quantum computers have the prospect of revolutionizing many fields by solving problems that are currently computationally expensive. The development of quantum computers is a rapidly advancing field of research and potential applications of quantum computers are currently being investigated. Quantum Image Processing shows a promising aptness by utilizing quantum superposition and entanglement as a powerful resource [3, 4, 5]. Converting image data into a quantum state, we can perform a wide range of linear operations, [6, 7, 8], thus transforming and processing images for various applications. There are many Quantum Image Representation techniques, such as Flexible Representation of Quantum Images (FRQI), Quantum Probability Image Encoding (QPIE), and Novel Enhanced Quantum Representation (NEQR), offering efficient pathways for translating pixel information into quantum data. Among these two methods, the FRQI method uses angle encoding, which requires fewer qubits [9, 10]. The QPIE method requires one qubit less than FRQI. The NEQR method, on the other hand, requires a much higher number of qubits. [11, 12].
Edge detection, a cornerstone of image analysis and feature extraction, assumes paramount importance across a multitude of applications, ranging from fingerprint recognition to medical imaging. While classical edge detection algorithms, such as, Sobel, Laplacian, Prewitt, and Canny, have proven effective in many scenarios, they encounter significant scalability challenges when dealing with larger images, owing to the increased computational demands [13, 14, 15, 16].
The emergence of quantum algorithms for edge detection presents a promising avenue for overcoming these challenges. Leveraging the inherent parallelism of quantum computation, these algorithms enable the simultaneous processing of multiple pixels, thereby reducing the overall time complexity. Among these pioneering algorithms, Quantum Hadamard Edge Detection (QHED) stands out for its constant time complexity and memory efficiency [17, 18]. However, despite its inherent advantages, QHED’s effectiveness diminishes when confronted with real-world images, exhibiting inaccuracies and noise due to its reliance on binary image bases.
In response to these challenges, this paper proposes a series of innovative modifications to enhance QHED’s accuracy and efficiency. At first, we used the angle encoding (FRQI) method to convert a classical image into a quantum state, followed by a partial measurement. After that, we reset the existing qubit and use it as a resource to implement traditional QHED with an additional qubit method. Then a classical post processing has been applied to generate an edge-detected output image. We have also analyzed the procedure from an information-theoretic perspective. We have designed the protocol to encompass the development of a versatile quantum circuit adaptable to diverse image inputs, refinement of object outline methodologies to improve precision in representation, and significant enhancements in edge detection for complex images through a combination of classical and quantum modifications applied to existing QHED algorithms. Through these endeavors, we seek to push the boundaries of quantum image processing, paving the way for more effective and robust edge detection methodologies in both theory and practice. Fig. 1 shows our proposed protocol and Fig. 2 gives a comprehensive overview of our improved protocol over traditional QHED.
Figure 1: System Diagram of the Proposed ModelFigure 2: Comparison between Traditional QHED and Proposed Model.
2 Preliminary Concepts
2.1 Quantum Image Processing
An image is given by a matrix . If the image is a grey-scale image, then represents the pixel value of row and column. If the image is a color image, then we have , representing the RGB values of a pixel, typically these values are 8 bits each, thus having a value between to . Some images have an additional component, named channel.
Classically image processing can be given by the Map , where .
In quantum image processing, We first need to encode the image into a quantum state called Quantum Image Representation. The state is represented by a normalized column vector that encodes color and position information. There are several ways to encode an image, for example, in Novel Enhanced Quantum Representation (NEQR), a grey scale image is represented as [19, 20]
(1)
Here, encodes pixel information, where and for grey scale image.
Now quantum image processing can be described by linear quantum operations, given by:
(2)
Here . We call Kraus Operators, and the map represents a completely positive trace-preserving map, and is called a density operator.
2.2 Flexible Representation of Quantum Images
The Flexible Representation of Quantum Images encodes the pixel data in angles, which requires only one qubit to store pixel information, rest of the qubits stores position information.
Given , the FRQI state is given by,
(3)
We can transform into FRQI state, by applying unitary operator , with and . where is a unitary matrix named controlled rotation, given by
(4)
We can implement the controlled rotation ’s using (controlled ) and gate. Here,
(5)
We can convert into by applying NOT gates on the left and right sides. For example, in case of grey image, we see, , and
(6)
Therefore controlled rotations can be implemented by
and NOT operations.
Basically, applying in the both side of to make the conversion:
(7)
Here is the tensor product of some and , which is a hermitian. Fig. 1 refers to the circuit of the FRQI method for an arbitrary color image.
Say, one colored pixel has the RGB values , then we encode the information as follows:
(8)
The advantage is, given , it is easier to get correspondent by expressing as base number. Fig. 3 refers to a circuit implementation of a image.
Figure 3: FRQI Encoding circuit for a sample color image.
2.3 Quantum Hadamard Edge Detection
QHED edge detection algorithm is based on QPIE image representation. QPIE will convert digital image information into a quantum state.
To begin with, the images are represented as normalized probability amplitude corresponding to a specific quantum state. Given an image , it can be expressed as
(9)
To build the QHED circuit an additional qubit is required. This will help to calculate all the pixel differences at once. At first, the image information is initialized to the N number of data qubits using the QPIE technique. Then, the Hadamard gate is applied to the auxiliary qubit. Finally, we have the following state that encodes the image:
(10)
After that, we performed an amplitude permutation unitary operation to shift down the element of the state vector, by one row. This operation will simultaneously facilitate the gradient calculation for both even and odd pixel pairs.
The expression of and its operation on the image is given in Eqn. (11) and (12) respectively.
(11)
(12)
After the above operation, an H-gate is applied to the auxiliary qubit. The resultant state would be,
(13)
The quantum circuit of the QHED algorithm for a binary image is shown in Fig. 4.
Figure 4: Quantum Circuit of QHED Algorithm.
Edge detection is the process of detecting the edge of an object from a picture based on dissimilarity of color intensity. The discontinuation can be measured from the difference between two neighbor pixels. If we measured the auxiliary qubit being in state |1⟩ then the necessary information for edge detection can be retrieved. The whole procedure carries out a horizontal scan to detect edges in the horizontal direction. For vertical scan, the image is transposed and the above operations are repeated. Finally, the horizontal and vertical scan outputs are superimposed into one another using classical post-processing for the final edge detected output.
3 Proposed Edge Detection Algorithm
In this paper, we have modified the edge outline of an object by analyzing the relative edge detection order and imposing a hyperparameter to filter out the noise. We have also modified the encoding part using FRQI and partial measurement. In this section, let’s assume we have an image with size .
3.1 Proposed Encoding Method
Suppose we have two grey-scale images, Image and Image, such that ().
Since , this map is a bijection with smooth behavior, that preserves the edge information, as shown in Fig. 5:
Figure 5: (a) image , (b) image . We note that the map doesn’t change the edges.
Now, say, . Therefore the QPIE representations of Images 1 and 2 are given by,
(14)
(15)
Now in our proposed protocol, we first encode our image using FRQI, given by Eq. (3). Say, the pixel information is stored at ancilla qubit, which will now be measured in the Z-basis, i.e., the Krauss Operators are given by, . The collapsed state will be given by either Eq. (14) or Eq. (15), depending on the measurement outcome. Since both collapsed state resembles the same edge, we will now apply the QHED algorithm with the additional qubit. The modified algorithm is shown in the diagram below:
Figure 6: System Diagram of Modified Algorithm.
3.2 Edge Detection Improvement
The ancilla qubit will be measured at state or , we will put an gate if the first case happens. After that a Hadamard gate will be applied to the ancilla qubit, that is how the state of the ancilla qubit will now be in to apply conventional QHED. QHED process compares two neighbor pixels, and based on their dissimilarity, it plots the edge. The edge detection operation occurs based on the superimposed scan results of left-to-right and top-to-bottom scans. One of the issues with QHED edge detection is that, it does not consider object boundaries. If there is a difference in color intensity between the current and the next pixel, QHED portrays an edge in the current pixel. QHED defines the edges inside an object boundary and does not wrap around the object. As a consequence, the resultant object outline is ambiguous and does not represent the actual object and shape correctly. We considered the object’s exact position to address this complication and analyzed the pixel gradient result. The edge outline around the object borders are then portrayed according to these findings.
Comparison of edge detection between traditional approach (middle column) and modified approach (far right column) for input image (far left column). It is evident the conventional approach does not capture the object outline correctly, and the actual object retrieval might not be easy. In comparison, our proposed model outlines the object accurately. The main QHED algorithm cannot detect all the edges properly for complex images and produces a lot of noise, while our modified approach can reduce noise using a dynamic threshold. In Fig. 7,8 & 9, we have demonstrated how our edge detection algorithm provides better visualization.
Figure 7: Scanning result difference between traditional QHED and the proposed method.Figure 8: Comparison of edge detection between traditional approach (middle column) and modified approach (far right column) for input image (far left column). It is evident the traditional approach does not capture the object outline correctly and the actual object retrieval might not be easy. Whereas our proposed model outlines the object accurately.Figure 9: Comparison of edge detection output. The middle column represents the conventional QHED implementation result, and the improved implementation of QHED is shown in the far-right column.
Threshold has been used to remove noise in grey-scale images and improve the edge outline. For any image, if the represented state is given by , we define the threshold as:
(16)
In the post-processing, we will generate a binary image, if the difference is greater than the threshold of the main picture, we will call it an edge. If the sign of difference is mismatched with the first edge, the edge will be shifted one pizel either in the vertical or horizontal direction based on scanning order. Lastly, noises will be removed if the pixel difference is less than . Thus the post-processing gives us an improved edge outline without noise.
3.3 Quantum Thermodynamics Perspective
When we partially measure the state given by Eq. (3), we have either collapsed the state in Eq.(14) or Eq. (15). We note that, even if we were to use Eq. (8) to preserve the color information, the measurement will make the state into the representation of a grey-scale image. We can easily note that by observing the fact that, for , the set is independent but is not. Hence, it can be said that grey-scale representation loses some information, we can produce the state by partially measuring the color-encoded state, i.e., measuring the pixel qubit. The Edge detection overall means losing some information but kee** the edge outline invariant. This also will be examined thoroughly in the next version of this work.
4 Conclusion
In this paper, we provided a generalized implementation scheme for NEQR and FRQI algorithms. We also have addressed the shortcomings of the QHED algorithm and proposed a modified version of QHED. Traditional QHED does not work for all input images, and it struggles with complex images. Our modified algorithm allowed the encoding and edge-detecting circuits to work with various types of complex images. We implemented a dynamic circuit for the input image, fixed the edge outline, and, most importantly, adjusted the threshold value to remove unnecessary noise. Overall, our project has significantly improved the QHED algorithm, making it a more efficient and accurate method for edge detection in quantum image processing. The changes we have made will allow the QHED algorithm to be applied to a broader range of images and provide more accurate results. We have also used the FRQI method, along with a partial measurement, to replace the QPIE method. This inclusion makes our model a more novel and physics-oriented approach.
Acknowledgment
The authors would like to thank Research Assistants Deponker Sarkar Depto and Md Shawmoon from the NSU Optics Lab for their constructive suggestions and technical help, respectively. M.R.C. Mahdy acknowledges the support of NSU CTRGC grant 2023-24 (approved by the members of BOT) and NSU internal grant.
References
[1]
Junfeng **g, Shenjuan Liu, Gang Wang, Weichuan Zhang, and Changming Sun.
Recent advances on image edge detection: A comprehensive review.
Neurocomputing, 503:259–271, 2022.
[2]
Zhaobin Wang, Minzhe Xu, and Yaonan Zhang.
Review of quantum image processing.
Archives of Computational Methods in Engineering, 29(2):737–761, 2022.
[3]
Quantum image processing on real superconducting and trapped-ion based quantum computers.
Tm-technisches Messen, 2023.
[4]
Yongquan Cai, Xiaowei Lu, and Nan Jiang.
A survey on quantum image processing.
Chinese Journal of Electronics, 27(4):718–727, 2018.
[5]
Andrei N Soklakov and Rüdiger Schack.
Efficient state preparation for a register of quantum bits.
Physical review A, 73(1):012307, 2006.
[6]Novel Design of Quantum Circuits for Representation of Grayscale Images.
2023.
[7]
An improved order-encoded quantum image representation model and its application.
International Journal of Quantum Information, 2023.
[8]
Yue Ruan, Hanwu Chen, Jianing Tan, and Xi Li.
Quantum computation for large-scale image classification.
Quantum Information Processing, 15:4049–4069, 2016.
[9]
Quang Phuc Le, Dong Fangyang, Arai Yoshinori, and Hirota Kaoru.
Flexible representation of quantum images and its computational complexity analysis.
In Proceedings of the 25th Fuzzy Systems Symposium of the Japanese Society for Fuzzy Theory and Intelligent Information, pages 185–185. Japanese Society for Fuzzy Theory and Intelligent Information, 2009.
[10]
Phuc Q Le, Fangyan Dong, and Kaoru Hirota.
A flexible representation of quantum images for polynomial preparation, image compression, and processing operations.
Quantum Information Processing, 10:63–84, 2011.
[11]
Quantum image processing algorithm using line detection mask based on neqr.
Entropy, 2023.
[12]
An evolutionary quantum scrambling scheme for medical image with neqr representation.
International Journal of Computing and Digital Systems, 2023.
[13]
Quantum-inspired edge detection algorithms implementation using new dynamic visual data representation and short-length convolution computation.
arXiv.org, 2022.
[14]
Rajib Chetia, S. M. B. Boruah, and P. P. Sahu.
Quantum image edge detection using improved sobel mask based on neqr.
Quantum Information Processing, 20:1–25, 2021.
[15]
Pengao Xu, Zhenxing He, Tianhui Qiu, and Hongyang Ma.
Quantum image processing algorithm using edge extraction based on kirsch operator.
Optics express, 28 9:12508–12517, 2020.
[16]
Ri gui Zhou, Han Yu, Yu Cheng, and Feng-Xin Li.
Quantum image edge extraction based on improved Prewitt operator.
Quantum Information Processing, 18, 2019.
[17]
Analisis deteksi tepi citra dengan quantum hadamard edge detection (qhed).
Techno.COM Jurnal, 2022.
[18]
Xi-Wei Yao, Hengyan Wang, Zeyang Liao, Ming-Cheng Chen, Jian Pan, Jun Li, Kechao Zhang, Xingcheng Lin, Zhehui Wang, Zhihuang Luo, et al.
Quantum image processing and its application to edge detection: theory and experiment.
Physical Review X, 7(3):031041, 2017.
[19]
Yi Zhang, Kai Lu, Yinghui Gao, and Mo Wang.
Neqr: a novel enhanced quantum representation of digital images.
Quantum information processing, 12:2833–2860, 2013.
[20]
Realization of quantum mean filters with different sized on neqr quantum images by qft based operations.
International Journal of Information Security Science, 2023.