Skip to main content

Manipulate run-length-encoded image masks

Project description

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]
]))

# 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 (3x3, 5x5, arbitrary kernels)
  • 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.

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.6.0.tar.gz (651.6 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

rlemasklib-0.6.0-cp313-cp313-win_amd64.whl (413.2 kB view details)

Uploaded CPython 3.13Windows x86-64

rlemasklib-0.6.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.8 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

rlemasklib-0.6.0-cp313-cp313-macosx_11_0_arm64.whl (963.5 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

rlemasklib-0.6.0-cp312-cp312-win_amd64.whl (411.4 kB view details)

Uploaded CPython 3.12Windows x86-64

rlemasklib-0.6.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.8 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

rlemasklib-0.6.0-cp312-cp312-macosx_11_0_arm64.whl (964.3 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

rlemasklib-0.6.0-cp311-cp311-win_amd64.whl (418.1 kB view details)

Uploaded CPython 3.11Windows x86-64

rlemasklib-0.6.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.9 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

rlemasklib-0.6.0-cp311-cp311-macosx_11_0_arm64.whl (962.6 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

rlemasklib-0.6.0-cp310-cp310-win_amd64.whl (417.3 kB view details)

Uploaded CPython 3.10Windows x86-64

rlemasklib-0.6.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.8 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

rlemasklib-0.6.0-cp310-cp310-macosx_11_0_arm64.whl (964.8 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

rlemasklib-0.6.0-cp39-cp39-win_amd64.whl (417.7 kB view details)

Uploaded CPython 3.9Windows x86-64

rlemasklib-0.6.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.8 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

rlemasklib-0.6.0-cp39-cp39-macosx_11_0_arm64.whl (966.1 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

rlemasklib-0.6.0-cp38-cp38-win_amd64.whl (420.9 kB view details)

Uploaded CPython 3.8Windows x86-64

rlemasklib-0.6.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.9 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

rlemasklib-0.6.0-cp38-cp38-macosx_11_0_arm64.whl (969.7 kB view details)

Uploaded CPython 3.8macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: rlemasklib-0.6.0.tar.gz
  • Upload date:
  • Size: 651.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for rlemasklib-0.6.0.tar.gz
Algorithm Hash digest
SHA256 3665f51436745322b2fcae45fa66d3c2fecbae04dc32c674b8ea8382d93ac87f
MD5 4261e6b376f061074382a17fcf028b15
BLAKE2b-256 25232bcc0f995e5f7a0bd1faf022d0f5059c31f3b04acdaddd728a9f4cac4eac

See more details on using hashes here.

Provenance

The following attestation bundles were made for rlemasklib-0.6.0.tar.gz:

Publisher: python-publish.yml on isarandi/rlemasklib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rlemasklib-0.6.0-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: rlemasklib-0.6.0-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 413.2 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for rlemasklib-0.6.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 243af767a1da4b3adfe30744e30d0e1911b8262c2f93b8a1ab25d4bb36319efd
MD5 2edd1aeac6a4cb6eaa279fa452d19c6a
BLAKE2b-256 9906477d210fe9ba6cb759d822986f1f73fe7d9978eec0f6e5b7a8f3e691d190

See more details on using hashes here.

Provenance

The following attestation bundles were made for rlemasklib-0.6.0-cp313-cp313-win_amd64.whl:

Publisher: python-publish.yml on isarandi/rlemasklib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rlemasklib-0.6.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rlemasklib-0.6.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 cecd9d6c35413a485d69836747a3e02a4d3dde6bec56e615d870f2d8cde34274
MD5 d8b72d7304a4ddef9cf45b92dcf33243
BLAKE2b-256 f4b937e772c902baa347205358991f4b56d536696625d6e5bc55a88431adc8c0

See more details on using hashes here.

Provenance

The following attestation bundles were made for rlemasklib-0.6.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: python-publish.yml on isarandi/rlemasklib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rlemasklib-0.6.0-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rlemasklib-0.6.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7b2c06fe156826418a926e93e09c0ae0631ad4e1246fe272887812164a26d0bc
MD5 66fc4d7ca27d5337424b4e3a43a828fb
BLAKE2b-256 b518961fa084c86abef086ae49999b60df781f8c3813f9db6dc16877b9816996

See more details on using hashes here.

Provenance

The following attestation bundles were made for rlemasklib-0.6.0-cp313-cp313-macosx_11_0_arm64.whl:

Publisher: python-publish.yml on isarandi/rlemasklib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rlemasklib-0.6.0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: rlemasklib-0.6.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 411.4 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for rlemasklib-0.6.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 94cbe6421dc7f0890483ee2f93ac68f141858b8adf491b8372d50148ad1ed0b8
MD5 e637861ea06e36afef974c95ea63ea1b
BLAKE2b-256 59767e83ee4b4b6ecdcf171f80074e0b9b4127651e1fc8ea61abeba11516a7db

See more details on using hashes here.

Provenance

The following attestation bundles were made for rlemasklib-0.6.0-cp312-cp312-win_amd64.whl:

Publisher: python-publish.yml on isarandi/rlemasklib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rlemasklib-0.6.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rlemasklib-0.6.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a89e9276de097606eba692fbbb8e6e97efd0252ad435a117e13eb419aed7ee75
MD5 6cb436814c7a5e50acca6c195b4db600
BLAKE2b-256 0ea675f5f946d1dad8f4dced530b1c228577818b15e48e40f46da6fce400507f

See more details on using hashes here.

Provenance

The following attestation bundles were made for rlemasklib-0.6.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: python-publish.yml on isarandi/rlemasklib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rlemasklib-0.6.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rlemasklib-0.6.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ac04e32315cffcaf5e7cb25dd9cd7b512eaeabff9145cabcbb40d796a3ff0bbb
MD5 3fc4be6d379d7a1490ae223869910263
BLAKE2b-256 4a0fbf3b5fdbed57d410591265fae385fe4d4d9a0d8178fe3215f7ea7c5b646c

See more details on using hashes here.

Provenance

The following attestation bundles were made for rlemasklib-0.6.0-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: python-publish.yml on isarandi/rlemasklib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rlemasklib-0.6.0-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: rlemasklib-0.6.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 418.1 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for rlemasklib-0.6.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 d4dfe60a8974967292b65750ce63523cd15c3b0203cb05fc12508eba038a5203
MD5 65deedbe6b33aaff064d5d29e2bb4bc6
BLAKE2b-256 895b456963e5e3f16e155de84ffc8b324da2554b0aaf37bdaf36fdb0f0bfc83d

See more details on using hashes here.

Provenance

The following attestation bundles were made for rlemasklib-0.6.0-cp311-cp311-win_amd64.whl:

Publisher: python-publish.yml on isarandi/rlemasklib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rlemasklib-0.6.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rlemasklib-0.6.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 21908d4a98055e3c03330a50af068450ead9cb62ec64a28437a9aab973a7233e
MD5 8755881d1f13d9e4a061b07d1f69907e
BLAKE2b-256 7d7407ad29a38a829de82c0c4febcf99efe3bf5fff80f737141ce5603345b4a9

See more details on using hashes here.

Provenance

The following attestation bundles were made for rlemasklib-0.6.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: python-publish.yml on isarandi/rlemasklib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rlemasklib-0.6.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rlemasklib-0.6.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 cd5c78c4068079d6a769a28c6ac12816efbea9f2a2ad26591fb8687b1cc5f607
MD5 013cf14e26909c84fd47929bebfe4951
BLAKE2b-256 565d4a40de1601249d348d000856de3a0d3d5bb9cf43edf66bed8d7bad6beacd

See more details on using hashes here.

Provenance

The following attestation bundles were made for rlemasklib-0.6.0-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: python-publish.yml on isarandi/rlemasklib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rlemasklib-0.6.0-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: rlemasklib-0.6.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 417.3 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for rlemasklib-0.6.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 574def5a60b2afa7f559961330e6354fc204a477789205dafb1b6bb5a9a97141
MD5 4d6a6c4a99cabbf95e38669a519f1732
BLAKE2b-256 ce48f095579fbb9c6222fa4ac964d57d7fa532bf70c823c1402b4929461cf03d

See more details on using hashes here.

Provenance

The following attestation bundles were made for rlemasklib-0.6.0-cp310-cp310-win_amd64.whl:

Publisher: python-publish.yml on isarandi/rlemasklib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rlemasklib-0.6.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rlemasklib-0.6.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 31e45f77b1a482ecd567facd755cdf669c1a5272b88630da89a1daef2b2eee55
MD5 64799c137172db28a056d59e795dab00
BLAKE2b-256 9c8879751f3dfe17575a4c90bac896daab3fe0775567fa6e8145e33c45dbd86e

See more details on using hashes here.

Provenance

The following attestation bundles were made for rlemasklib-0.6.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: python-publish.yml on isarandi/rlemasklib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rlemasklib-0.6.0-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rlemasklib-0.6.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 cec37b6956fead232a3eeca17b89a669e1a17ff7170863eac12bc9e7c644736a
MD5 ef63264f71e073da8255fb25f4fac3d9
BLAKE2b-256 d4dc8b90009d00a23ce3cad61bb76f43575b1d02660b505ab9a46a54aba66475

See more details on using hashes here.

Provenance

The following attestation bundles were made for rlemasklib-0.6.0-cp310-cp310-macosx_11_0_arm64.whl:

Publisher: python-publish.yml on isarandi/rlemasklib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rlemasklib-0.6.0-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: rlemasklib-0.6.0-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 417.7 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for rlemasklib-0.6.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 e51964acba9883f7a9434d4e420b3dfef398fc2f10f4a07e21ceaf8a0aa77c92
MD5 e811d372397f5fb3a263e20943c5f32f
BLAKE2b-256 bc437142e1d1a4e8be723f21877265e00153064122f9dbc176a989e59811b67b

See more details on using hashes here.

Provenance

The following attestation bundles were made for rlemasklib-0.6.0-cp39-cp39-win_amd64.whl:

Publisher: python-publish.yml on isarandi/rlemasklib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rlemasklib-0.6.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rlemasklib-0.6.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c01ff57211d6c52d69f9a3c97e41a3016e1132b3b00da6b8daa29d869df2a6c1
MD5 3e6c90c83904786872a040e7c27eecf5
BLAKE2b-256 6c48fae91d52eb02ff8ab8d5e85f131b617f66740b72bcac17afb237257e01d2

See more details on using hashes here.

Provenance

The following attestation bundles were made for rlemasklib-0.6.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: python-publish.yml on isarandi/rlemasklib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rlemasklib-0.6.0-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rlemasklib-0.6.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 52d61e0d20405556745e03d8d29d139a2cb92e69600b7334b2214b6c68d35f1d
MD5 d4977471568652b3ce76654c953fdcab
BLAKE2b-256 14d92ad998e7c253f1fd1cc0a9f6152331a99978b98c517ccdc0f9cf4b221472

See more details on using hashes here.

Provenance

The following attestation bundles were made for rlemasklib-0.6.0-cp39-cp39-macosx_11_0_arm64.whl:

Publisher: python-publish.yml on isarandi/rlemasklib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rlemasklib-0.6.0-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: rlemasklib-0.6.0-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 420.9 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for rlemasklib-0.6.0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 81d7b6891ad5f8fa65474ff3c01828371fc8a7b6d2b0ba18e503254554ded61e
MD5 b80a2271ed56425086b26129a3fc4895
BLAKE2b-256 67bba9ec080e212cf3244c18f7e39dca613e074cf82a9fae279dbafa9e8bef22

See more details on using hashes here.

Provenance

The following attestation bundles were made for rlemasklib-0.6.0-cp38-cp38-win_amd64.whl:

Publisher: python-publish.yml on isarandi/rlemasklib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rlemasklib-0.6.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rlemasklib-0.6.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2a7ff0a35668ea307fdd88f22ace83533ae359c3dce9b2b93d8ead78edb12aa9
MD5 e72b922c83460b00b057d6d63428adb4
BLAKE2b-256 005f6a2ff5186d50e92988a212912358aafcfbd514fd1dbdf4012f54a794c5bf

See more details on using hashes here.

Provenance

The following attestation bundles were made for rlemasklib-0.6.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: python-publish.yml on isarandi/rlemasklib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rlemasklib-0.6.0-cp38-cp38-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rlemasklib-0.6.0-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f22f796b825b16d3f71644221d36e321609dd2a1ba72c2b4cc141307a7e0fee0
MD5 bafaa261da1479511d2513c416bab965
BLAKE2b-256 db04c1121ce40a45967da884acd5a06e0a68c4c68f31911916c7e82f9b56215e

See more details on using hashes here.

Provenance

The following attestation bundles were made for rlemasklib-0.6.0-cp38-cp38-macosx_11_0_arm64.whl:

Publisher: python-publish.yml on isarandi/rlemasklib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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