masks_to_boxes¶
- torchvision.ops.masks_to_boxes(masks: Tensor) Tensor [source]¶
Compute the bounding boxes around the provided masks.
Returns a [N, 4] tensor containing bounding boxes. The boxes are in
(x1, y1, x2, y2)
format with0 <= x1 < x2
and0 <= y1 < y2
.- Parameters:
masks (Tensor[N, H, W]) – masks to transform where N is the number of masks and (H, W) are the spatial dimensions.
- Returns:
bounding boxes
- Return type:
Tensor[N, 4]
Examples using
masks_to_boxes
:Repurposing masks into bounding boxes
Repurposing masks into bounding boxes