v9.1.1
Menu

Occlusion Detection in Warping

mediumPROView InterpolationIBRCV: Image-Based Rendering

Detect pixels that will be occluded when warping between views.

When warping from left to right view, occlusions occur when:

  1. Multiple source pixels map to the same target location (the frontmost wins)
  2. A target location receives no source pixels (disocclusion/hole)

We detect occlusions by counting how many source pixels map to each target. When multiple pixels compete for the same target, the one that gets occluded (typically the one further from the camera) is marked.

This function returns a mask indicating which source pixels are occluded.

Example

Input
detect_occlusions([[0, 0, 2, 0]], 1)
Output
[[0, 1, 0, 0]]
Reasoning

Analyzing pixel mappings (left to right with disparity [0,0,2,0]): Pixel 0: maps to 0+0=0 Pixel 1: maps to 1+0=1 Pixel 2: maps to 2+2=4 (out of bounds, or wraps) Pixel 3: maps to 3+0=3

Wait - with d=2 at index 2, in direction 1:

  • target = src + direction × disparity = 2 + 1×2 = 4 (out of bounds)

Let me reconsider: If pixel 2 has disparity 2 and moves right, it occludes pixel 1 in the target. Pixel 1 is marked occluded.

Constraints

  • disparity: 2D disparity map
  • direction: 1 for left-to-right, -1 for right-to-left
  • Return occlusion mask (1 = occluded, 0 = visible)

Learn this in

More from CV: Image-Based Rendering

PRO

Editor locked

The code editor is locked for Pro problems. It is only available for free problems. Please upgrade to gain access to the code editor for all problems.

solution.py

Test results

Sign in to run your code against the test cases.