CoScan: Multi-Scale Content-Adaptive Space-Filling Scans for Causal State-Space Image Restoration

Wei Dong, Terry Ji, Yan Min, Shahram Shirani, Jun Chen, Han Zhou

TL;DR

Vision models based on Mamba offer incredible speed by reading images as 1D sequences, but flattening a 2D picture using rigid, predetermined zig-zags often chops objects in half and confuses the model—especially when the image is dark, blurry, or covered in rain. CoScan solves this by dynamically drawing a custom, continuous path through each image that hugs semantic structures and deliberately starts in the most detail-rich neighborhoods. Plugged into existing architectures, it boosts image restoration quality across the board while actually reducing computational overhead.

What Problem Does This Paper Address?

Transformers are great at seeing the big picture in an image, but their quadratic attention cost makes high-resolution image restoration painfully heavy. Enter Mamba (a Selective State-Space Model, or SSM), which processes sequences in linear time.

There’s a catch, though: Mamba was built for 1D text, which has a natural left-to-right order. Images are 2D grids. To feed an image into Mamba, you have to trace a path through the pixels to flatten them into a 1D line. Furthermore, Mamba is causal—a pixel only knows about the pixels visited before it, and its memory of older pixels decays exponentially over time.

Most Vision Mamba models use fixed, content-blind paths (like row-by-row sweeps or Hilbert curves). When restoring a degraded image, a blind scan constantly crosses object boundaries, separating related pixels by huge gaps in the 1D sequence. Worse, if the scan starts in a pitch-black or blurry background corner, the model wastes its influential early sequence positions on useless noise. Recent attempts at "dynamic" scans either break continuity with awkward jumps or accidentally visit pixels multiple times. How do we trace a continuous, single-visit path that adapts to a degraded image's actual content, works across multi-scale U-Net layers, and starts somewhere meaningful?

Methods

CoScan builds upon classic space-filling curves (SFCs)—continuous paths that visit every pixel on a grid exactly once (a Hamiltonian circuit) by merging tiny $2\times2$ pixel loops using a Minimum Spanning Tree (MST) on a dual graph. CoScan upgrades this classical graph trick into a modern, content-aware neural pipeline through four clever steps:

  1. Differentiable Proxy Optimization: Computing an MST is non-differentiable, meaning you can't just backpropagate through it to learn better edge weights. CoScan introduces a two-network dance: a Weight Generator ($G$) predicts graph weights from the image, and a Weight Evaluator ($E$) acts as a differentiable proxy, learning to predict how good the resulting scan will be. $G$ is then trained via gradients flowing through $E$ to optimize three novel scan-quality objectives: short-range autocorrelation, causal predictability (via a linear autoregressive residual ratio), and spatial 4-neighbor adjacency.
Differentiable proxy optimization of content-aware space-filling curves using a Weight Generator and Weight Evaluator.
  1. Multi-Scale MST Coarsening: Restoration networks usually rely on hierarchical U-Nets that shrink and expand feature maps. Instead of expensively recalculating a brand-new curve at every resolution—or naively downsampling a curve and causing dead-ends—CoScan takes the fine-level MST, groups nodes into blocks, median-pools the edges between blocks, and runs a fast MST on the coarse graph. Structure stays consistent across all scales.
Multi-scale scan scaling via graph-based MST coarsening across feature resolutions.
  1. Frequency-Guided Start Selection: Because an SFC starts by cutting a closed loop, CoScan gets to choose where to make the cut. It extracts high-frequency details via a Fourier transform, unfolds them along the loop, and uses dynamic programming to find the most structure-rich contiguous segment—rotating the sequence so the scan begins right in the thick of the action.
  2. Global Prefix Tokens: Finally, before running the Mamba scan, CoScan prepends 8 lightweight, MLP-pooled "global tokens" to give the causal state an immediate bird's-eye summary of the whole feature map.

Datasets

No new datasets are introduced; CoScan is benchmarked across standard datasets spanning five distinct restoration tasks:

  • Low-Light Image Enhancement (LLIE): Trained/tested on LOL, plus zero-shot real-world evaluation on MEF, DICM, LIME, and NPE.
  • Image Deblurring: Trained on GoPro, evaluated on GoPro and HIDE.
  • Raindrop Removal: Trained and tested on the Raindrop dataset.
  • Image Dehazing: Trained and tested on RESIDE-6K (indoor and outdoor splits).
  • Super-Resolution ($\times 4$): Trained on DF2K and DIV2K; tested on Set5, Set14, B100, Urban100, and Manga109.

Key Insights and Ideas

  • 2D Locality $\neq$ 1D Causal Predictability: Just because a path stays spatially local (like a standard Hilbert curve) doesn't mean it creates a predictable sequence for a causal state-space model. Explicitly training the path using classic time-series metrics (Yule–Walker autoregressive residuals) bridges graph geometry and sequence modeling.
  • Where You Start Matters: In a causal model, early tokens shape the context for everything that follows. Using frequency saliency to pick a segment (rather than a single pixel, which could just be an isolated noise spike) prevents Mamba from "wasting" its prefix on empty backgrounds.
  • One Smart Scan Beats Four Blind Ones: Standard Vision Mamba modules typically scan an image in four static directions at once to compensate for causal blind spots. Replacing multi-scan blocks with a single content-aware CoScan boosts accuracy while trimming down parameter counts and compute.

Key Results

Plugged into three state-of-the-art Mamba backbones (MambaIR, EAMamba, and MaIR), CoScan delivers consistent gains across all five tasks:

  • Low-Light Enhancement: On LOL, CoScan boosts PSNR by +1.07 dB on MambaIR, +0.89 dB on EAMamba, and +0.87 dB on MaIR (reaching 24.16 dB overall, beating top Transformer Restormer by +0.66 dB).
  • Deblurring & Raindrops: CoScan + MaIR improves over base MaIR by +1.34 dB on HIDE deblurring and +1.71 dB on Raindrop removal (32.45 dB vs. 30.74 dB).
  • Efficiency Wins: On RESIDE-6K dehazing, CoScan + MaIR jumps outdoor PSNR by +2.75 dB (from 28.49 to 31.24 dB) while reducing parameters from 26.3M to 23.5M and cutting MACs (on $128\times128$ patches) from 49.3G down to 35.2G.
  • Qualitative: Restored images exhibit noticeably crisper text through glass, fewer motion smears on faces, and cleaner reconstructions behind raindrops without color shifts.

Limitations and Future Work

Not discussed in the paper. (Note: While the abstract briefly mentions promising results on high-level vision tasks as a direction beyond image restoration, no dedicated limitations or future work section is included in the provided manuscript.)

Summary updated

Abstract

Selective state-space models (SSMs) have recently shown strong potential for efficient image restoration. A central difficulty, however, is that a 2D feature map typically needs to be linearized into a 1D token sequence for causal state-space updates, making restoration performance highly sensitive to the imposed scan order. Existing deterministic scans follow space-filling principles but remain fixed and content-agnostic, and can yield fragmented or semantically inconsistent contexts under degradations. We propose **CoScan**, a **co**ntent-adaptive **scan**-order design for causal vision SSMs. CoScan learns image-dependent space-filling traversals via differentiable proxy supervision driven by **scan-quality objectives** that encourage *short-range coherence and causal predictability, while preserving spatial adjacency*. To support hierarchical restoration backbones, we introduce an **efficient multi-scale scan construction** by *coarsening a fine-level minimum spanning tree*, producing coherent scans across feature resolutions. In addition, **a frequency-guided start selection strategy** is designed to *place informative structures early in the sequence prefix to strengthen causal context formation*. Plugged into existing Mamba-based backbones, CoScan yields consistent improvements across several restoration benchmarks with minimal overhead and shows promising results on high-level vision tasks. Code will be released upon acceptance.
BibTeX
@inproceedings{dong2026coscan,
  author = {Wei Dong and Terry Ji and Yan Min and Shahram Shirani and Jun Chen and Han Zhou},
  title = {{CoScan: Multi-Scale Content-Adaptive Space-Filling Scans for Causal State-Space Image Restoration}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=XHd7CqQtoF},
}
Figure