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.7.0.tar.gz (675.2 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.7.0-cp313-cp313-win_amd64.whl (435.1 kB view details)

Uploaded CPython 3.13Windows x86-64

rlemasklib-0.7.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.0 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

rlemasklib-0.7.0-cp313-cp313-macosx_11_0_arm64.whl (1.0 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

rlemasklib-0.7.0-cp312-cp312-win_amd64.whl (433.5 kB view details)

Uploaded CPython 3.12Windows x86-64

rlemasklib-0.7.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.0 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

rlemasklib-0.7.0-cp312-cp312-macosx_11_0_arm64.whl (1.0 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

rlemasklib-0.7.0-cp311-cp311-win_amd64.whl (441.7 kB view details)

Uploaded CPython 3.11Windows x86-64

rlemasklib-0.7.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.1 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

rlemasklib-0.7.0-cp311-cp311-macosx_11_0_arm64.whl (1.0 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

rlemasklib-0.7.0-cp310-cp310-win_amd64.whl (440.5 kB view details)

Uploaded CPython 3.10Windows x86-64

rlemasklib-0.7.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.0 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

rlemasklib-0.7.0-cp310-cp310-macosx_11_0_arm64.whl (1.0 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

rlemasklib-0.7.0-cp39-cp39-win_amd64.whl (441.2 kB view details)

Uploaded CPython 3.9Windows x86-64

rlemasklib-0.7.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.0 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

rlemasklib-0.7.0-cp39-cp39-macosx_11_0_arm64.whl (1.0 MB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

rlemasklib-0.7.0-cp38-cp38-win_amd64.whl (444.7 kB view details)

Uploaded CPython 3.8Windows x86-64

rlemasklib-0.7.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.1 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

rlemasklib-0.7.0-cp38-cp38-macosx_11_0_arm64.whl (1.0 MB view details)

Uploaded CPython 3.8macOS 11.0+ ARM64

File details

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

File metadata

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

File hashes

Hashes for rlemasklib-0.7.0.tar.gz
Algorithm Hash digest
SHA256 e0c83e459100631374167a6090d7eb89ffed02fee35af2ab13069396d5cdca39
MD5 0c948f3644102a3fa334dd0fddc0bdeb
BLAKE2b-256 1cd2e47406427929603c8107970c61adf59550b94d34a2ca8dc00b041bc9f9e3

See more details on using hashes here.

Provenance

The following attestation bundles were made for rlemasklib-0.7.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.7.0-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: rlemasklib-0.7.0-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 435.1 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.7.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 29e92a2a515805be429c3b9043faca9a4fea360308d5c1accfd369309e441a3a
MD5 b72b783a77c76b5a7283171ea56c43c3
BLAKE2b-256 c4b86382e683bc04b9bb31aba39fae7fa9c3290fbe14e0ea885f753eb3fdb09e

See more details on using hashes here.

Provenance

The following attestation bundles were made for rlemasklib-0.7.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.7.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rlemasklib-0.7.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b9e085e17f865156d6e2bf162bfce14e44ec6acd10c99a120385eee6bdcd677a
MD5 d89aa612c33a897ffd81ae4cdfebc2d5
BLAKE2b-256 74e8631732c617274d6a4a12cb3585b45be791c95858680f50a6fe14ec6193cc

See more details on using hashes here.

Provenance

The following attestation bundles were made for rlemasklib-0.7.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.7.0-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rlemasklib-0.7.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 45e7ef3f825fada918f74c7eb34c407c7da8eabf54d51a6c66485b58fce4b5b7
MD5 3ca7e39cbd595686c0eb516687306177
BLAKE2b-256 203c2f96a5428a28aa629dea4d62c1aace19cf84f0c898d13ab9a5a0dad93cf9

See more details on using hashes here.

Provenance

The following attestation bundles were made for rlemasklib-0.7.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.7.0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: rlemasklib-0.7.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 433.5 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.7.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 763ae102a23fd41b4532bf699db2a64d11a1145be81e5f3340465dd42b34e437
MD5 43a78641fcbf22a61e88e42cae7a9e46
BLAKE2b-256 5fe3e652d4aff6cf2fdd84e564b6bed04ee370c1dc4df96dcb5f9bfd33456d4b

See more details on using hashes here.

Provenance

The following attestation bundles were made for rlemasklib-0.7.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.7.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rlemasklib-0.7.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 983e6d76e04d3cf6d4a7f0399b77075d5c9695b208b5df83f4adf9b96fb20f42
MD5 431f57732ce498c08c1adf4b3432629f
BLAKE2b-256 a8a9e64b077276b5329b6c418216434a939e676af7fd30e4cfe19882db4765cb

See more details on using hashes here.

Provenance

The following attestation bundles were made for rlemasklib-0.7.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.7.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rlemasklib-0.7.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d6183b0f4d11c80dba85ea69a1bb790289d631f9695ca12889c4642a0fc77442
MD5 ec10e9c70cea3c93e4821175e298ebe0
BLAKE2b-256 aa66df383454d403a4b42b6f0763ac7ee16181abb62a697e7e60ec44ba018772

See more details on using hashes here.

Provenance

The following attestation bundles were made for rlemasklib-0.7.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.7.0-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: rlemasklib-0.7.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 441.7 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.7.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 dd79c1b33fd2068ce9da2c5a03785a8531454a4146f29640961fd41ec756a17c
MD5 89c7cf34981f8d2fd1bdaa3cf1b7f479
BLAKE2b-256 6cfd263a960a11d732ae95bccca9cccc9cb7ad6fd55fb1c187623850772edcb2

See more details on using hashes here.

Provenance

The following attestation bundles were made for rlemasklib-0.7.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.7.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rlemasklib-0.7.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f4162ae0b96d2b1b7d03d0b8d5c16b80aafa3330252e2c4487e304e78de32a58
MD5 5710907bb00bd7692b9ec95d3a99b8be
BLAKE2b-256 108c33b83685c4e6a187cb6cb53959865b5699d8e026152a263b343aa4d2b0b3

See more details on using hashes here.

Provenance

The following attestation bundles were made for rlemasklib-0.7.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.7.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rlemasklib-0.7.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 15602190b815095fa977ba582ba008a8d3cc3068a2f5aa81deaa511692812574
MD5 4fac0e9fc7b2f6b701ea61da55c5f2d0
BLAKE2b-256 c2b40a20b26d95f6dba7132a052f4ff759e980dd91fa64efec9d88ca8ca97696

See more details on using hashes here.

Provenance

The following attestation bundles were made for rlemasklib-0.7.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.7.0-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: rlemasklib-0.7.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 440.5 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.7.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 fb24fb9f559ac939cfcedf056284e699b30ac266628efc72f6c19407f9d3f2d7
MD5 5a8a2f8052d0902e622b171879a5131c
BLAKE2b-256 5f6e96deb27219f9f14079233ca1fcd5591887f57f7b25b84817b16c6da9d664

See more details on using hashes here.

Provenance

The following attestation bundles were made for rlemasklib-0.7.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.7.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rlemasklib-0.7.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8cf7a42e0ebc858c528c909c8bc8ad6b185512ec8e605a437be4c81f63169d6a
MD5 bfd405ecd7bda68c5193f4c7053948e6
BLAKE2b-256 fc14e7b85dfd2a52a4053cf1c8610b38cba5f2560e25340beccb7af561c599bf

See more details on using hashes here.

Provenance

The following attestation bundles were made for rlemasklib-0.7.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.7.0-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rlemasklib-0.7.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 798d870ac1a938a754a6bdd8c1e31fec2f79899e51e2b6813950caa0939a0ad0
MD5 1ff90c5b2d06eacfc7c6aaf40914482e
BLAKE2b-256 08a6d57ad5ddeb664acbec751f71c197c7746e175866d9485f60d3925c0a03ef

See more details on using hashes here.

Provenance

The following attestation bundles were made for rlemasklib-0.7.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.7.0-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: rlemasklib-0.7.0-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 441.2 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.7.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 795edf5ed6a0a2bca62ee36b83b6d9dfeecce0eceff27a6aa4825d387240afd8
MD5 ee245785ee4a618e13e0103286b2b1bd
BLAKE2b-256 c07cd9e1300a2bfca8ecd4a0530c3d3ad807d4473938a05c2485f9176598c7dc

See more details on using hashes here.

Provenance

The following attestation bundles were made for rlemasklib-0.7.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.7.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rlemasklib-0.7.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b5e292c3c585a2596568a670dc4a7505cd49f97cb6c08299db73045f21f32d4b
MD5 8c9277267ee5f6e5a3c5312c6a9f1cbb
BLAKE2b-256 325d6cd91e7cd6edc8d34fd2eadbdba3c1b3e0df44744cbd43f6ad706d1ace29

See more details on using hashes here.

Provenance

The following attestation bundles were made for rlemasklib-0.7.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.7.0-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rlemasklib-0.7.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 67318cc7173345bdcfd378efac0612cbe4fef1d565e586de57d05f00f9c71c00
MD5 46aa07099b3b4f722676a3042a6c8e9a
BLAKE2b-256 e404f313304e053fd9c32e71b093b5cd0739080f52a3cac4b5b1599006ac48e6

See more details on using hashes here.

Provenance

The following attestation bundles were made for rlemasklib-0.7.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.7.0-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: rlemasklib-0.7.0-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 444.7 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.7.0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 5268a6c03b065ef0c232cd8cad326bd88c67e769a431dfc24becf7449cf2357a
MD5 afa8fe5de41e688af56a2200f08e4a80
BLAKE2b-256 3f17be69b582d67f144a9ad965f1af0c7c364f889bd3c46a05659688557ff1a5

See more details on using hashes here.

Provenance

The following attestation bundles were made for rlemasklib-0.7.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.7.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rlemasklib-0.7.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4940257aab56020932b3d0d8004f3db98e643f65d6709cee5a5adeac43247180
MD5 530fc8d8918f0c9ea6ec2c6efd04ef6c
BLAKE2b-256 f6d94953773cdb6fdbc3236c5d1eae4914c56d2644dfd102d8b393ede659327b

See more details on using hashes here.

Provenance

The following attestation bundles were made for rlemasklib-0.7.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.7.0-cp38-cp38-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rlemasklib-0.7.0-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9b5f6f2f0eea90d644d4346be594fcdaf052983a4a4ee49cf8427bf500190409
MD5 0d560cfdf16bf52e90578af87823e9a1
BLAKE2b-256 ce6cf2e1ae1b495eb65337f34ef8ac1ee3fabb6b92752846353cc2e75131cf7d

See more details on using hashes here.

Provenance

The following attestation bundles were made for rlemasklib-0.7.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