MCPcopy Create free account
hub / github.com/InternRobotics/G2VLM / colorize_depth_affine

Function colorize_depth_affine

eval_code/recons/models/moge/utils/vis.py:21–29  ·  view source on GitHub ↗
(depth: np.ndarray, mask: np.ndarray = None, cmap: str = 'Spectral')

Source from the content-addressed store, hash-verified

19
20
21def colorize_depth_affine(depth: np.ndarray, mask: np.ndarray = None, cmap: str = 'Spectral') -> np.ndarray:
22 if mask is not None:
23 depth = np.where(mask, depth, np.nan)
24
25 min_depth, max_depth = np.nanquantile(depth, 0.001), np.nanquantile(depth, 0.999)
26 depth = (depth - min_depth) / (max_depth - min_depth)
27 colored = np.nan_to_num(matplotlib.colormaps[cmap](depth)[..., :3], 0)
28 colored = np.ascontiguousarray((colored.clip(0, 1) * 255).astype(np.uint8))
29 return colored
30
31
32def colorize_disparity(disparity: np.ndarray, mask: np.ndarray = None, normalize: bool = True, cmap: str = 'Spectral') -> np.ndarray:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected