to_dict#

rlemasklib.RLEMask.to_dict(zlevel=None)[source]#

Convert the RLE mask to a dictionary.

Returns:

A dictionary with the keys "size" and "counts" or "zcounts".

  • "size" – [height, width] of the mask

  • "counts" – LEB128-like compressed run-length counts as in pycocotools, or

  • "zcounts"– if zlevel is provided, "counts" is further compressed using zlib

Parameters:

zlevel (Optional[int])

Return type:

dict

See also

from_dict()