Skip to content

waikato-datamining/simple-mask-utils

Repository files navigation

simple-mask-utils

Utility functions around image segmentation masks and turning them into polygons.

Installation

You can install the library via pip (or pip3):

pip install simple_mask_utils

Or directly from the repo:

pip install https://github.com/waikato-datamining/simple-mask-utils.git

Usage

from smu import mask_to_polygon, polygon_to_lists

mask = ...  # binary mask (0/1) or float mask (0-1)
polys = mask_to_polygon(mask)  # determine polygons
for poly in polys:
    px, py = polygon_to_lists(poly, swap_x_y=True, as_type="int")  # get coordinates

See also this example.