MCPcopy Create free account
hub / github.com/dcharatan/flowmap / color_map_depth

Function color_map_depth

flowmap/visualization/depth.py:7–20  ·  view source on GitHub ↗
(
    depth: Float[Tensor, "batch height width"],
    cmap: str = "inferno",
    invert: bool = True,
)

Source from the content-addressed store, hash-verified

5
6
7def 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)

Callers 2

render_depthsFunction · 0.90
visualizeMethod · 0.85

Calls 1

apply_color_map_to_imageFunction · 0.85

Tested by

no test coverage detected