davisinteractive.utils.visualization

plot_scribble

plot_scribble(ax, scribble, frame, output_size=None, **kwargs)
Plot scribbles into an axis.

Arguments

  • ax: Matplotlib Axis. Axis where to plot the scribble lines.
  • scribbles: Scribble. Scribble to plot.
  • frame: Integer. Frame of the scribble to plot.
  • output_size: Tuple. Image size to scale the scribble points (H, W).
  • **kwargs: Dictionary. Additional parameters to pass at the ax.plot(**kwargs) method.

Returns

matplotlib.axis: Returns the given axis with the scribbles plotted on it.

draw_scribble

draw_scribble(img, scribble, frame, output_size=None, width=5)
Draw scribbles into a PIL Image.

Arguments

  • img: PIL Image. Image where to draw the scribbles.
  • scribbles: Scribble. Scribble to plot.
  • frame: Integer. Frame of the scribble to plot.
  • output_size: Tuple. Image size to scale the scribble points (H, W).
  • width: Integer. Width of the drawed lines.

Returns

PIL Image: Returns the original image img with the scribble draw on it.

overlay_mask

overlay_mask(im, ann, alpha=0.5, colors=None, contour_thickness=None)
Overlay mask over image.

This function allows you to overlay a mask over an image with some transparency.

Arguments

  • im: Numpy Array. Array with the image. The shape must be (H, W, 3) and the pixels must be represented as np.uint8 data type.
  • ann: Numpy Array. Array with the mask. The shape must be (H, W) and the values must be intergers
  • alpha: Float. Proportion of alpha to apply at the overlaid mask.
  • colors: Numpy Array. Optional custom colormap. It must have shape (N, 3) being N the maximum number of colors to represent.
  • contour_thickness: Integer. Thickness of each object index contour draw over the overlay. This function requires to have installed the package opencv-python.

Returns

Numpy Array: Image of the overlay with shape (H, W, 3) and data type np.uint8.