tfm.vision.box_ops.bbox2mask
Stay organized with collections
Save and categorize content based on your preferences.
Converts bounding boxes to bitmasks.
tfm.vision.box_ops.bbox2mask(
bbox: tf.Tensor,
*,
image_height: int,
image_width: int,
dtype: tf.DType = tf.bool
) -> tf.Tensor
Args |
bbox
|
A tensor in shape (..., 4) with arbitrary numbers of batch dimensions,
representing the absolute coordinates (ymin, xmin, ymax, xmax) for each
bounding box.
|
image_height
|
an integer representing the height of the image.
|
image_width
|
an integer representing the width of the image.
|
dtype
|
DType of the output bitmasks.
|
Returns |
A tensor in shape (..., height, width) which stores the bitmasks created
from the bounding boxes. For example:
bbox2mask(tf.constant([[1,2,4,4]]),
image_height=5,
image_width=5,
dtype=tf.int32)
<tf.Tensor: shape=(1, 5, 5), dtype=int32, numpy=
array([[[0, 0, 0, 0, 0],
[0, 0, 1, 1, 0],
[0, 0, 1, 1, 0],
[0, 0, 1, 1, 0],
[0, 0, 0, 0, 0]]], dtype=int32)>
|
[null,null,["Last updated 2026-11-06 UTC."],[],[]]