tfm.vision.box_ops.bbox2mask

Converts bounding boxes to bitmasks.

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.

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)>