Skip to main content

RLEMaskLib: Run-Length Encoded Mask Operations

This library provides efficient run-length encoded (RLE) operations for binary masks in Python. It is designed to be fast and memory efficient, and is particularly useful for working with large datasets. The library provides an intuitive and extensive object-oriented interface as well as a simpler functional one. To achieve high efficiency, the core functionality is implemented in C, and wrapped via Cython.

RLEMaskLib is fully compatible with the COCO mask format (in the form of dictionaries) but can also work directly with runlength sequences.

The library provides many operations on masks, including:

  • Set operations (complement, difference, symmetric difference) and custom boolean functions.
  • Crop, pad, tile, concatenate
  • Connected components extraction
  • Warp (affine, perspective, lens distortion)
  • Transpose, flip, rotate by multiples of 90 degrees
  • Binary morphology: dilate, erode, open, close
  • Convolve with arbitrary kernels
  • Directly create fully foreground and fully background masks
  • Decompress of COCO's compressed RLE format to integer run-lengths, and vice versa
  • Extra compression (optional) using gzip on top of the LEB128-like encoding used by the COCO API (~40% reduction beyond the COCO compression)
  • Object-oriented and functional APIs.

This library originates as a fork of the COCO API's pycocotools.mask module (which was originally written by Piotr Dollár and Tsung-Yi Lin) but now mostly consists of new code.

Installation

The library can be installed with pip from GitHub:

pip install git+https://github.com/isarandi/rlemasklib.git

Documentation

The documentation can be found at https://istvansarandi.com/docs/rlemasklib/.

Metadata

Release files for RLEMaskLib 0.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for RLEMaskLib 0.3.1
File Size Uploaded Provenance Actions
rlemasklib-0.3.1.tar.gz 450.4 kB Without provenance Details for rlemasklib-0.3.1.tar.gz

Release files / rlemasklib-0.3.1.tar.gz

Download URL rlemasklib-0.3.1.tar.gz
Size 450.4 kB
Tags Source
SHA-256 checksum
How to use checksums
e212cb7f37e6a31d1f4e2255eadf1437bcaa6860c6665139b05b8b0d41e4d51f
BLAKE2b-256 checksum
How to use checksums
1bf54ad1f86c0b5a9565857bda8e005742b8d64bdb25b4725ce614037af9c57b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.10.14

Security for RLEMaskLib 0.3.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page