Draw segmentation masks with their respective colors on top of a given RGB tensor image
draw_segmentation_masks(image, masks, alpha = 0.8, colors = NULL)
Tensor of shape (C x H x W) and dtype uint8
or dtype float
.
In case of dtype float, values are assumed to be in range \([0, 1]\).
C value for channel can only be 1 (grayscale) or 3 (RGB).
torch_tensor of shape (num_masks, H, W) or (H, W) and dtype bool.
number between 0 and 1 denoting the transparency of the masks.
character vector containing the colors of the boxes or single color for all boxes. The color can be represented as strings e.g. "red" or "#FF00FF". By default, viridis colors are generated for masks
torch_tensor of shape (3, H, W) and dtype uint8 of the image with segmentation masks drawn on top.
Other image display:
draw_bounding_boxes()
,
draw_keypoints()
,
tensor_image_browse()
,
tensor_image_display()
,
vision_make_grid()
if (torch::torch_is_installed()) {
image <- torch::torch_randint(170, 250, size = c(3, 360, 360))$to(torch::torch_uint8())
mask <- torch::torch_tril(torch::torch_ones(c(360, 360)))$to(torch::torch_bool())
masked_image <- draw_segmentation_masks(image, mask, alpha = 0.2)
tensor_image_browse(masked_image)
}