opendvp.imaging.mask_to_polygons

opendvp.imaging.mask_to_polygons#

opendvp.imaging.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.

Return type:

GeoDataFrame

Parameters:#

mask_pathstr

Path to a 2D labeled segmentation mask TIFF. Pixel values represent cell IDs; background is 0.

simplifyfloat, optional

Tolerance for geometry simplification. If None, no simplification is performed.

max_memory_mbint, optional

Maximum memory (in MB) allowed to safely process the image (default: 16000).

Returns:#

gpd.GeoDataFrame

A GeoDataFrame containing polygons/multipolygons and their cell IDs.

Raises:#

ValueError

If the estimated memory usage exceeds max_memory_mb or cell IDs exceed int32 range.