---
title: Quantum Hadamard Edge Detection (QHED)
url: https://www.emergentmind.com/topics/quantum-hadamard-edge-detection-qhed
type: topic
---

# Quantum Hadamard Edge Detection (QHED)

Quantum Hadamard Edge Detection (QHED) is a quantum image-processing algorithm in which an image is amplitude-encoded into a quantum state and a Hadamard-based interference step transforms neighboring pixel amplitudes into sums and differences, with the difference components encoding boundary information [1801.01465]. In its canonical formulation, QHED is built on Quantum Probability Image Encoding (QPIE), uses a single-qubit Hadamard as the core edge operator, and is often presented as a constant-time quantum edge-detection primitive once the image state has already been prepared [1801.01465]. Subsequent work has refined this basic construction for grayscale and FRQI-encoded images, contrasted it with transform-domain Walsh–Hadamard alternatives, and adapted it to NISQ-oriented decompositions for large medical images [2404.06889], [2507.06642], [2507.10939].

## 1. Origins and formal definition

QHED was explicitly introduced as a “quantum Hadamard edge detection (QHED) algorithm” in the framework of quantum image processing based on amplitude encoding [1801.01465]. The original formulation represents an image as an \(n\)-qubit pure state
\[
|f\rangle = \sum_{k=0}^{2^n-1} c_k |k\rangle,
\]
where the computational basis labels pixel positions and the amplitudes \(c_k\) encode normalized pixel values [1801.01465]. The defining idea is to choose a qubit whose binary value distinguishes neighboring pixels and then apply a Hadamard gate to that qubit so that each amplitude pair \((a,b)\) is mapped to \((a+b,a-b)/\sqrt{2}\) [1801.01465].

In the original construction, the global edge operator is
\[
U_{\text{edge}} = I_{2^{n-1}} \otimes H,
\]
with the Hadamard applied to the last qubit of the image register [1801.01465]. Acting on the amplitude vector, this gives
\[
\begin{bmatrix}
c_0\\
c_1\\
c_2\\
c_3\\
\vdots\\
c_{N-2}\\
c_{N-1}
\end{bmatrix}
\mapsto
\frac{1}{\sqrt{2}}
\begin{bmatrix}
c_0 + c_1\\
c_0 - c_1\\
c_2 + c_3\\
c_2 - c_3\\
\vdots\\
c_{N-2} + c_{N-1}\\
c_{N-2} - c_{N-1}
\end{bmatrix},
\quad N=2^n.
\]
The amplitudes associated with the targeted qubit in state \(|1\rangle\) therefore encode neighboring-pixel differences, which are interpreted as edges [1801.01465].

The original paper framed this as a global edge detector acting on the entire image state in parallel and stated that the task can be completed with “only one single-qubit operation, independent of the size of the image” for the core edge-detection step [1801.01465]. A later review and extension characterized QHED in the same terms: QPIE input, an auxiliary qubit, a Hadamard-permutation-Hadamard pattern, and difference amplitudes interpreted as discrete gradients [2404.06889].

## 2. Image encoding and circuit mechanics

The canonical encoding used by QHED is QPIE. For a classical image \(F=(F_{i,j})\), the original work forms the column-stacked vector
\[
\vec f = \mathrm{vec}(F) = (F_{1,1},F_{2,1},\dots,F_{M,1},F_{1,2},\dots,F_{M,L})^T
\]
and prepares the state
\[
|f\rangle = \sum_{k=0}^{2^n-1} c_k |k\rangle,\qquad
c_k = \frac{F_{i,j}}{\sqrt{\sum_{i,j}F_{i,j}^2}}
\]
for \(k<ML\), with zero padding when \(2^n>ML\) [1801.01465]. This encoding is qubit-efficient because pixel intensities are stored directly in amplitudes rather than in a separate value register [1801.01465].

A widely cited ancilla-assisted QHED construction appends a redundant least-significant qubit initialized in \(|0\rangle\), giving
\[
|\psi_0\rangle = |f\rangle \otimes |0\rangle.
\]
A Hadamard on that qubit yields a duplicated amplitude pattern,
\[
|\psi_1\rangle
=
|f\rangle \otimes |+\rangle
=
\frac{1}{\sqrt{2}}
\begin{bmatrix}
c_0\\
c_0\\
c_1\\
c_1\\
\vdots
\end{bmatrix},
\]
after which a decrement permutation \(D_{2^{n+1}}\) cyclically shifts amplitudes, and a second Hadamard maps the result to
\[
|\psi_3\rangle
=
\frac{1}{2}
\begin{bmatrix}
c_0+c_1\\
c_0-c_1\\
c_1+c_2\\
c_1-c_2\\
\vdots\\
c_{2^n-1}-c_0
\end{bmatrix},
\]
so that odd-indexed basis states encode \(c_i-c_{i+1}\) [2507.10939]. A closely related account describes the same sequence as: auxiliary Hadamard, amplitude permutation \(D_{2^{n+1}}\), second Hadamard, then conditioning on the auxiliary outcome that carries the differences [2404.06889].

The decrement operator is written as a cyclic-shift permutation matrix,
\[
D_{2^{n+1}}=
\begin{bmatrix}
0 & 1 & 0 & \cdots & 0 & 0\\
0 & 0 & 1 & \cdots & 0 & 0\\
0 & 0 & 0 & \cdots & 0 & 0\\
\vdots & \vdots & \vdots & \ddots & \vdots & \vdots\\
0 & 0 & 0 & \cdots & 0 & 1\\
1 & 0 & 0 & \cdots & 0 & 0
\end{bmatrix},
\]
and is the core nontrivial permutation primitive in ancilla-based QHED descriptions [2404.06889], [2507.10939].

## 3. Boundary extraction, orientation, and full-edge variants

The simplest Hadamard-only form of QHED produces differences for neighboring pairs \((0,1),(2,3),\dots\) [1801.01465]. To recover complementary pairs such as \((1,2),(3,4),\dots\), the original work described two strategies [1801.01465].

The first strategy uses a quantum amplitude permutation \(P\) that shifts amplitudes so that odd and even entries are exchanged in the appropriate pattern before applying the same Hadamard edge operator again [1801.01465]. The second strategy, developed in the appendix of the original paper, introduces an auxiliary qubit and a specific amplitude permutation \(D_{2^{n+1}}\) so that after postselection on the last qubit the resulting \(n\)-qubit state is
\[
|g\rangle = \frac{1}{2}(c_0-c_1,\;c_1-c_2,\;\dots,\;c_{N-1}-c_0)^T,
\]
which encodes the full set of neighboring differences with cyclic boundary conditions [1801.01465].

Orientation is controlled by the encoding order. The original paper stated that with image encoding along different orientations, row scanning detects vertical boundaries and column scanning detects horizontal boundaries [1801.01465]. A later Walsh-domain alternative explicitly noted that its vertical–horizontal handling is “the same strategy as in QHED”: run the algorithm directly on the original matrix for vertical edges, transpose the image to obtain horizontal edges, transpose back, and combine the outputs [2507.06642]. This confirms that QHED is ordinarily understood as a directional detector whose output depends on the mapping between pixel geometry and basis ordering.

A common misconception is that the single-Hadamard description by itself yields a complete edge map. In the original formulation, full boundary extraction requires either an additional amplitude permutation step or an ancilla-based redundant encoding that captures all neighboring differences in one pass [1801.01465].

## 4. Complexity claims and their assumptions

The canonical complexity claim associated with QHED is that the core edge-detection step is \(O(1)\) in image size because the logical operator is a single-qubit Hadamard acting on an \(n\)-qubit image state [1801.01465]. The original paper contrasted this with classical gradient-based methods, which it described as requiring at least \(O(2^n)\) work because every pixel must be processed [1801.01465]. A later FRQI-based refinement reiterated that, once image preparation is treated separately and the decrement permutation is regarded as available, the edge-extraction depth remains constant in the idealized model [2404.06889].

That asymptotic statement is accompanied, in later work, by explicit caveats. A 2025 Walsh-based comparison paper stated that both QHED and its proposed alternative ignore the costs of quantum state preparation using QPIE and ancilla measurement in their complexity analyses [2507.06642]. The same paper characterized QHED’s central operation as quantum amplitude permutation with computational cost
\[
\mathcal{O}(\mathrm{poly}(n)),
\]
where \(n=\log_2(N_1N_2)\) is the number of qubits encoding the image, and therefore summarized QHED’s cost for an \(N_1\times N_2\) image as
\[
\mathcal{O}\bigl(\mathrm{poly}(\log_2(N_1N_2))\bigr)
\]
under the shared assumption that state preparation and final readout are excluded [2507.06642].

The original paper also acknowledged the readout issue: reconstructing the full edge image requires many measurements, whereas global feature testing can avoid full image reconstruction by using procedures such as a SWAP test [1801.01465]. A plausible implication is that QHED’s most defensible speedup claims arise when it is embedded inside a larger quantum pipeline and when the objective is not exhaustive classical readout. That implication is explicitly aligned with later remarks that the algorithm becomes advantageous when the input state is already the output of a preceding quantum subroutine [2507.06642].

## 5. Experimental realization and NISQ-oriented implementations

QHED was demonstrated experimentally in liquid-state NMR on a four-qubit processor using iodotrifluoroethylene, with three \(^{19}\mathrm{F}\) nuclei and one \(^{13}\mathrm{C}\) nucleus [1801.01465]. The experiment encoded a \(4\times 4\) image into a four-qubit state, prepared a pseudopure state
\[
\rho_{0000}=\epsilon |0000\rangle\langle 0000|+\frac{1-\epsilon}{16}I_{16},
\]
reported a pseudopure-state fidelity of approximately \(98.4\%\), and implemented the edge operator \(\hat U_e=I_8\otimes H\) to obtain the edge-information state \(|g_e\rangle=\hat U_e|f_e\rangle\) [1801.01465]. For the input and output image states, the reported fidelities relative to the ideal states were between \(0.972\) and \(0.981\), with normalized Euclidean distances of about \(0.06\) for the input and \(0.08\) for the output [1801.01465].

More recent work has focused less on proof-of-principle state tomography and more on hardware-aware restructuring. A 2025 medical-imaging study introduced a modified QHED, denoted QHED\(^\mathrm{M}\), with a two-level \(P\times Q\) decomposition consisting of Data-Level Decomposition into \(P\) buffered sub-images and Circuit-Level Decomposition into \(Q\) smaller cut circuits per sub-image [2507.10939]. In that work, the original decrement implemented via multi-controlled \(X\) gates was replaced by an ancilla-assisted construction using only CX and Toffoli gates after decomposition, with ancillas starting and ending in \(|0\dots 0\rangle\) [2507.10939].

Under realistic IBM FakeMumbai noise models for 5-qubit data input sizes, that decomposition and optimization strategy was reported to achieve over \(62\%\) reductions in circuit depth, approximately \(93\%\) fewer two-qubit operations, and fidelity exceeding \(95.6\%\) [2507.10939]. The same study applied the method to \(1024\times 1024\) MRI images and to a \(256\times 256\times 130\) brain MRI volume, which was decomposed into \(P=283{,}990\) buffered 5-qubit subdomains processed in a distributed D-NISQ workflow [2507.10939]. These results do not alter the logical structure of QHED, but they recast it as a decomposed, stitched primitive suitable for NISQ-era constraints.

## 6. Extensions, alternatives, and comparative developments

A major extension of QHED replaced QPIE with Flexible Representation of Quantum Images (FRQI) and then used partial measurement of the FRQI color qubit to obtain a QPIE-like grayscale state before applying a modified QHED stage [2404.06889]. In that approach, the FRQI image state is
\[
|I(\theta)\rangle =
\frac{1}{2^n}\sum_{i=0}^{4^n-1}
(\cos\theta_i|0\rangle+\sin\theta_i|1\rangle)\otimes |i\rangle,
\]
and measurement of the color qubit yields either a state proportional to \(\sum_i \cos\theta_i|i\rangle\) or one proportional to \(\sum_i \sin\theta_i|i\rangle\), both interpreted as QPIE-like grayscale images that preserve the same edge structure [2404.06889]. The measured qubit is then reset and reused as the QHED ancilla, prepared in \(|-\rangle\) via \(X\) and \(H\) gates if needed [2404.06889].

That FRQI-based work also introduced classical post-processing to improve object outlines. It defined a dynamic threshold
\[
\mathrm{thr}=\frac{\left|\max_i\{c_i-c_{i+1}\}\right|}{2n}
\]
for a \(2^n\times 2^n\) image, and proposed shifting detected edges by one pixel when the sign of a difference is inconsistent with the sign of the first edge in a scan line, thereby relocating interior detections to the object boundary [2404.06889]. Within the terms used there, the modification was presented as addressing the fact that traditional QHED can produce noisy or incomplete object outlines on grayscale images [2404.06889].

QHED has also served as a benchmark for alternative quantum edge detectors. A 2025 paper on grayscale edge detection in the sequency-ordered Walsh domain explicitly stated that QHED uses QPIE and that its central operation is quantum amplitude permutation \(D_{2^{n+1}}\), whereas the proposed method replaces that primitive with a sequency-ordered Walsh–Hadamard transform \(U_zH^{\otimes n}\) and a quantum high-pass filter [2507.06642]. That paper reported complexity
\[
\mathcal{O}(\log_2(N_1N_2))
\]
for the Walsh-based algorithm versus
\[
\mathcal{O}\bigl(\mathrm{poly}(\log_2(N_1N_2))\bigr)
\]
for QHED, and gave SSIM comparisons on \(64\times 64\) synthetic images in which the proposed method was slightly better or comparable to QHED: \(0.3791\) vs \(0.3654\) for a string image, \(0.7255\) vs \(0.7228\) for one polygon case, and \(0.6794\) vs \(0.6715\) for another [2507.06642].

A distinct line of work has pursued NISQ-friendly local alternatives rather than full-image QHED. One hybrid method based on a quantum artificial neuron explicitly cited QHED as a more efficient alternative in theory, but emphasized that larger hardware demonstrations remained limited; its own design instead used small patchwise Hadamard-and-phase circuits whose qubit count and depth do not scale with image size [2203.12072]. This suggests a bifurcation in the literature between globally encoded QHED-style methods and hybrid patchwise methods that retain some Hadamard-interference structure while abandoning whole-image amplitude encoding.

## 7. Interpretive issues and research status

The central interpretive issue around QHED is the status of its constant-time claim. In the narrow sense used by the original algorithm, the claim refers to the logical edge operator itself—one Hadamard or a short Hadamard-permutation-Hadamard sequence acting on an already prepared quantum image state [1801.01465], [2404.06889]. In broader system-level terms, later work has repeatedly emphasized that state preparation, readout, and physically realistic implementations of the permutation primitive can dominate cost and fidelity [2507.06642], [2507.10939].

Another persistent issue concerns image representation. QHED in its canonical form is tightly associated with QPIE, which is qubit-efficient but couples all intensities through global normalization [1801.01465]. FRQI-based modifications were introduced precisely to broaden applicability to grayscale and potentially color images, while Walsh-domain alternatives retained QPIE but replaced QHED’s amplitude-permutation core with transform-domain filtering [2404.06889], [2507.06642].

The research trajectory therefore presents QHED in three distinct but connected roles. First, it is an original Hadamard-interference algorithm for edge extraction from amplitude-encoded images [1801.01465]. Second, it is a modifiable template whose image representation, ancilla handling, and post-processing can be altered to improve outlines or support more general image classes [2404.06889]. Third, it is a benchmark against which newer transform-based and hardware-aware methods are evaluated, especially in terms of asymptotic cost, gate decomposition, NISQ fidelity, and scalability to real-world datasets such as MRI [2507.06642], [2507.10939].

Within quantum image processing, QHED remains the canonical example of how a single Hadamard-induced interference pattern can convert amplitude-encoded image data into neighbor-difference information. Its enduring significance lies less in any settled practical superiority than in the way it crystallizes the central promises and tensions of the field: logarithmic qubit representations, highly compressed quantum operators, and the unresolved costs of loading, extracting, and faithfully executing image-processing tasks on realistic hardware [1801.01465], [2507.10939].

Source: https://www.emergentmind.com/topics/quantum-hadamard-edge-detection-qhed