MCPcopy Create free account
hub / github.com/apchenstu/mvsnerf / visualize_depth_numpy

Function visualize_depth_numpy

utils.py:30–45  ·  view source on GitHub ↗

depth: (H, W)

(depth, minmax=None, cmap=cv2.COLORMAP_JET)

Source from the content-addressed store, hash-verified

28
29
30def visualize_depth_numpy(depth, minmax=None, cmap=cv2.COLORMAP_JET):
31 """
32 depth: (H, W)
33 """
34
35 x = np.nan_to_num(depth) # change nan to 0
36 if minmax is None:
37 mi = np.min(x[x>0]) # get minimum positive depth (ignore background)
38 ma = np.max(x)
39 else:
40 mi,ma = minmax
41
42 x = (x-mi)/(ma-mi+1e-8) # normalize to 0~1
43 x = (255*x).astype(np.uint8)
44 x_ = cv2.applyColorMap(x, cmap)
45 return x_, [mi,ma]
46
47def visualize_depth(depth, minmax=None, cmap=cv2.COLORMAP_JET):
48 """

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected