Manuscript Offprint

arXiv:2610.37297

TRUCO: A Scalable Lock-Free Algorithm for Parallel Contour Extraction

Rafael Munoz-Salinas, Francisco J. Romero-Ramirez, Manuel J. Marin-Jimenez

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

Transforming binary masks into geometric contours remains a critical step in many computer vision pipelines, particularly for post-processing high-resolution segmentation outputs. Yet, standard algorithms such as the Suzuki-Abe method are limited by their sequential nature and the overhead of building topological hierarchies. As modern applications transition to high-resolution imaging, there is a critical need for contour extraction that leverages multi-core CPU architectures without the complexity of tile stitching or heavy synchronization.

This paper presents TRUCO (Threaded Raster Unrestricted Contour Ownership), a lock-free parallel algorithm designed for high-performance geometric boundary extraction. TRUCO introduces a start-point ownership rule, combined with a speculative tracing model, in which threads trace contours downward into adjacent regions and use an upward-termination logic to ensure each contour is processed exactly once.

Experimental results on synthetic and real-world datasets, conducted on both consumer and server-grade CPUs, demonstrate that TRUCO significantly outperforms existing baselines. The method achieves speedups of over an order of magnitude compared to the industry standard while maintaining robust scalability on high-resolution scenes across diverse hardware architectures.

Keywords: Contour Tracing, Parallel Algorithms, Suzuki-Abe, Image Processing, High-Performance Computing

1. Introduction

Binary image contour extraction is a fundamental prerequisite for a wide array of computer vision applications, ranging from shape analysis and optical character recognition (OCR) [1, 2, 3] to fiducial marker detection [4, 5] and robotic vision [6, 7]. Standard algorithms, most notably the topological structural analysis algorithm by Suzuki and Abe [8], have served as the industry standard for decades. However, the landscape of digital imaging has shifted dramatically since these algorithms were conceived. Modern applications increasingly demand the processing of high-resolution images (4K and beyond) in real time, placing significant strain on traditional serial processing pipelines.

The primary bottleneck in standard contour extraction is its sequential nature and the high computational cost of establishing topological hierarchies (i.e., determining parent-child relationships between contours). While this topological information is valuable for specific tasks, many high-performance applications require only the geometric boundaries of objects, making hierarchical computation an unnecessary overhead. Furthermore, as central processing units (CPUs) have evolved toward multi-core architectures, legacy single-threaded algorithms fail to exploit the available hardware parallelism, limiting the overall system throughput.

While the literature presents several parallel strategies to accelerate this process [9, 10, 11, 12], a significant gap remains between theoretical proposals and practical utility. Most existing parallel alternatives are either computationally complex or lack publicly available implementations, making them inaccessible in real-world scenarios. For instance, even the industry-standard OpenCV library [13] currently lacks a native parallel implementation for contour extraction.

In this paper, we present TRUCO, a high-performance parallel algorithm for contour tracing that optimizes the fundamental Suzuki-Abe method [8] for multi-core architectures. Our approach utilizes a deterministic vertical partitioning strategy governed by a unidirectional tracing constraint. By enforcing a strict start-point ownership rule, we eliminate the need for complex boundary stitching or synchronization primitives often found in tile-based approaches. Since the algorithm relies on a benign race condition model where tracing operations are idempotent—the outcome of multiple threads marking the same pixel is identical to a single thread doing so—threads can modify the shared image buffer concurrently without the need for mutexes or atomic hardware instructions. Threads are permitted to trace contours downwards into adjacent regions speculatively, but are governed by an upward termination logic: a trace must abort immediately.

*Corresponding author

Email addresses: in1musar@uco.es (Rafael Muñoz-Salinas), fj.romero@uco.es (Francisco J. Romero-Ramirez), mjmarin@uco.es (Manuel J. Marín-Jiménez)

Preprint submitted to Elsevier

October 28, 2026 if the path traverses upward into a preceding thread's domain. This mechanism ensures that every contour is extracted exactly once by the thread that contains its raster-scan entry point, effectively resolving the double-counting problem inherent in parallel processing. Consequently, TRUCO delivers a lock-free, high-throughput solution tailored for applications that require geometric boundary data, without the computational burden of constructing a topological hierarchy. Furthermore, by restricting the state space to 8-bit operations rather than the 32-bit integer labeling required by the standard Suzuki-Abe algorithm, TRUCO achieves higher SIMD throughput and reduced memory-bandwidth pressure, providing a performance advantage that is independent of thread count.

This approach specifically addresses the gap in current libraries by providing a lightweight, deterministic tracer optimized for modern multi-core architectures. The source code for TRUCO and all necessary materials to reproduce our results are publicly available 1^{1}.

The remainder of this paper is organized as follows: Section 2 reviews related works in contour extraction. Section 3 details the Suzuki-Abe algorithm, and Section 4 explains our proposal. Section 5 presents the experimental results on synthetic and real-world datasets, and finally, Section 6 presents some conclusions.

References (28)