mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-11-14 20:03:49 +08:00
colormaps: add "gray" (#2058)
* colormaps: remove useless "pca" choice, add "gray" - The "pca" choice didn't work when applied to a single-channel image (it crashed the viewer), and it's applied by default to any image of more than 3 channels, where the colormap choice is ignore anyway. - Add the trivial "gray" colormap, useful to eg extract accumulation. * colormaps.py: re-add "pca" * control_panel: don't show the "pca" option either --------- Co-authored-by: Frédéric Devernay <f-dy@users.noreply.github.com>
This commit is contained in:
1 parent
f2fdd10d9b
commit
d18588d5d4
2 files changed
+4
-2
No files matched your search
@@ -24,7 +24,7 @@ from torch import Tensor
|
||||
|
||||
from nerfstudio.utils import colors
|
||||
|
||||
Colormaps = Literal["default", "turbo", "viridis", "magma", "inferno", "cividis", "pca"]
|
||||
Colormaps = Literal["default", "turbo", "viridis", "magma", "inferno", "cividis", "gray", "pca"]
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@@ -104,6 +104,8 @@ def apply_float_colormap(image: Float[Tensor, "*bs 1"], colormap: Colormaps = "v
|
||||
colormap = "turbo"
|
||||
|
||||
image = torch.nan_to_num(image, 0)
|
||||
if colormap == "gray":
|
||||
return image.repeat(1, 1, 3)
|
||||
image_long = (image * 255).long()
|
||||
image_long_min = torch.min(image_long)
|
||||
image_long_max = torch.max(image_long)
|
||||
|
||||
Reference in new issue
Block a user