Skip to main content

RLEMaskLib: Run-Length Encoded Mask Operations

Read the Docs PyPI - Version License: MIT

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

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.8.0
File Size Uploaded Provenance Actions
rlemasklib-0.8.0.tar.gz 760.8 kB With provenance Details for rlemasklib-0.8.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for RLEMaskLib 0.8.0
File Actions
rlemasklib-0.8.0-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details for rlemasklib-0.8.0-cp313-cp313-win_amd64.whl
rlemasklib-0.8.0-cp313-cp313-manylinux_2_28_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.28+ x86-64 Details for rlemasklib-0.8.0-cp313-cp313-manylinux_2_28_x86_64.whl
rlemasklib-0.8.0-cp313-cp313-macosx_11_0_arm64.whl CPython 3.13 CPython 3.13 macOS 11.0+ ARM64 Details for rlemasklib-0.8.0-cp313-cp313-macosx_11_0_arm64.whl
rlemasklib-0.8.0-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details for rlemasklib-0.8.0-cp312-cp312-win_amd64.whl
rlemasklib-0.8.0-cp312-cp312-manylinux_2_28_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.28+ x86-64 Details for rlemasklib-0.8.0-cp312-cp312-manylinux_2_28_x86_64.whl
rlemasklib-0.8.0-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details for rlemasklib-0.8.0-cp312-cp312-macosx_11_0_arm64.whl
rlemasklib-0.8.0-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details for rlemasklib-0.8.0-cp311-cp311-win_amd64.whl
rlemasklib-0.8.0-cp311-cp311-manylinux_2_28_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.28+ x86-64 Details for rlemasklib-0.8.0-cp311-cp311-manylinux_2_28_x86_64.whl
rlemasklib-0.8.0-cp311-cp311-macosx_11_0_arm64.whl CPython 3.11 CPython 3.11 macOS 11.0+ ARM64 Details for rlemasklib-0.8.0-cp311-cp311-macosx_11_0_arm64.whl
rlemasklib-0.8.0-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details for rlemasklib-0.8.0-cp310-cp310-win_amd64.whl
rlemasklib-0.8.0-cp310-cp310-manylinux_2_28_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.28+ x86-64 Details for rlemasklib-0.8.0-cp310-cp310-manylinux_2_28_x86_64.whl
rlemasklib-0.8.0-cp310-cp310-macosx_11_0_arm64.whl CPython 3.10 CPython 3.10 macOS 11.0+ ARM64 Details for rlemasklib-0.8.0-cp310-cp310-macosx_11_0_arm64.whl

Total release size: 21.3 MB

Release files / rlemasklib-0.8.0.tar.gz

Download URL rlemasklib-0.8.0.tar.gz
Size 760.8 kB
Tags Source
SHA-256 checksum
How to use checksums
c4ec6721fcc00f41e5de2f253c995a78f89af17006029a779d8aceb34ce137da
BLAKE2b-256 checksum
How to use checksums
33922fee088ee7a3ada1b36756117c2e6739d7f47ea375b616e5fa0a05590a93
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.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 Jul 23, 2026.

Transparency log

Release files / rlemasklib-0.8.0-cp313-cp313-win_amd64.whl

Download URL rlemasklib-0.8.0-cp313-cp313-win_amd64.whl
Size 494.4 kB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
6cffbd71ffd2e138d4ddd731e798a309fdb103e09d8378cedc51ee94d0669255
BLAKE2b-256 checksum
How to use checksums
7a35c118e0a1576ee7400a850eee6af77a1ee6ed8515e836d82e3f2c49967b2c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.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 Jul 23, 2026.

Transparency log

Release files / rlemasklib-0.8.0-cp313-cp313-manylinux_2_28_x86_64.whl

Download URL rlemasklib-0.8.0-cp313-cp313-manylinux_2_28_x86_64.whl
Size 3.4 MB
Tags CPython 3.13 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
30254ead8ea5f11f7a484286d3a5228325ecd5e33ed214528d5cf2447cd2f0ca
BLAKE2b-256 checksum
How to use checksums
2506d2f2c6f4b776b24edb6c782887f08a5d985a73dcecd8d1d97071622eb7af
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.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 Jul 23, 2026.

Transparency log

Release files / rlemasklib-0.8.0-cp313-cp313-macosx_11_0_arm64.whl

Download URL rlemasklib-0.8.0-cp313-cp313-macosx_11_0_arm64.whl
Size 1.1 MB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
670ce7b12513c1939d255971375e612ec7d0baafe87892ee3b91fadfa93e4c63
BLAKE2b-256 checksum
How to use checksums
1b226205117ba8eaba209535ce59e6e51a43717a1c4e1ec3bc90f8ef34b4b7ae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.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 Jul 23, 2026.

Transparency log

Release files / rlemasklib-0.8.0-cp312-cp312-win_amd64.whl

Download URL rlemasklib-0.8.0-cp312-cp312-win_amd64.whl
Size 492.2 kB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
205fde80c402534aa286e1743eadf420e42f318396168ac335b7201203948d74
BLAKE2b-256 checksum
How to use checksums
d3f1408e5b37ca99eb361c3598db2464d01d57351cf011172ef1a6e1266b29b4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.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 Jul 23, 2026.

Transparency log

Release files / rlemasklib-0.8.0-cp312-cp312-manylinux_2_28_x86_64.whl

Download URL rlemasklib-0.8.0-cp312-cp312-manylinux_2_28_x86_64.whl
Size 3.5 MB
Tags CPython 3.12 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
0d120298d1cbbb542e42b5f7c0533c31ade382b35689c7d43ee834769c55e70c
BLAKE2b-256 checksum
How to use checksums
513dba1d243f30701fe8b0f9ab59c918dc7a7428a730cec98e67939a0b53086d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.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 Jul 23, 2026.

Transparency log

Release files / rlemasklib-0.8.0-cp312-cp312-macosx_11_0_arm64.whl

Download URL rlemasklib-0.8.0-cp312-cp312-macosx_11_0_arm64.whl
Size 1.1 MB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
629cb5ba1c454ea81216ab698a89a86278d25877ba337083416d7be3d8988a5f
BLAKE2b-256 checksum
How to use checksums
3e63e8bc30ee5a113e9fcf6bcf7e63ac45638a6eb2b3aa77e2de5cd209034334
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.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 Jul 23, 2026.

Transparency log

Release files / rlemasklib-0.8.0-cp311-cp311-win_amd64.whl

Download URL rlemasklib-0.8.0-cp311-cp311-win_amd64.whl
Size 503.0 kB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
fcc3ecc0c67fb9b0ad8d2a1be49ffaaa721b095911103bd2ba93621f991a431e
BLAKE2b-256 checksum
How to use checksums
895e547e5dfd4b6f762c6367c10805c52f1a5c33d3ab9f1f8840cc8d869053ab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.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 Jul 23, 2026.

Transparency log

Release files / rlemasklib-0.8.0-cp311-cp311-manylinux_2_28_x86_64.whl

Download URL rlemasklib-0.8.0-cp311-cp311-manylinux_2_28_x86_64.whl
Size 3.6 MB
Tags CPython 3.11 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
241a4415c99b6d596c9d27d4fcf058440cf36b085b757caf264163c0348e144e
BLAKE2b-256 checksum
How to use checksums
4d92630c4ed3bc2f560a087ccff4b3041b6e76648783ca62d830749abe57c791
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.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 Jul 23, 2026.

Transparency log

Release files / rlemasklib-0.8.0-cp311-cp311-macosx_11_0_arm64.whl

Download URL rlemasklib-0.8.0-cp311-cp311-macosx_11_0_arm64.whl
Size 1.1 MB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
5a138b78fcbc69fac54be83aac858a756eaa7442826a4299206eab8b1938e66e
BLAKE2b-256 checksum
How to use checksums
d10896e9fea8e21a94df652450ca171f5d48f044a7c993bd773ff9b1ff82c06f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.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 Jul 23, 2026.

Transparency log

Release files / rlemasklib-0.8.0-cp310-cp310-win_amd64.whl

Download URL rlemasklib-0.8.0-cp310-cp310-win_amd64.whl
Size 501.1 kB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
2cb95da2e89dd7d336520b87594bd655ebf7d09019bffe1c1ecbb98af75c206f
BLAKE2b-256 checksum
How to use checksums
d9835aebdffb0122e22b968a4a3f88789360feb32c438f5ff05d46669b0a3404
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.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 Jul 23, 2026.

Transparency log

Release files / rlemasklib-0.8.0-cp310-cp310-manylinux_2_28_x86_64.whl

Download URL rlemasklib-0.8.0-cp310-cp310-manylinux_2_28_x86_64.whl
Size 3.5 MB
Tags CPython 3.10 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
b6bbafb3162314d1726584b426a726a3bdf590d8e035b46145108565cdf47edc
BLAKE2b-256 checksum
How to use checksums
9eb5e7eb2015f725f7ba6391371ae12efb5d8307eebed5293c266696a192ba13
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.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 Jul 23, 2026.

Transparency log

Release files / rlemasklib-0.8.0-cp310-cp310-macosx_11_0_arm64.whl

Download URL rlemasklib-0.8.0-cp310-cp310-macosx_11_0_arm64.whl
Size 1.1 MB
Tags CPython 3.10 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
7d29d6b0ab73912d813aac16905dd164e7e6f89f937a41e7a5880b294d7c7dfb
BLAKE2b-256 checksum
How to use checksums
107a90bef9079242a3c1d3127a7bc5f756e7f77524d308fe22abd6e2a3eb00d2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.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 Jul 23, 2026.

Transparency log

Security for RLEMaskLib 0.8.0

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.

Full provenance

All 13 files in this release have been uploaded with provenance metadata.

Select from 13 files

Attestation for rlemasklib-0.8.0.tar.gz

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 Jul 23, 2026.

Transparency log

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