PIXELBANKv9.1.0
Menu

Surface Integration from Normals

Implement a method to integrate surface normals and recover a depth map, a crucial step in 3D Reconstruction using Photometric Stereo. This process involves calculating the surface gradient from given normals.

The surface gradient is a fundamental concept in Computer Vision, representing the rate of change of the surface depth in the x and y directions. Given the surface normals nxn_x, nyn_y, nzn_z, the surface gradient can be calculated as p=−nx/nzp = -n_x/n_z and q=−ny/nzq = -n_y/n_z, which are essential for integrating the surface.

To integrate the surface, follow these steps:

  1. Calculate the surface gradient pp and qq from the given normals.
  2. Use the calculated pp and qq in a Poisson equation solver to obtain the depth ZZ.
p=−nx/nz,q=−ny/nzp = -n_x/n_z, \quad q = -n_y/n_z

This technique is widely used in 3D scanning and object recognition applications.

Example:

Input:
Normal map
Output:
Depth map
Reasoning:

Compute gradients from normals, integrate using Poisson

Constraints:

  • Input normals: 2D numpy array of shape (height, width, 3) with dtype float32, representing the surface normals nxn_x, nyn_y, nzn_z
  • Valid ranges: nzn_z values are non-zero, and all normal values are normalized to have a length of 1
  • Output depth map: 2D numpy array of shape (height, width) with dtype float32, representing the recovered depth ZZ with precision up to 6 decimal places
  • Special conditions: The input normals are assumed to be noise-free and the surface is assumed to be Lambertian and convex
  • Boundary conditions: The depth values at the boundary of the image are assumed to be zero, and the Poisson equation solver should handle the boundary conditions accordingly
🔒

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

0/0
Run code to see test results.
Surface Integration from Normals - Medium | PixelBank