from_label_map_png#
- static rlemasklib.RLEMask.from_label_map_png(path=None, data=None)[source]#
Convert a PNG label map directly to a dict of RLEMasks.
Decodes PNG and builds RLEs in a single pass, avoiding intermediate numpy array allocation.
Label 0 is treated as background and not included in the output. Labels 1-255 become individual RLEMasks.
- Parameters:
path (Union[str, PathLike, None]) – Path to PNG file (str or Path).
data (Union[bytes, bytearray, memoryview, None]) – PNG data as bytes, bytearray, or memoryview.
- Returns:
A dict mapping label values (1-255) to RLEMask objects. Only labels that appear in the input are included.
- Raises:
ValueError – If neither path nor data is provided, or both are provided.
- Return type: