Shortcuts

mmedit.utils.random_bbox

mmedit.utils.random_bbox(img_shape, max_bbox_shape, max_bbox_delta=40, min_margin=20)[source]

Generate a random bbox for the mask on a given image.

In our implementation, the max value cannot be obtained since we use np.random.randint. And this may be different with other standard scripts in the community.

Parameters
  • img_shape (tuple[int]) – The size of a image, in the form of (h, w).

  • max_bbox_shape (int | tuple[int]) – Maximum shape of the mask box, in the form of (h, w). If it is an integer, the mask box will be square.

  • max_bbox_delta (int | tuple[int]) – Maximum delta of the mask box, in the form of (delta_h, delta_w). If it is an integer, delta_h and delta_w will be the same. Mask shape will be randomly sampled from the range of max_bbox_shape - max_bbox_delta and max_bbox_shape. Default: (40, 40).

  • min_margin (int | tuple[int]) – The minimum margin size from the edges of mask box to the image boarder, in the form of (margin_h, margin_w). If it is an integer, margin_h and margin_w will be the same. Default: (20, 20).

Returns

The generated box, (top, left, h, w).

Return type

tuple[int]

Read the Docs v: zyh/doc-notfound-extend
Versions
master
latest
stable
zyh-doc-notfound-extend
Downloads
pdf
html
epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.