core.services.utils.annotations¶
annotations
¶
Functions:
| Name | Description |
|---|---|
mask_to_polygons |
Convert a binary segmentation mask into a list of polygons. |
mask_to_polygons(mask)
¶
Convert a binary segmentation mask into a list of polygons.
This function extracts the external contours from a 2D binary mask and converts them into polygon representations. Each polygon is a NumPy array of (x, y) coordinates. Contours with fewer than 3 points are discarded to ensure valid polygon shapes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
ndarray
|
A 2D NumPy array representing the binary mask, where non-zero pixels indicate the segmented region. |
required |
Returns:
| Type | Description |
|---|---|
list[ndarray]
|
list[np.ndarray]: A list of polygons extracted from the mask. Each polygon is a NumPy array of shape (N, 2) with integer coordinates, where N is the number of points in the polygon. |