RLEMaskLib: Run-Length Encoded Mask Operations
Fast run-length encoded (RLE) binary mask operations in Python. Core implemented in C via Cython for efficiency.
The API is designed to feel like NumPy and OpenCV, with familiar slicing, boolean operators, and method names.
Fully compatible with the COCO mask format.
Installation
pip install rlemasklib
Quick Start
import numpy as np
from rlemasklib import RLEMask
# Create from numpy array
mask = RLEMask(np.array([
[0, 1, 1],
[1, 1, 0],
[0, 0, 1]
]))
mask1 = RLEMask.from_array(np.eye(3, dtype=np.uint8))
mask2 = RLEMask.from_array(np.eye(3, dtype=np.uint8)[::-1])
# Boolean operations
union = mask1 | mask2
intersection = mask1 & mask2
difference = mask1 - mask2
complement = ~mask
# Morphology
eroded = mask.erode3x3()
dilated = mask.dilate3x3()
# Geometric transforms (NumPy/OpenCV style)
flipped = mask.fliplr()
rotated = mask.rot90()
cropped = mask[10:50, 20:80] # slicing like numpy
resized = mask.resize((256, 256))
# Analysis
area = mask.area()
bbox = mask.bbox()
components = mask.connected_components()
# COCO format I/O
coco_dict = mask.to_dict() # {'size': [h, w], 'counts': b'...'}
mask = RLEMask.from_dict(coco_dict)
Features
- Boolean operations: union, intersection, difference, complement, XOR, custom functions
- Morphology: erode, dilate, open, close (circle/square/diamond/cross kernels of any size)
- Geometric: crop, pad, tile, flip, transpose, rotate, resize, warp (affine/perspective)
- Analysis: area, bounding box, connected components, largest interior rectangle, IoU
- I/O: COCO format, numpy arrays, polygons, bounding boxes, circles
- Compression: LEB128 (COCO-compatible) + optional gzip (~40% smaller)
APIs
Object-oriented (recommended): Work with RLEMask objects for chained operations.
Functional (legacy): Dict-to-dict operations, compatible with COCO's pycocotools.mask.
Documentation
Full documentation with visual examples: rlemasklib.readthedocs.io
Origin
Fork of COCO API's pycocotools.mask (by Piotr Dollár and Tsung-Yi Lin), now mostly new code.
Metadata
Release files for RLEMaskLib 0.8.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| rlemasklib-0.8.1.tar.gz | 805.5 kB | Details |
Built distributions (wheels)
Total release size: 27.6 MB
Release files / rlemasklib-0.8.1.tar.gz
| Download URL | rlemasklib-0.8.1.tar.gz |
|---|---|
| Size | 805.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4abf3463195345d408fe56f45df6423207ce032f9d91781a2efef095ed2dffa7
|
|
BLAKE2b-256 checksum How to use checksums |
9fe5c8aea39048d77633fc178b78af469c71ac1f7d7b6be494ad197dbadc7459
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.
Transparency logRelease files / rlemasklib-0.8.1-cp313-cp313-win_amd64.whl
| Download URL | rlemasklib-0.8.1-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 507.9 kB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
94a4892985bd4405b63c79278e86f0f966b263c130524add56c5298407b51941
|
|
BLAKE2b-256 checksum How to use checksums |
37d2c80643f03273d4136241bc417df71d7f649c8fc5c6f37f287a41989e9d04
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.
Transparency logRelease files / rlemasklib-0.8.1-cp313-cp313-manylinux_2_28_x86_64.whl
| Download URL | rlemasklib-0.8.1-cp313-cp313-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 3.6 MB |
| Tags | CPython 3.13 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
ea968a0672792fb8a0784c225145b3c262a1a912fac2d244c18f41af0c073c24
|
|
BLAKE2b-256 checksum How to use checksums |
ec40934277b18256b6e6ec717fef27668381cfd24205414d840f9c064aa37630
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.
Transparency logRelease files / rlemasklib-0.8.1-cp313-cp313-macosx_11_0_x86_64.whl
| Download URL | rlemasklib-0.8.1-cp313-cp313-macosx_11_0_x86_64.whl |
|---|---|
| Size | 1.3 MB |
| Tags | CPython 3.13 macOS 11.0+ x86-64 |
|
SHA-256 checksum How to use checksums |
d9b76b138fd6428bcfbc50fa70424e5219b92fa4921de4772881df8292ebad78
|
|
BLAKE2b-256 checksum How to use checksums |
cb3662f342c696d7fc2df5153f393c4ad5c00b39d027f9dcf1010b7d2c6c73de
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.
Transparency logRelease files / rlemasklib-0.8.1-cp313-cp313-macosx_11_0_arm64.whl
| Download URL | rlemasklib-0.8.1-cp313-cp313-macosx_11_0_arm64.whl |
|---|---|
| Size | 1.2 MB |
| Tags | CPython 3.13 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
344adb4bd3f2e7fc0cf5fdaed8ae3092e473d4fa53e8390222febc9e44d12bf8
|
|
BLAKE2b-256 checksum How to use checksums |
55c5439b8f8dd7dabee4f3d6a05903358054743dd343e388fe57b0eaa75a821b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.
Transparency logRelease files / rlemasklib-0.8.1-cp312-cp312-win_amd64.whl
| Download URL | rlemasklib-0.8.1-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 507.7 kB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
069f758d44035f76ad66743f9d90a472fec2864b3aaf3560581489db9487b340
|
|
BLAKE2b-256 checksum How to use checksums |
0eb8e8be015479f72afb69a0817229109bf5bc10585496e272502091287366f0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.
Transparency logRelease files / rlemasklib-0.8.1-cp312-cp312-manylinux_2_28_x86_64.whl
| Download URL | rlemasklib-0.8.1-cp312-cp312-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 3.6 MB |
| Tags | CPython 3.12 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
01975c42fb7bac289ec6fbe9e24f899248f81429c45233c766af0b776173ff53
|
|
BLAKE2b-256 checksum How to use checksums |
4396f5b45bc64152bc49cf98531c21a9bb7f9005a21e116d356018a0aa5c4cc0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.
Transparency logRelease files / rlemasklib-0.8.1-cp312-cp312-macosx_11_0_x86_64.whl
| Download URL | rlemasklib-0.8.1-cp312-cp312-macosx_11_0_x86_64.whl |
|---|---|
| Size | 1.3 MB |
| Tags | CPython 3.12 macOS 11.0+ x86-64 |
|
SHA-256 checksum How to use checksums |
73e328e730b39a54e94a3e1ea07619d855163b85d1ed496069f3872b549034a0
|
|
BLAKE2b-256 checksum How to use checksums |
361bb62e24791f9d4cb80cdbe016cb7e58677b81ca05312a4935133e6417856a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.
Transparency logRelease files / rlemasklib-0.8.1-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | rlemasklib-0.8.1-cp312-cp312-macosx_11_0_arm64.whl |
|---|---|
| Size | 1.2 MB |
| Tags | CPython 3.12 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
b636769439da0bef441e417ef11d037c59c5afeae69ba06dbef2c9618df909b3
|
|
BLAKE2b-256 checksum How to use checksums |
d5af04d069546c85fa801912ae0d65c3093feadff394eca6b5330154994f7f2f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.
Transparency logRelease files / rlemasklib-0.8.1-cp311-cp311-win_amd64.whl
| Download URL | rlemasklib-0.8.1-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 524.4 kB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
c0e39cf4b377171a23ef39f8d06ff74be0bc14cb36620a0b01c0e139fdd076b6
|
|
BLAKE2b-256 checksum How to use checksums |
2f041101156ee3d6943dcb6b79281a3d62d9096ec1e3f6b41fa0148ccf82717d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.
Transparency logRelease files / rlemasklib-0.8.1-cp311-cp311-manylinux_2_28_x86_64.whl
| Download URL | rlemasklib-0.8.1-cp311-cp311-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 3.8 MB |
| Tags | CPython 3.11 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
a3023a1a8e945d1214d0094c367f7c4bc18898d04ab5106f7d45d32cfa3696b4
|
|
BLAKE2b-256 checksum How to use checksums |
eb886454f49a5c262e5c69e4a71ea30be4e0486160fcdbd017e53ddd1e453e8f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.
Transparency logRelease files / rlemasklib-0.8.1-cp311-cp311-macosx_11_0_x86_64.whl
| Download URL | rlemasklib-0.8.1-cp311-cp311-macosx_11_0_x86_64.whl |
|---|---|
| Size | 1.3 MB |
| Tags | CPython 3.11 macOS 11.0+ x86-64 |
|
SHA-256 checksum How to use checksums |
7b06a5a48a837e440e2fcc3f3303e989acce16338f669808af81876b27c7107b
|
|
BLAKE2b-256 checksum How to use checksums |
0a10adf1815f38d78f26c7ee44bfedb0939e3a17ed41518bc721cb2f09fac4e4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.
Transparency logRelease files / rlemasklib-0.8.1-cp311-cp311-macosx_11_0_arm64.whl
| Download URL | rlemasklib-0.8.1-cp311-cp311-macosx_11_0_arm64.whl |
|---|---|
| Size | 1.2 MB |
| Tags | CPython 3.11 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
7efc524437ad21fa4b8d89920ff508593f8d46f06153360669df969e43b1bb06
|
|
BLAKE2b-256 checksum How to use checksums |
74f0915bba05aa321e3df1af2855ce6131b55150468408d8814237c0febf0d45
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.
Transparency logRelease files / rlemasklib-0.8.1-cp310-cp310-win_amd64.whl
| Download URL | rlemasklib-0.8.1-cp310-cp310-win_amd64.whl |
|---|---|
| Size | 523.6 kB |
| Tags | CPython 3.10 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
07283417e0392939e901e44ba3f1494bc2d8eaf8c443ed2b873893ca3a40ffdf
|
|
BLAKE2b-256 checksum How to use checksums |
fbe01a2b130eedf62e550514dd13319cabde7fa40de830f77700872823e04ec3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.
Transparency logRelease files / rlemasklib-0.8.1-cp310-cp310-manylinux_2_28_x86_64.whl
| Download URL | rlemasklib-0.8.1-cp310-cp310-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 3.7 MB |
| Tags | CPython 3.10 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
ea148570554a7bbf9a58bf6dd6e7eb5e4a21a2ad86d179a1debfd8d1c68cf3e9
|
|
BLAKE2b-256 checksum How to use checksums |
6d738fcaab2a82388b064efc655194564ab15051beafffbbba822c1d79d9d8be
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.
Transparency logRelease files / rlemasklib-0.8.1-cp310-cp310-macosx_11_0_x86_64.whl
| Download URL | rlemasklib-0.8.1-cp310-cp310-macosx_11_0_x86_64.whl |
|---|---|
| Size | 1.3 MB |
| Tags | CPython 3.10 macOS 11.0+ x86-64 |
|
SHA-256 checksum How to use checksums |
c0e777160a70162f26160069f39605d1ab826f4d23af1d00ece3ab10d641c71a
|
|
BLAKE2b-256 checksum How to use checksums |
87e3d8a5670a349a3dda41ae352d9d1337bbf50e90d3f317bdfba1f7940403bc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.
Transparency logRelease files / rlemasklib-0.8.1-cp310-cp310-macosx_11_0_arm64.whl
| Download URL | rlemasklib-0.8.1-cp310-cp310-macosx_11_0_arm64.whl |
|---|---|
| Size | 1.2 MB |
| Tags | CPython 3.10 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
fffe40d0b5192efa78956f2f0bef7c4ec81ddfd1c3d285572589bd1460c13c42
|
|
BLAKE2b-256 checksum How to use checksums |
4abf39adf6196dabc0f3b977d47d6ac5fd65d335d8eb75e4f85b9e1af719c2d2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.
Transparency log