Colormaps#

Helper functions for visualizing outputs

class nerfstudio.utils.colormaps.ColormapOptions(colormap: Literal['default', 'turbo', 'viridis', 'magma', 'inferno', 'cividis', 'gray', 'pca'] = 'default', normalize: bool = False, colormap_min: float = 0, colormap_max: float = 1, invert: bool = False)[source]#

Bases: object

Options for colormap

colormap: Literal['default', 'turbo', 'viridis', 'magma', 'inferno', 'cividis', 'gray', 'pca'] = 'default'#

The colormap to use

colormap_max: float = 1#

Maximum value for the output colormap

colormap_min: float = 0#

Minimum value for the output colormap

invert: bool = False#

Whether to invert the output colormap

normalize: bool = False#

Whether to normalize the input tensor image

nerfstudio.utils.colormaps.apply_boolean_colormap(image: Bool[Tensor, '*bs 1'], true_color: Float[Tensor, '*bs rgb=3'] = tensor([1., 1., 1.]), false_color: Float[Tensor, '*bs rgb=3'] = tensor([0., 0., 0.])) Float[Tensor, '*bs rgb=3'][source]#

Converts a depth image to color for easier analysis.

Parameters:
  • image – Boolean image.

  • true_color – Color to use for True.

  • false_color – Color to use for False.

Returns:

Colored boolean image

nerfstudio.utils.colormaps.apply_colormap(image: Float[Tensor, '*bs channels'], colormap_options: ColormapOptions = ColormapOptions(colormap='default', normalize=False, colormap_min=0, colormap_max=1, invert=False), eps: float = 1e-09) Float[Tensor, '*bs rgb=3'][source]#

Applies a colormap to a tensor image. If single channel, applies a colormap to the image. If 3 channel, treats the channels as RGB. If more than 3 channel, applies a PCA reduction on the dimensions to 3 channels

Parameters:
  • image – Input tensor image.

  • eps – Epsilon value for numerical stability.

Returns:

Tensor with the colormap applied.

nerfstudio.utils.colormaps.apply_depth_colormap(depth: Float[Tensor, '*bs 1'], accumulation: Optional[Float[Tensor, '*bs 1']] = None, near_plane: Optional[float] = None, far_plane: Optional[float] = None, colormap_options: ColormapOptions = ColormapOptions(colormap='default', normalize=False, colormap_min=0, colormap_max=1, invert=False)) Float[Tensor, '*bs rgb=3'][source]#

Converts a depth image to color for easier analysis.

Parameters:
  • depth – Depth image.

  • accumulation – Ray accumulation used for masking vis.

  • near_plane – Closest depth to consider. If None, use min image value.

  • far_plane – Furthest depth to consider. If None, use max image value.

  • colormap – Colormap to apply.

Returns:

Colored depth image with colors in [0, 1]

nerfstudio.utils.colormaps.apply_float_colormap(image: Float[Tensor, '*bs 1'], colormap: Literal['default', 'turbo', 'viridis', 'magma', 'inferno', 'cividis', 'gray', 'pca'] = 'viridis') Float[Tensor, '*bs rgb=3'][source]#

Convert single channel to a color image.

Parameters:
  • image – Single channel image.

  • colormap – Colormap for image.

Returns:

Colored image with colors in [0, 1]

Return type:

Tensor

nerfstudio.utils.colormaps.apply_pca_colormap(image: Float[Tensor, '*bs dim'], pca_mat: Optional[Float[Tensor, 'dim rgb=3']] = None, ignore_zeros=True) Float[Tensor, '*bs rgb=3'][source]#

Convert feature image to 3-channel RGB via PCA. The first three principle components are used for the color channels, with outlier rejection per-channel

Parameters:
  • image – image of arbitrary vectors

  • pca_mat – an optional argument of the PCA matrix, shape (dim, 3)

  • ignore_zeros – whether to ignore zero values in the input image (they won’t affect the PCA computation)

Returns:

Colored image

Return type:

Tensor