Skip to main content

Manipulate run-length-encoded image masks

Project description

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/.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rlemasklib-0.3.2.tar.gz (450.9 kB view details)

Uploaded Source

File details

Details for the file rlemasklib-0.3.2.tar.gz.

File metadata

  • Download URL: rlemasklib-0.3.2.tar.gz
  • Upload date:
  • Size: 450.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.10.14

File hashes

Hashes for rlemasklib-0.3.2.tar.gz
Algorithm Hash digest
SHA256 aea3455f0db2cb8c21b3f2a83187ee022fe7b55c41f6bae727641fb2d4282720
MD5 232b8e38d14349d1ed8c1eaaef310ae7
BLAKE2b-256 e9e33a9b5ff6aa3994341a45b4781d4554cfc2bb5b4ad23b6d4527401dd5d797

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page