Visualization¶
Visualization tools.
API¶
- kiui.vis.map_color(value: ndarray, cmap_name: str = 'viridis', vmin: float | None = None, vmax: float | None = None)[source]¶
map a 1D array to continuous color.
- Parameters:
value (ndarray) – array of float, [N]
cmap_name (str, optional) – color map name, ref: https://matplotlib.org/stable/users/explain/colors/colormaps.html#classes-of-colormaps. Defaults to “viridis”.
vmin (float, optional) – min value. Defaults to None.
vmax (float, optional) – max value. Defaults to None.
- Returns:
array of color, [N, 3] in [0, 1]
- Return type:
ndarray
- kiui.vis.plot_image(*xs, normalize=False, save=False, prefix='kiui_vis_plot_image')[source]¶
sequentially plot provided images, optionally save to current dir.
- Parameters:
xs (Sequence[Union[torch.Tensor, numpy.ndarray]]) – can be uint8 or float32. [B, 4/3/1, H, W], [B, H, W, 4/3/1], [4/3/1, H, W], [H, W, 4/3/1], [H, W] torch.Tensor or numpy.ndarray
normalize (bool, optional) – whether to renormalize the image to [0, 1]. Defaults to False.
save (bool, optional) – whether to save the image to current dir (in case the plot cannot be showed, like in vscode remote). Defaults to False.
prefix (str, optional) – image save name prefix if save=True.
- kiui.vis.plot_matrix(*xs)[source]¶
visualize some 2D matrix, different from
kiui.vis.plot_image
, this will keep the original range and plot channel-by-channel.- Parameters:
xs (Sequence[Union[torch.Tensor, numpy.ndarray]]) – [B, C, H, W], [C, H, W], or [H, W] torch.Tensor or numpy.ndarray
- kiui.vis.plot_pointcloud(pc, color=None)[source]¶
plot point cloud.
- Parameters:
pc (ndarray) – point cloud positions, float [N, 3].
color (ndarray, optional) – point cloud colors, float/uint8 [N, 3/4]. Defaults to None.
Note
This function requires a desktop (cannot be forwarded by ssh)!
- kiui.vis.plot_poses(poses, size=0.1, bound=1, points=None, mesh=None, opengl=True)[source]¶
plot camera poses.
- Parameters:
poses (ndarray) – camera poses, float [N, 4, 4].
size (float, optional) – line width. Defaults to 0.1.
bound (int, optional) – bounding box bound. Defaults to 1.
points (ndarray, optional) – also draw point clouds, float [M, 3]. Defaults to None.
mesh (trimesh.Trimesh, optional) – also draw mesh. Defaults to None.
opengl (bool, optional) – use OpenGL camera convention. Defaults to True.
Note
This function requires a desktop (cannot be forwarded by ssh)!