mask_to_polygon
- cocohelper.utils.segmentation.mask_to_polygon(mask, simplify_tolerance=1.0, **kwargs)[source]
Converts segmentation mask to a list of polygons.
To reduce the number of vertices in the obtained polygon, try to increase the value of polygon_simplify_tolerance.
- Parameters:
mask (ndarray) – numpy array containing multiple segmentation masks. Each mask must be associated with a different number, where 0 is for background, and other numbers related to different objects. For example, objects of a class A may be associated with a value of 1, class B to values 10, class C to 255, and so on.
simplify_tolerance (float) – a tolerance value used to remove redundant vertexes for the polygons extracted from the mask.
**kwargs – extra parameters are ignored.
- Returns:
List of polygons segmentation masks.
- Return type:
List