MCPcopy Create free account
hub / github.com/apple/ml-sharp / colorize_depth

Function colorize_depth

src/sharp/utils/vis.py:16–36  ·  view source on GitHub ↗

Colorize depth map.

(depth: torch.Tensor, val_max: float = 10.0)

Source from the content-addressed store, hash-verified

14
15
16def colorize_depth(depth: torch.Tensor, val_max: float = 10.0) -> torch.Tensor:
17 """Colorize depth map."""
18 depth_channels = depth.shape[-3]
19
20 # When we have a general depth/disparity map, output the color map as is.
21 if depth_channels == 1:
22 return colorize_scalar_map(
23 depth.squeeze(-3), val_min=0.0, val_max=val_max, color_map="turbo"
24 )
25
26 # When we have a multi-layered depth/disparity map,
27 # we concatenate the color maps horizontally and output it.
28 else:
29 colored_depths = []
30 for c in range(depth_channels):
31 colored_depths.append(
32 colorize_scalar_map(
33 depth[..., c, :, :], val_min=0.0, val_max=val_max, color_map="turbo"
34 )
35 )
36 return torch.cat(colored_depths, dim=-1)
37
38
39def colorize_alpha(alpha: torch.Tensor) -> torch.Tensor:

Callers 1

add_frameMethod · 0.85

Calls 1

colorize_scalar_mapFunction · 0.85

Tested by

no test coverage detected