Learning on the Edge: Explicit Boundary Handling in CNNs

Carlo Innamorati, Tobias Ritschel, Tim Weyrich, Niloy J. Mitra

Abstract

Standard Convolutional Neural Networks (CNNs) handle image boundaries using fixed heuristics like zero-padding or reflection, which often introduce artifacts that propagate into the image interior. This paper introduces Explicit Boundary Handling, a method that replaces these rules with a set of learned filters specifically for edges and corners. By optimizing these boundary-specific kernels alongside standard interior filters, the approach achieves a 5% to 20% performance boost across diverse computer vision tasks—including colorization, de-Bayering, and optical flow—with negligible computational overhead.

The Problem: Boundary Artifacts

When a convolution filter slides over an image, it eventually encounters the edge. To calculate a value at the boundary, the network must assume what lies outside the image frame. Traditionally, researchers use padding: filling the void with zeros, mirroring edge pixels, or using a mean color.

These heuristics are fundamentally task-oblivious and flawed. For instance, zero-padding creates a "black halo" effect, while reflection padding can create unnatural discontinuities in diagonal lines. In deep architectures, particularly encoder-decoders like U-Nets, these boundary errors do not remain localized; they propagate inward, deteriorating the feature quality of the entire image and leading to suboptimal results even in the center of the frame.

Methods: Explicit Boundary Rules

The core innovation is the use of domain decomposition to implement explicit boundary rules. Instead of applying a single universal filter across the entire padded image, the authors propose using a "family" of kernels.

Explicit boundary rules via domain decomposition: a standard filter is replaced by a family of nine learned kernels (g1 to g9) corresponding to different spatial configurations.

For a standard $3 \times 3$ filter, there are nine possible spatial configurations: the interior, four edges (top, bottom, left, right), and four corners. The network learns nine separate versions of every filter. When the convolution is in the interior, it uses standard weights. When it touches a boundary, it switches to a specific filter (e.g., a "top-left corner" filter) that has learned how to optimally extrapolate features for that specific task. These filters are trained jointly using standard backpropagation. While this increases the weight count slightly, it adds zero computational operations at runtime, as the specialized filters simply replace the standard ones at specific coordinates.

Key Results and Insights

The authors evaluated their method across several benchmarks, including ImageNet for Gaussian blur analysis, and specialized datasets for de-Bayering, colorization, and scene flow. The method demonstrated consistent quantitative improvements:

Task Metric Reflect Padding Zero Padding Ours (Explicit)
Gauss Filtering DSSIM (lower is better) .0018 .0022 .0016
De-noise/Bayer PSNR (higher is better) 31.46 31.50 31.94
Colorization DSSIM (lower is better) .1593 .1604 .1577
Scene Flow px error (lower is better) 1.380 1.183 .1096

The "Shielding" Effect

A critical finding is that explicit boundary handling improves the accuracy of interior pixels. By handling boundaries correctly, the network "shields" inner regions from the spurious signals typically caused by bad padding. This allows the CNN to adopt a "Gestalt assumption" of continuity, effectively in-painting the missing context needed for clean convolutions.

Spatial distribution of error for different padding methods. Explicit boundary handling (right) effectively 'shields' the interior and minimizes boundary artifacts compared to zero and reflection padding.

Limitations and Future Work

While highly effective for the $3 \times 3$ filters common in modern CNNs, the number of boundary cases scales with filter size (e.g., a $7 \times 7$ filter would require 49 cases), which could become memory-intensive for large-kernel architectures. Additionally, while the theoretical overhead is zero, current deep learning frameworks are optimized for uniform convolutions; peak efficiency requires custom implementation logic for region-specific kernel switching. Future work may extend this approach to non-rectangular domains, such as spherical images or graph-based networks.

Summary updated

BibTeX
@inproceedings{innamorati2018learning,
  author = {Carlo Innamorati and Tobias Ritschel and Tim Weyrich and Niloy J. Mitra},
  title = {{Learning on the Edge: Explicit Boundary Handling in CNNs}},
  booktitle = {BMVC},
  year = {2018},
  url = {https://openreview.net/forum?id=ZH9uzmVEea6},
}
Figure