Shortcuts

mmedit.utils.brush_stroke_mask

mmedit.utils.brush_stroke_mask(img_shape, num_vertices=(4, 12), mean_angle=1.2566370614359172, angle_range=0.41887902047863906, brush_width=(12, 40), max_loops=4, dtype='uint8')[source]

Generate free-form mask.

The method of generating free-form mask is in the following paper: Free-Form Image Inpainting with Gated Convolution.

When you set the config of this type of mask. You may note the usage of np.random.randint and the range of np.random.randint is [left, right).

We prefer to use uint8 as the data type of masks, which may be different from other codes in the community.

TODO: Rewrite the implementation of this function.

Parameters
  • img_shape (tuple[int]) – Size of the image.

  • num_vertices (int | tuple[int]) – Min and max number of vertices. If only give an integer, we will fix the number of vertices. Default: (4, 12).

  • mean_angle (float) – Mean value of the angle in each vertex. The angle is measured in radians. Default: 2 * math.pi / 5.

  • angle_range (float) – Range of the random angle. Default: 2 * math.pi / 15.

  • brush_width (int | tuple[int]) – (min_width, max_width). If only give an integer, we will fix the width of brush. Default: (12, 40).

  • max_loops (int) – The max number of for loops of drawing strokes. Default: 4.

  • np.dtype (str) – Indicate the data type of returned masks. Default: ‘uint8’.

Returns

Mask in the shape of (h, w, 1).

Return type

mask (np.ndarray)

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.