Draws bounding boxes on top of one image tensor
draw_bounding_boxes(
image,
boxes,
labels = NULL,
colors = NULL,
fill = FALSE,
width = 1,
font = c("serif", "plain"),
font_size = 10
)
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).
Tensor of size (N, 4) containing N bounding boxes in c(\(x_{min}\), \(y_{min}\), \(x_{max}\), \(y_{max}\)). format. Note that the boxes coordinates are absolute with respect to the image. In other words: \(0 \leq x_{min} < x_{max} < W \) and \(0 \leq y_{min} < y_{max} < W \).
character vector containing the labels of bounding boxes.
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 boxes.
If TRUE
fills the bounding box with specified color.
Width of text shift to the bounding box.
NULL for the current font family, or a character vector of length 2 for Hershey vector fonts.
The requested font size in points.
torch_tensor of size (C, H, W) of dtype uint8: Image Tensor with bounding boxes plotted.
Other image display:
draw_keypoints()
,
draw_segmentation_masks()
,
tensor_image_browse()
,
tensor_image_display()
,
vision_make_grid()
if (torch::torch_is_installed()) {
if (FALSE) { # \dontrun{
image <- torch::torch_randint(170, 250, size = c(3, 360, 360))$to(torch::torch_uint8())
x <- torch::torch_randint(low = 1, high = 160, size = c(12,1))
y <- torch::torch_randint(low = 1, high = 260, size = c(12,1))
boxes <- torch::torch_cat(c(x, y, x + 20, y + 10), dim = 2)
bboxed <- draw_bounding_boxes(image, boxes, colors = "black", fill = TRUE)
tensor_image_browse(bboxed)
} # }
}