from_polygon#

static rlemasklib.RLEMask.from_polygon(poly, imshape=None, imsize=None)[source]#

Create an RLEMask object from a polygon.

Parameters:
  • poly – a polygon (numpy array of xy coordinates)

  • imshape – [height, width] of the desired mask (either this or imsize must be provided)

  • imsize – [width, height] of the desired mask (either this or imshape must be provided)

Returns:

An RLEMask object representing the input polygon (1 inside the polygon, 0 outside).

Return type:

RLEMask

Examples

Create a triangle from polygon vertices:

RLEMask.from_polygon(poly, imshape=(7, 9)) ==