Colorize depth map.
(depth: torch.Tensor, val_max: float = 10.0)
| 14 | |
| 15 | |
| 16 | def 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 | |
| 39 | def colorize_alpha(alpha: torch.Tensor) -> torch.Tensor: |
no test coverage detected