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.1.tar.gz (652.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.1-cp313-cp313-win_amd64.whl (413.8 kB view details)

Uploaded CPython 3.13Windows x86-64

rlemasklib-0.6.1-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.1-cp313-cp313-macosx_11_0_arm64.whl (964.2 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

rlemasklib-0.6.1-cp312-cp312-win_amd64.whl (412.2 kB view details)

Uploaded CPython 3.12Windows x86-64

rlemasklib-0.6.1-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.1-cp312-cp312-macosx_11_0_arm64.whl (965.0 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

rlemasklib-0.6.1-cp311-cp311-win_amd64.whl (418.8 kB view details)

Uploaded CPython 3.11Windows x86-64

rlemasklib-0.6.1-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.1-cp311-cp311-macosx_11_0_arm64.whl (963.7 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

rlemasklib-0.6.1-cp310-cp310-win_amd64.whl (417.8 kB view details)

Uploaded CPython 3.10Windows x86-64

rlemasklib-0.6.1-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.1-cp310-cp310-macosx_11_0_arm64.whl (965.7 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

rlemasklib-0.6.1-cp39-cp39-win_amd64.whl (418.4 kB view details)

Uploaded CPython 3.9Windows x86-64

rlemasklib-0.6.1-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.1-cp39-cp39-macosx_11_0_arm64.whl (966.6 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

rlemasklib-0.6.1-cp38-cp38-win_amd64.whl (421.6 kB view details)

Uploaded CPython 3.8Windows x86-64

rlemasklib-0.6.1-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.1-cp38-cp38-macosx_11_0_arm64.whl (970.3 kB view details)

Uploaded CPython 3.8macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: rlemasklib-0.6.1.tar.gz
  • Upload date:
  • Size: 652.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.1.tar.gz
Algorithm Hash digest
SHA256 5bd7a550f649ae992a9804035c238e913cda60ca086b8e9455f029227ee4c8d9
MD5 c0c72a021a875deb6fa8e006772ba559
BLAKE2b-256 330dcbf27a8e9e678316122429b0960368376398d3a17e132d48dd809c6bca28

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: rlemasklib-0.6.1-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 413.8 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.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 4c6b8280ee6bbeb5463edfdacb3ce16cb7874f2e3781334f6c836d2412358fa6
MD5 688aedbf5006a6505c6ade28a1fc6611
BLAKE2b-256 2aabb43dd4cf5f522a9f3d71e89e328e9cbbd9f5811846b007e0a19d7a6ae6ab

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for rlemasklib-0.6.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 568d99224ee612a2e04a7d05ac17a630a6202f553ec0ef7cfbb403f4bcad62f3
MD5 717ca1be39ebd93e712fb5ee1c028b5d
BLAKE2b-256 0a414166631a29699b463bdbc921bfff612c1f7a8c526aa945ac7353d53cae7d

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for rlemasklib-0.6.1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4f49923c355c3db2f8b311d111cd98999726a0a66a0f471d535fcd6922f8c2b1
MD5 a4a3278683ccd1a440a5dd2b69532d88
BLAKE2b-256 0c23c1f6119df8691301bdac07eb64dfc90d32a775af51a4c0e201fda5c1fce1

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: rlemasklib-0.6.1-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 412.2 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.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 b56a48de2724f51eb5716a7e61a2f95da0a245567d72af3f316d9f24256f172e
MD5 1b729bfbd1e3bed64c75e83867dd8f3e
BLAKE2b-256 9e1151fea2c66dad1e9f2bff586b8c641359310d93db8f1af160b070089d3482

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for rlemasklib-0.6.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9f8389f999d6c13e2a635cf057dca60640018fd37c905ad70595be8b591db9e4
MD5 d860e6186711dea800bd10280f82bd15
BLAKE2b-256 7b62f0b8180653d84239b0da416e58800fefc2e04380f92cc730ffe93fd72b43

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for rlemasklib-0.6.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 388c9a257be8ff252bdc489fea02c1a776b93ad74163fe80028a960cd3c275df
MD5 fdc9f744d8bb5ee71a2a3c716900f8e5
BLAKE2b-256 8bbf0a4294b0806b60ad8f56895fd77172254d31c67c512443aeff8b7c8c9310

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: rlemasklib-0.6.1-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 418.8 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.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 a7eb206b61f38ecd59b4f23d7e44b88c0e17911488049f087aaae59fe4ccf52e
MD5 18110e4b7408068b2e120309e3eb9474
BLAKE2b-256 2b56fad0a9751954652a6ee1d6c0378aa325b517240cf604e04e6af63dc9db88

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for rlemasklib-0.6.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e27faa70fa436151afe7c4422104d29e020d5b375e664659cb573ebb1eb7e83c
MD5 416447e5e13227e66eb078eb674d3e15
BLAKE2b-256 bb38d81d7e20c6f9f1bdc733cae8b3662ed92c0a9106f903841f24cf5a3eea2d

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for rlemasklib-0.6.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 70c36b772838ff7514df7d2baac7387563a7c075aa41797c1f066022ed465004
MD5 e46dba8a03b0f152e160e13c9a392190
BLAKE2b-256 63efff8da0cc9cbbc76a9ce04f56998b5bc5b68baa85ec508fc424c5eb963c40

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: rlemasklib-0.6.1-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 417.8 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.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 012722b8aa6e91f901e37b96b592052f71a0e99bd4e0f231ffd1cbbcbe01a0dd
MD5 a840aff8948f8227050ad56ab70dfc28
BLAKE2b-256 62434aaba488588d395e66a962aba4ea5eb08876f6555a0e2f629af64015ab8e

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for rlemasklib-0.6.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9a9ce5adecfb8f20244edbf8494a6cbdcb3d1c6a289c8179e82b85c04637f323
MD5 f6dddf9a4aa77443faed2ba697d13f08
BLAKE2b-256 2fa324de2c04e2c4ea24827377006d56cfba747b1efd76da8040f6ed29f8286e

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for rlemasklib-0.6.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2458f55987a061f5d727f59205ab12f4d9f47ccb153130a3234157834a7c1c40
MD5 320aef00e95252244d237881bac8167f
BLAKE2b-256 e08d1596b75fa492ac43bc15f7fc3fe624af082f9531cca43da05bc2940563da

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: rlemasklib-0.6.1-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 418.4 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.1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 616708118d1dc5a3f0bcf7f67ea1f4d9d57ad35182ed5fd45d02b73dce553a88
MD5 8a3ed0a001e1ea6a0b4c51c12a3d88ef
BLAKE2b-256 01c385fe669aec600cac0b5ef047bad63eed3ec2182c1821a4ff27eab41adb14

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for rlemasklib-0.6.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ec4d8c21f2d28ff78a179d46334639ef5a1337359334af2be0f17ed0d302f5c8
MD5 a4ed0a8929aa87353755dca2e8fbec03
BLAKE2b-256 5c60bd04d6a42622144aa70a7c12b21032b106df84c1d68980452109da88f6fa

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for rlemasklib-0.6.1-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9704eef5ddd7e3947bb5ebf310d85ab61eaa120b4cad11a5b3943130106f01cd
MD5 fffddacb172e22fbb260b91eb7608dfc
BLAKE2b-256 e0ec1a43f7892eb848f1af0bc348021e248fc84e479368c78590a6a3d295a368

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: rlemasklib-0.6.1-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 421.6 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.1-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 d608ebf864e136f08074d829eb649746f9da21761614b423d3bd2316e0eb4851
MD5 edea1c99fb23d5fcb04881fef895b313
BLAKE2b-256 9d7f821aa4c37ebcd1cf2090889cdf0794b01994769322166c633cdd54f43050

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for rlemasklib-0.6.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b830e9b376b97d664c35aacd3e3e7e0a8b11171ef2829f4d161b9d312baa4f6d
MD5 d23fb0f12f51674994e2cb754b6b7f94
BLAKE2b-256 96e89274112dcb0f1bb3bcc95b5590f113e8ea96ea93a1531755aabfa3b14a1f

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for rlemasklib-0.6.1-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3e5ce351110a016f51fdbc82d312d86f5c10f9c1a4bf9b3ba30a17b62d6b7b46
MD5 e573af40864c2dfdaf829455fb08e7a1
BLAKE2b-256 8135eedc191b26fcc5c429a74afb570f9bc1530c6d5b4b4a3d8be02f86a337a1

See more details on using hashes here.

Provenance

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