vis4d.vis.image

Image Visualization.

class BoundingBoxVisualizer(*args, n_colors=50, class_id_mapping=None, file_type='png', canvas=<vis4d.vis.image.canvas.pillow_backend.PillowCanvasBackend object>, viewer=<vis4d.vis.image.viewer.matplotlib_viewer.MatplotlibImageViewer object>, **kwargs)[source]

Bounding box visualizer class.

Creates a new Visualizer for Image and Bounding Boxes.

Parameters:
  • n_colors (int) – How many colors should be used for the internal color map

  • class_id_mapping (dict[int, str]) – Mapping from class id to human readable name

  • file_type (str) – Desired file type

  • canvas (CanvasBackend) – Backend that is used to draw on images

  • viewer (ImageViewerBackend) – Backend that is used show images

process(cur_iter, images, image_names, boxes, scores=None, class_ids=None, track_ids=None)[source]

Processes a batch of data.

Parameters:
  • cur_iter (int) – Current iteration.

  • images (list[ArrayLike]) – Images to show.

  • image_names (list[str]) – Image names.

  • boxes (list[ArrayLikeFloat]) – List of predicted bounding boxes with shape [N, (x1, y1, x2, y2)], where N is the number of boxes.

  • scores (None | list[ArrayLikeFloat], optional) – List of predicted box scores each of shape [N]. Defaults to None.

  • class_ids (None | list[ArrayLikeInt], optional) – List of predicted class ids each of shape [N]. Defaults to None.

  • track_ids (None | list[ArrayLikeInt], optional) – List of predicted track ids each of shape [N]. Defaults to None.

Return type:

None

process_single_image(image, image_name, boxes, scores=None, class_ids=None, track_ids=None)[source]

Processes a single image entry.

Parameters:
  • image (ArrayLike) – Image to show.

  • image_name (str) – Image name.

  • boxes (ArrayLikeFloat) – Predicted bounding boxes with shape [N, (x1,y1,x2,y2)], where N is the number of boxes.

  • scores (None | ArrayLikeFloat, optional) – Predicted box scores of shape [N]. Defaults to None.

  • class_ids (None | ArrayLikeInt, optional) – Predicted class ids of shape [N]. Defaults to None.

  • track_ids (None | ArrayLikeInt, optional) – Predicted track ids of shape [N]. Defaults to None.

Return type:

None

reset()[source]

Reset visualizer.

Return type:

None

save_to_disk(cur_iter, output_folder)[source]

Saves the visualization to disk.

Writes all processes samples to the output folder naming each image <sample.image_name>.<filetype>.

Parameters:
  • cur_iter (int) – Current iteration.

  • output_folder (str) – Folder where the output should be written.

Return type:

None

show(cur_iter, blocking=True)[source]

Shows the processed images in a interactive window.

Parameters:
  • cur_iter (int) – Current iteration.

  • blocking (bool) – If the visualizer should be blocking i.e. wait for human input for each image. Defaults to True.

Return type:

None

class SegMaskVisualizer(*args, n_colors=50, class_id_mapping=None, file_type='png', color_palette=None, canvas=<vis4d.vis.image.canvas.pillow_backend.PillowCanvasBackend object>, viewer=<vis4d.vis.image.viewer.matplotlib_viewer.MatplotlibImageViewer object>, **kwargs)[source]

Segmentation mask visualizer class.

Creates a new Visualizer for Image and Bounding Boxes.

Parameters:
  • n_colors (int) – How many colors should be used for the color map.

  • class_id_mapping (dict[int, str]) – Mapping from class id to human readable name.

  • file_type (str) – Desired file type

  • color_palette (list[tuple[int, int, int]]) – Color palette for each class, in RGB format (0-255). If None, a random color palette with n_colors is generated automatically. Defaults to None.

  • canvas (CanvasBackend) – Backend that is used to draw on images

  • viewer (ImageViewerBackend) – Backend that is used show images

process(cur_iter, images, image_names, masks, class_ids=None)[source]

Processes a batch of data.

Parameters:
  • cur_iter (int) – Current iteration.

  • images (list[ArrayLikeFloat]) – Images to show.

  • image_names (list[str]) – Image names.

  • masks (list[ArrayLikeUInt]) – Segmentation masks to show, each with shape [H, W] or [N, H, W]. If the shape is [H, W], the mask is assumed to be a semantic segmentation mask with each pixel being the class id. If the shape is [N, H, W], each mask is assumed to be a binary mask with each pixel being either 0 or 1.

  • class_ids (list[ArrayLikeInt], optional) – Class ids for each mask, with shape [N]. If set, the masks are assumed to be binary masks and the length of class_ids must match the amount of masks. Defaults to None.

Return type:

None

process_single_image(image, image_name, masks, class_ids=None)[source]

Processes a single image entry.

Parameters:
  • image (ArrayLikeFloat) – Images to show.

  • image_name (str) – Name of the image.

  • masks (ArrayLikeUInt) – Binary masks to show, each with shape [N, H, W] or [H, W].

  • class_ids (ArrayLikeInt, optional) – Class ids for each mask, with shape [N]. Defaults to None.

Return type:

None

reset()[source]

Reset visualizer for new round of evaluation.

Return type:

None

save_to_disk(cur_iter, output_folder)[source]

Saves the visualization to disk.

Writes all processes samples to the output folder naming each image <sample.image_name>.<filetype>.

Parameters:
  • cur_iter (int) – Current iteration.

  • output_folder (str) – Folder where the output should be written.

Return type:

None

show(cur_iter, blocking=True)[source]

Shows the processed images in a interactive window.

Parameters:
  • cur_iter (int) – Current iteration.

  • blocking (bool) – If the visualizer should be blocking i.e. wait for human input for each image

Return type:

None

Modules

vis4d.vis.image.bbox3d_visualizer

Bounding box 3D visualizer.

vis4d.vis.image.bev_visualizer

BEV Bounding box 3D visualizer.

vis4d.vis.image.bounding_box_visualizer

Bounding box visualizer.

vis4d.vis.image.canvas

Vis4D image canvas backends.

vis4d.vis.image.seg_mask_visualizer

Segmentation mask visualizer.

vis4d.vis.image.util

Utility functions for image processing operations.

vis4d.vis.image.viewer

Viewer implementations to display images.