https://github.com/isarandi/rlemasklib
Manipulate run-length encoded image masks
https://github.com/isarandi/rlemasklib
compression-algorithm computer-vision cython image-mask image-masking image-processing image-segmentation mask python run-length run-length-encoding runlengthencoding segmentation
Last synced: about 1 month ago
JSON representation
Manipulate run-length encoded image masks
- Host: GitHub
- URL: https://github.com/isarandi/rlemasklib
- Owner: isarandi
- License: other
- Created: 2023-06-05T21:52:43.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2025-04-09T18:12:37.000Z (about 1 month ago)
- Last Synced: 2025-04-09T19:05:25.656Z (about 1 month ago)
- Topics: compression-algorithm, computer-vision, cython, image-mask, image-masking, image-processing, image-segmentation, mask, python, run-length, run-length-encoding, runlengthencoding, segmentation
- Language: C
- Homepage: https://rlemasklib.readthedocs.io
- Size: 170 KB
- Stars: 9
- Watchers: 1
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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](https://github.com/cocodataset/cocoapi)'s `pycocotools.mask` module (which was originally written by Piotr Dollár and Tsung-Yi Lin) but now mostly consists of new code.
## Installation
```bash
pip install rlemasklib
```## Documentation
See [https://rlemasklib.readthedocs.io/](https://rlemasklib.readthedocs.io/).