opendvp.imaging.mask_to_polygons#
- mask_to_polygons(mask_path, simplify=None, max_memory_mb=16000)#
Convert a labeled segmentation mask (TIFF file) into a GeoDataFrame of polygons and/or multipolygons.
- Parameters:
mask_path (str) – Path to a 2D labeled segmentation mask TIFF. Pixel values represent cell IDs; background is 0.
simplify (float, optional) – Tolerance for geometry simplification. If None, no simplification is performed.
max_memory_mb (int, optional) – Maximum memory (in MB) allowed to safely process the image (default: 16000).
- Returns:
A GeoDataFrame containing polygons/multipolygons and their cell IDs.
- Return type:
- Raises:
ValueError – If the estimated memory usage exceeds max_memory_mb or cell IDs exceed int32 range.