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

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

TL;DR

TRUCO is a novel, lock-free parallel algorithm that accelerates the conversion of binary masks into geometric contours by over an order of magnitude. By utilizing a "speculative tracing" model and a simplified 8-bit state space, it eliminates the need for complex synchronization or boundary stitching, making it a high-performance alternative to the decades-old Suzuki-Abe industry standard.

What Problem Does This Paper Address?

In computer vision, "contour extraction"—turning a grid of pixels into a list of geometric coordinates—is a foundational step for everything from OCR to robotic vision. For nearly 40 years, the Suzuki-Abe algorithm has been the gold standard. However, it has a major flaw for the modern era: it is inherently sequential.

As we move toward 4K and 8K imaging, traditional serial pipelines are struggling. While researchers have tried to parallelize this process before, most solutions involve "tiling" (splitting the image into blocks), which creates a new headache: "stitching" contours back together where they cross tile boundaries. Furthermore, standard libraries like OpenCV still lack a native parallel implementation for this task, leaving a significant performance gap in high-resolution real-time applications.

Methods

The authors introduce TRUCO (Threaded Raster Unrestricted Contour Ownership), which rethinks parallelization through three key innovations:

  1. Start-Point Ownership & Speculative Tracing: The image is divided into horizontal strips. A thread "owns" any contour that starts within its strip (based on a top-to-bottom raster scan). Crucially, threads are allowed to trace contours downward into other threads' regions without any locking.
  2. Upward Termination (The Abort Condition): If a thread, while tracing a contour, moves upward into a previous thread’s territory, it immediately aborts that trace. The logic is elegant: if a contour goes up, its true "start point" must be in a higher strip, and the thread owning that higher strip will eventually find and trace the entire thing.
  3. 8-bit State Space: Unlike Suzuki-Abe, which requires 32-bit integers to label unique contour IDs, TRUCO uses just four 8-bit labels (Background, Foreground, Visited, and East-Visited). This drastically reduces memory bandwidth and allows for better SIMD (Single Instruction, Multiple Data) optimization.
The speculative tracing logic: Thread T1 starts a trace but aborts if it moves into T0's region, ensuring each contour is only saved once.

Datasets

The algorithm was evaluated on two primary datasets:

  • Synthetic Dataset: 40 high-resolution (4000x4000) images with varying densities of circular objects to test how the algorithm handles different levels of geometric complexity.
  • Liu4K Dataset: A collection of 924 real-world high-resolution images (standardized to 16MP) featuring complex topologies, noise, and irregular shapes. This served as a "stress test" for load balancing and parallel efficiency.

Key Insights and Ideas

  • Hierarchy is Often Bloat: Suzuki-Abe spends significant time building a "topological tree" (which contour is inside which). TRUCO realizes that many high-performance tasks only need the geometric boundaries, so it discards the hierarchy to gain massive speed.
  • Benign Race Conditions: TRUCO is "lock-free" because it treats writes to the shared image buffer as idempotent. If two threads mark the same pixel as "Visited" at the same time, the result is the same as if one did it. This removes the need for expensive mutexes or atomic operations.
  • Memory Efficiency as a Baseline: Even in single-threaded mode, TRUCO is ~1.8x faster than the baseline. This isn't due to parallelism, but rather the switch from 32-bit to 8-bit labels, which plays much nicer with CPU caches.

Key Results

TRUCO demonstrates impressive scalability across different hardware (Intel i7 consumer CPUs and Xeon server CPUs):

  • Massive Speedups: On 16MP real-world images, TRUCO achieved a 10.5x speedup over the OpenCV Suzuki-Abe baseline using 20 threads.
  • Peak Performance: On synthetic 1MP images, the speedup reached nearly 20x.
  • Linear Scaling: In "contour-dense" scenes (images with many objects), the algorithm scales almost linearly with the number of threads, as there are plenty of independent tasks to keep the CPU busy.
Scalability analysis on the Liu4K dataset showing robust performance gains as thread count increases.

Limitations and Future Work

While TRUCO is highly effective for natural images, the authors identified specific "pathological" cases where it struggles:

  • Vertical Stripes & Infinite Spirals: If an image consists of a single contour that spans the entire height (like a giant spiral), the "upward termination" logic causes many threads to start traces only to abort them. This creates "false sharing" in the CPU cache and limits parallel gains.
  • Lack of Topology: Because TRUCO focuses on raw geometric extraction, it does not provide the parent-child relationship between contours (e.g., knowing a hole is inside a specific object). Applications requiring this specific structural data would still need a hierarchical approach.

Future work could involve adapting these speculative tracing principles to other image processing tasks that are currently bottlenecked by sequential scanning.

Summary updated

BibTeX
@misc{munozsalinas2026truco,
  author = {Rafael Munoz-Salinas and Francisco J. Romero-Ramirez and Manuel J. Marin-Jimenez},
  title = {{TRUCO: A Scalable Lock-Free Algorithm for Parallel Contour Extraction}},
  year = {2026},
  eprint = {2610.37297},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2610.37297},
}
Figure