Utility functions around image segmentation masks and turning them into polygons.
You can install the library via pip (or pip3):
pip install simple_mask_utilsOr directly from the repo:
pip install https://github.com/waikato-datamining/simple-mask-utils.gitfrom 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 coordinatesSee also this example.