PIXELBANKv9.1.0
Menu

Normalize a depth map to [0, 1] range using min-max normalization.

Depth maps often need normalization for visualization or as input to neural networks. Min-max normalization maps values to [0, 1]:

Znorm=Zβˆ’ZminZmaxβˆ’ZminZ_{norm} = \frac{Z - Z_{min}}{Z_{max} - Z_{min}}

where:

  • ZminZ_{min} and ZmaxZ_{max} are the minimum and maximum depths in the map
  • Closest points (small Z) become 0 (black in visualization)
  • Farthest points (large Z) become 1 (white in visualization)

Note: If all depths are equal, the normalized result is all zeros.

Example:

Input:
normalize_depth([[1, 2], [3, 4]])
Output:
[[0.0, 0.3333], [0.6667, 1.0]]
Reasoning:

Normalizing depth map:

  • min = 1, max = 4, range = 3 (1-1)/3 = 0.0 (2-1)/3 = 0.3333 (3-1)/3 = 0.6667 (4-1)/3 = 1.0

Constraints:

  • depth_map: 2D array of depth values
  • Return normalized depth map with values in [0, 1], rounded to 4 decimal places
πŸ”’

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.