Skip to content

Commit

Permalink
Merge pull request #150 from Visual-Behavior/depth_get_view
Browse files Browse the repository at this point in the history
Depth.get_view(): fix normalization and add reverse cmap feature
  • Loading branch information
thibo73800 authored Feb 14, 2022
2 parents 54ed9af + 66f55d3 commit dab73e8
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions aloscene/depth.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ def append_occlusion(self, occlusion: Mask, name: str = None):
"""
self._append_child("occlusion", occlusion, name)

def __get_view__(self, cmap="nipy_spectral", min_depth=0, max_depth=200, title=None):
def __get_view__(self, cmap="nipy_spectral", min_depth=0, max_depth=200, title=None, reverse=True):
assert all(dim not in self.names for dim in ["B", "T"]), "Depth should not have batch or time dimension"
cmap = matplotlib.cm.get_cmap(cmap)
depth = self.rename(None).permute([1, 2, 0]).detach().cpu().contiguous().numpy()

depth = max_depth - np.clip(depth, min_depth, max_depth)
depth = matplotlib.colors.Normalize(vmax=max_depth)(depth)
depth = matplotlib.colors.Normalize(vmin=min_depth, vmax=max_depth, clip=True)(depth)
if reverse:
depth = 1 - depth
depth_color = cmap(depth)[:, :, 0, :3]
return View(depth_color, title=title)

Expand Down

0 comments on commit dab73e8

Please sign in to comment.