vis4d.vis.functional.image¶
Function interface for image visualization functions.
Functions
|
Draw 3D box onto image. |
|
Draws the predicted bounding boxes into the given image. |
|
Draws semantic masks into the given image. |
|
Shows a single image. |
|
Shows a single image. |
|
Shows the bounding boxes overlayed on the given image. |
|
Show image with bounding boxes. |
|
Shows semantic masks overlayed over the given image. |
|
Visualize the 'topk' bounding boxes with highest score. |
|
Visualize paired bounding boxes successively for batched frame pairs. |
- draw_bbox3d(image, boxes3d, intrinsics, extrinsics=None, scores=None, class_ids=None, track_ids=None, class_id_mapping=None, n_colors=50, image_mode='RGB', canvas=<vis4d.vis.image.canvas.pillow_backend.PillowCanvasBackend object>, width=4, camera_near_clip=0.15)[source]¶
Draw 3D box onto image.
- Return type:
NDArrayUI8
- draw_bboxes(image, boxes, scores=None, class_ids=None, track_ids=None, class_id_mapping=None, n_colors=50, image_mode='RGB', box_width=1, canvas=<vis4d.vis.image.canvas.pillow_backend.PillowCanvasBackend object>)[source]¶
Draws the predicted bounding boxes into the given image.
- Parameters:
image (ArrayLike) – The image to draw the bboxes into.
boxes (ArrayLikeFloat) – Predicted bounding boxes.
scores (None | ArrayLikeFloat, optional) – Predicted scores. Defaults to None.
class_ids (ArrayLikeInt, optional) – Predicted class ids. Defaults to None.
track_ids (ArrayLikeInt, optional) – Predicted track ids. Defaults to None.
class_id_mapping (dict[int, str], optional) – Mapping from class id to name. Defaults to None.
n_colors (int, optional) – Number of colors to use for color palette. Defaults to 50.
image_mode (str, optional) – Image Mode. Defaults to “RGB”.
box_width (int, optional) – Width of the box border. Defaults to 1.
canvas (CanvasBackend, optional) – Canvas backend to use. Defaults to PillowCanvasBackend().
- Returns:
The image with boxes drawn into it,
- Return type:
NDArrayUI8
- draw_masks(image, masks, class_ids, n_colors=50, image_mode='RGB', canvas=<vis4d.vis.image.canvas.pillow_backend.PillowCanvasBackend object>)[source]¶
Draws semantic masks into the given image.
- Parameters:
image (ArrayLike) – The image to draw the bboxes into.
masks (ArrayLikeBool) – The semantic masks with the same shape as the image.
class_ids (ArrayLikeInt, optional) – Predicted class ids. Defaults to None.
n_colors (int, optional) – Number of colors to use for color palette. Defaults to 50.
image_mode (str, optional) – Image Mode. Defaults to “RGB”.
canvas (CanvasBackend, optional) – Canvas backend to use. Defaults to PillowCanvasBackend().
- Returns:
The image with semantic masks drawn into it,
- Return type:
NDArrayUI8
- imsave(image, file_path, image_mode='RGB', image_viewer=<vis4d.vis.image.viewer.matplotlib_viewer.MatplotlibImageViewer object>)[source]¶
Shows a single image.
- Parameters:
image (NDArrayNumber) – The image to show.
file_path (str) – The path to save the image to.
image_mode (str, optional) – Image Mode. Defaults to “RGB”.
image_viewer (ImageViewerBackend, optional) – The Image viewer backend to use. Defaults to MatplotlibImageViewer().
- Return type:
None
- imshow(image, image_mode='RGB', image_viewer=<vis4d.vis.image.viewer.matplotlib_viewer.MatplotlibImageViewer object>)[source]¶
Shows a single image.
- Parameters:
image (NDArrayNumber) – The image to show.
image_mode (str, optional) – Image Mode. Defaults to “RGB”.
image_viewer (ImageViewerBackend, optional) – The Image viewer backend to use. Defaults to MatplotlibImageViewer().
- Return type:
None
- imshow_bboxes(image, boxes, scores=None, class_ids=None, track_ids=None, class_id_mapping=None, n_colors=50, image_mode='RGB', box_width=1, image_viewer=<vis4d.vis.image.viewer.matplotlib_viewer.MatplotlibImageViewer object>)[source]¶
Shows the bounding boxes overlayed on the given image.
- Parameters:
image (ArrayLike) – Background Image
boxes (ArrayLikeFloat) – Boxes to show. Shape [N, 4] with (x1,y1,x2,y2) as corner convention
scores (ArrayLikeFloat, optional) – Score for each box shape [N]
class_ids (ArrayLikeInt, optional) – Class id for each box shape [N]
track_ids (ArrayLikeInt, optional) – Track id for each box shape [N]
class_id_mapping (dict[int, str], optional) – Mapping to convert class id to class name
n_colors (int, optional) – Number of distinct colors used to color the boxes. Defaults to 50.
image_mode (str, optional) – Image channel mode (RGB or BGR).
box_width (int, optional) – Width of the box border. Defaults to 1.
image_viewer (ImageViewerBackend, optional) – The Image viewer backend to use. Defaults to MatplotlibImageViewer().
- Return type:
None
- imshow_bboxes3d(image, boxes3d, intrinsics, extrinsics=None, scores=None, class_ids=None, track_ids=None, class_id_mapping=None, n_colors=50, image_mode='RGB', image_viewer=<vis4d.vis.image.viewer.matplotlib_viewer.MatplotlibImageViewer object>)[source]¶
Show image with bounding boxes.
- Return type:
None
- imshow_masks(image, masks, class_ids, n_colors=50, image_mode='RGB', canvas=<vis4d.vis.image.canvas.pillow_backend.PillowCanvasBackend object>, image_viewer=<vis4d.vis.image.viewer.matplotlib_viewer.MatplotlibImageViewer object>)[source]¶
Shows semantic masks overlayed over the given image.
- Parameters:
image (ArrayLike) – The image to draw the bboxes into.
masks (ArrayLikeBool) – The semantic masks with the same shape as the image.
class_ids (ArrayLikeInt, optional) – Predicted class ids. Defaults to None.
n_colors (int, optional) – Number of colors to use for color palette. Defaults to 50.
image_mode (str, optional) – Image Mode.. Defaults to “RGB”.
canvas (CanvasBackend, optional) – Canvas backend to use. Defaults to PillowCanvasBackend().
image_viewer (ImageViewerBackend, optional) – The Image viewer backend to use. Defaults to MatplotlibImageViewer().
- Return type:
None
- imshow_topk_bboxes(image, boxes, scores, topk=100, class_ids=None, track_ids=None, class_id_mapping=None, n_colors=50, image_mode='RGB', box_width=1, image_viewer=<vis4d.vis.image.viewer.matplotlib_viewer.MatplotlibImageViewer object>)[source]¶
Visualize the ‘topk’ bounding boxes with highest score.
- Parameters:
image (ArrayLike) – Background Image
boxes (ArrayLikeFloat) – Boxes to show. Shape [N, 4] with (x1,y1,x2,y2) as corner convention
scores (ArrayLikeFloat) – Score for each box shape [N]
topk (int) – Number of boxes to visualize
class_ids (ArrayLikeInt, optional) – Class id for each box shape [N]
track_ids (ArrayLikeInt, optional) – Track id for each box shape [N]
class_id_mapping (dict[int, str], optional) – Mapping to convert class id to class name
n_colors (int, optional) – Number of distinct colors used to color the boxes. Defaults to 50.
image_mode (str, optional) – Image channel mode (RGB or BGR).
box_width (int, optional) – Width of the box border. Defaults to 1.
image_viewer (ImageViewerBackend, optional) – The Image viewer backend to use. Defaults to MatplotlibImageViewer().
- Return type:
None
- imshow_track_matches(key_imgs, ref_imgs, key_boxes, ref_boxes, key_track_ids, ref_track_ids, image_mode='RGB', image_viewer=<vis4d.vis.image.viewer.matplotlib_viewer.MatplotlibImageViewer object>)[source]¶
Visualize paired bounding boxes successively for batched frame pairs.
- Parameters:
key_imgs (list[ArrayLike]) – Key Images.
ref_imgs (list[ArrayLike]) – Reference Images.
key_boxes (list[ArrayLikeFloat]) – Predicted Boxes for the key image. Shape [N, 4]
ref_boxes (list[ArrayLikeFloat]) – Predicted Boxes for the key image. Shape [N, 4]
key_track_ids (list[ArrayLikeInt]) – Predicted ids for the key images.
ref_track_ids (list[ArrayLikeInt]) – Predicted ids for the reference images.
image_mode (str, optional) – Color mode if the image. Defaults to “RGB”.
image_viewer (ImageViewerBackend, optional) – The Image viewer backend to use. Defaults to MatplotlibImageViewer().
- Return type:
None