arXiv:2610.33107cs.AROct 2026Cited by 2 papers on PaperVantage

Manuscript Offprint

arXiv:2610.33107

Fast Path, Exact Path: One Library of Hardwired Operators for Streaming and Exact Canny Edge Detection on a Low-Cost FPGA

Raj Mali

Raj Mali

Independent Researcher

raj.mali.research@gmail.com

ORCID: 0009-0001-6351-0062

Abstract—Hysteresis edge tracking, the final stage of Canny edge detection, follows edge chains of unbounded length and therefore resists single-pass streaming; FPGA designs either approximate it or dedicate separate labelling hardware to it. We show that a single library of hardwired 3×33 \times 3 operators, each with an identical two-clock latency, delivers both a camera-rate approximation and exact hysteresis on a low-cost Artix-7 (XC7A35T). The fast path streams camera pixels through the operators and K local hysteresis stages and commits each edge decision 262.15–720.63 μ\mus after the pixel arrives ( K=1–8K = 1–8; system simulation with a datasheet camera model), that is, 3+K3 + K camera lines later and 46–127×46–127 \times sooner than a frame-based processor can even begin at 30 frames per second. It provably never reports an edge that exact hysteresis rejects, recovers 76.6–96.1 % of exact edges at thresholds 20/40, and on the 200 BSDS500 test images retains at least 98.6 % of the exact path's boundary F-measure (ODS 0.470–0.477 versus 0.476). The exact path holds 128×128128 \times 128 tiles in block RAM, is exact within each tile, and replaces two-buffer iteration with in-place forward and reverse sweeps built into the same operator. This reduces hysteresis from 38–82 passes to 3–7 on pattern and photo tiles, accelerating the hysteresis step 6.6–21.7×(40×6.6–21.7 \times (40 \times on a worst-case tile) and a complete tile 4.5–9.9×4.5–9.9 \times, with identical output. Both paths are bit-exact with software golden models at every pipeline stage and close timing at 50 MHz in at most 1455 LUTs. An optimised multi-core CPU remains faster on stored images, but it cannot begin until the frame is complete.

Index Terms—FPGA, Canny edge detection, hysteresis thresholding, streaming architecture, bit-exact verification

I. INTRODUCTION

Edge detection is the entry point of many vision systems, from inspection lines to robotic grasping, and Canny's detector [1] remains the reference because it yields thin, connected edges with few false responses. In embedded and industrial settings, however, the decisive figure is often not throughput but latency: when a decision becomes available, and how predictably.

Four of Canny's five stages, namely Gaussian smoothing, Sobel gradients [2], non-maximum suppression (NMS) and double thresholding, are local 3×33 \times 3 operations that map naturally onto a line-buffered FPGA pipeline. The fifth, hysteresis, is not: a weak pixel is an edge only if a chain of weak pixels links it to a strong one, however long that chain. Software follows chains with a stack [3], [4], which presupposes random access. FPGA designs therefore settle for one of three compromises. They approximate hysteresis within a fixed window, which is fast but inexact; they add a connected-component labelling unit, which is exact but separate hardware [5], [6]; or they store the frame and iterate a local rule to convergence, which is exact and reuses the local operator but is slow, because a chain grows by only one pixel per full-frame pass (up to 82 passes on a 128×128128 \times 128 photo tile in our design).

CPU comparisons demand equal rigour, since weak baselines have inflated many reported speed-ups [7]. An optimised library on a modern CPU processes a stored 480×720480 \times 720 frame in 0.603 ms (Section V-F), which no one-pixel-per-clock pipeline at 50 MHz can match. The FPGA's advantage lies elsewhere: it can decide before the frame is complete, at a latency fixed by its structure.

We argue that speed and exactness need not be engineered separately. A single library of hardwired operators serves two architectures: a fast path that decides within a few image lines and never adds a false edge, and an exact path that completes the weak chains the fast path may miss. A system can act on the fast answer and refine it with the exact one, much as fast reflexes and slower deliberate processing coexist in nervous systems. Our contributions are:

  1. A library of 3×33 \times 3 Canny operators with a common two-clock latency that serves, unchanged except for one feedback-enable input, both a streaming fast path and a frame-buffered exact path (Fig. 1, Section III).

  2. In-place forward/reverse hysteresis sweeps, a known technique for morphological reconstruction [8], built into the shared operator through a one-clock left-neighbour feedback and a row-above write-back into the window's line buffer. The output is identical to two-buffer iteration, while the hysteresis step runs 6.6–21.7×6.6–21.7 \times faster on photo and pattern tiles (Section III-C).

  3. A verification methodology in which every pipeline stage of both paths is compared byte for byte with bit-exact software models in RTL simulation, and on hardware for the exact path (Section IV).

  4. Measurements of fast-path latency and accuracy as functions of K, including boundary accuracy on BSDS500, and a fair CPU comparison that reports where the CPU wins (Section V).

II. BACKGROUND AND RELATED WORK

Hysteresis in software. Canny's hysteresis retains a weak pixel only if it is 8-connected through weak pixels to a strong one [1]. OpenCV traces chains from each strong pixel with a stack, visiting each pixel roughly once [3], and a patent application describes the same seed-and-stack scheme [4]. The random access this requires suits a CPU, not a raster-order pipeline.

Canny on FPGAs. Early FPGA implementations stream the local stages through line buffers [9]. Xu et al. partition the frame into blocks processed in parallel with block-adaptive thresholds [10], and recent designs on low-cost devices report video-rate operation with modified Canny variants [11]. Other implementations parallelise the pipeline for real-time operation [12], reduce its hardware cost [13], adapt the Canny parameters to the estimated noise level [14], or combine edge and corner detection at several resolutions [15]. Stencil compilers such as Darkroom [16] and vendor libraries such as Vitis Vision [17] generate line-buffered pipelines automatically, and fully pipelined, line-buffered processing at one pixel per clock with deterministic latency also underlies recent low-latency line-segment detectors [18]. In streaming designs, hysteresis is typically omitted or confined to a local window.

Exact hysteresis in hardware. Hysteresis can be made exact in a single raster pass by recasting it as connected-component analysis: edge pixels receive provisional labels, equivalent labels are merged, and a component is retained if it contains a strong pixel [5], [6], building on single-pass connected-component architectures for FPGAs [19], which now label 4K video streams in real time [20]. These designs are exact and fast, but their label and equivalence storage and merge logic stand apart from the local operators of the rest of the pipeline. A recent HLS design follows chains with an explicit stack, as software does, at the cost of a large share of the block RAM [21].

Raster-scan propagation. Rosenfeld and Pfaltz showed that alternating forward and backward raster sweeps, in which each pixel sees values already updated within the same sweep, propagate information across an image in a few passes [22]; the idea underlies distance transforms and multipass connected-component labelling. Hysteresis is a binary morphological reconstruction (the weak mask reconstructed from the strong seeds), and Vincent's sequential reconstruction algorithm computes reconstruction with precisely such alternating raster and anti-raster sweeps [8]. Anacona-Mosquera et al. implemented sequential and hybrid grey-level reconstruction in FPGA hardware, running the anti-raster sweep through the same module with the pixel order reversed [23], [24]. We do not claim the sweeps themselves. Our contribution is how they are realised for Canny: inside the same two-clock 3×33 \times 3 hysteresis operator as the rest of the library, with a one-clock left-neighbour feedback and decisions written back into the window's row-above line buffer, so that each pass is a single streaming pass requiring no memory beyond the existing frame buffers.

Fair comparison. Following [7], [25], [26], our CPU baseline includes both an optimised multi-threaded library and a single-threaded port of our own algorithm, and we report the cases in which the CPU is faster.

Table I situates both paths among these approaches. None dominates on every criterion; our point is that the last three rows, two of them new, are all built from one set of operators.

TABLE I WAYS TO IMPLEMENT CANNY HYSTERESIS ON AN FPGA. PASS COUNTS ARE FOR OUR 128×128128 \times 128 PATTERN AND PHOTO TILES (TABLE II).

ApproachExactExtra hardwarePasses
Local window [9]noline buffers1, streaming
Labelling [5], [6]yeslabel tables, merge logic1
Two-buffer (baseline)yes2 frame buffers38–82
In-place (ours)yes2 frame buffers + 2 feedbacks3–7
Fast path (ours)no†^{\dagger}1 line buffer per stage1, streaming

†^{\dagger} Never reports a false edge (Proposition 2).

References (29)