(
depth: Float[Tensor, "batch height width"],
cmap: str = "inferno",
invert: bool = True,
)
| 5 | |
| 6 | |
| 7 | def color_map_depth( |
| 8 | depth: Float[Tensor, "batch height width"], |
| 9 | cmap: str = "inferno", |
| 10 | invert: bool = True, |
| 11 | ) -> Float[Tensor, "batch 3 height width"]: |
| 12 | depth = depth.log() |
| 13 | # Normalize the depth. |
| 14 | near = depth.min() |
| 15 | far = depth.max() |
| 16 | depth = (depth - near) / (far - near) |
| 17 | depth = depth.clip(min=0, max=1) |
| 18 | if invert: |
| 19 | depth = 1 - depth |
| 20 | return apply_color_map_to_image(depth, cmap) |
no test coverage detected