Automatic Fence Segmentation in Videos of Dynamic Scenes

Renjiao Yi, Jue Wang, Ping Tan

Abstract

This paper presents a robust, fully automatic pipeline for segmenting fence-like occluders in videos characterized by moving cameras and dynamic subjects. By leveraging motion contrast and structural priors within a spatio-temporal dense Conditional Random Field (CRF) framework, the proposed method effectively isolates thin, repetitive structures that typically challenge standard segmentation tools. Evaluation on a diverse dataset demonstrates that this approach significantly outperforms existing interactive and automatic solutions in both precision and recall.

Introduction

Capturing video through fences—common at zoos, sports events, or construction sites—often results in distracting occlusions. While removing these fences in post-processing is a highly desired feature for photographers and videographers, it remains a significant technical challenge. Existing solutions typically assume static cameras or stationary backgrounds, which fail in "in-the-wild" scenarios involving complex camera movement and dynamic subjects.

Overview of the automatic fence segmentation pipeline. Left: Original frame with fence occlusion. Middle: Initial segmentation result. Right: Final refined segmentation mask.

Challenges in Fence Segmentation

Fences present several unique difficulties that hinder standard computer vision algorithms:

  • Thin Structures: Fences consist of very thin wires that challenge standard segmentation tools like GrabCut, which often fail to maintain topological connectivity.
  • Lack of Texture: Fence wires often lack distinctive colors or textures, making them difficult to track reliably across frames.
  • Repetitive Patterns: The grid-like nature of fences frequently causes errors in optical flow and motion estimation due to the aperture problem and matching ambiguities.
  • Dynamic Complexity: Most prior work assumes a simple "two-layer" model (a static background and a moving fence). This assumption breaks down when the background contains moving objects (e.g., animals) or when the camera itself is moving, creating complex parallax effects.

Methodology

The authors propose a three-stage bottom-up framework to address these challenges by integrating visual, motion, and structural cues.

1. Pixel Grouping

Instead of processing individual pixels, the system computes optical flow and applies K-means clustering in a 5D feature space consisting of RGB color and normalized motion vectors. This process groups pixels into coherent "super-pixels" based on how they move and look, effectively separating the foreground fence from the dynamic background.

2. Initial Fence Labeling

The pixel groups are analyzed using a graph-cut approach. The "fenceness" of a group is determined by two key priors:

  • Structural Prior: Fences typically exhibit two dominant gradient orientations that are approximately perpendicular. This man-made regularity distinguishes them from natural background textures.
  • Geometric Prior: Due to their thinness, morphological erosion causes fence structures to disappear, while solid background objects remain largely intact.

3. Spatio-temporal Refinement

To correct per-frame inaccuracies and ensure temporal smoothness, a dense CRF is solved across all video frames. This step aligns fence boundaries with actual image edges and ensures the fence doesn't "flicker" in and out of existence across frames by connecting pixels across time using optical flow.

Intermediate stages of the segmentation process: (a) initial noisy labeling based on motion, (b) labeling after applying structural and geometric priors, (c) final refined mask after spatio-temporal optimization.

Experimental Results

The method was evaluated on a diverse dataset of 18 video clips, including YouTube footage, research benchmarks, and mobile phone captures. The dataset featured challenging scenarios such as large perspective distortions and non-fence occluders like tree branches and thin wires.

The proposed method achieved an average Precision of 80.92% and Recall of 82.31%, significantly outperforming the industry-standard interactive tool Rotobrush (57.43% Precision / 52.25% Recall) and previous state-of-the-art automatic methods.

Conclusion

This research demonstrates that motion, often viewed as a complication in computer vision, can be a powerful feature for isolating occluders. By leveraging local motion contrast and structural regularities, the system effectively segments fences in dynamic scenes. While the method currently relies on motion and is sensitive to extremely poor optical flow, it represents a significant step toward automated, high-quality fence removal in consumer video. Future work will focus on integrating advanced multi-frame inpainting to provide professional-grade, fence-free results.

Summary updated

BibTeX
@inproceedings{yi2016automatic,
  author = {Renjiao Yi and Jue Wang and Ping Tan},
  title = {{Automatic Fence Segmentation in Videos of Dynamic Scenes}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2016},
  doi = {10.1109/cvpr.2016.83},
}
Figure