🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more

RLEMaskLib

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

RLEMaskLib

Manipulate run-length-encoded image masks

0.3.14
Maintainers
1

RLEMaskLib: Run-Length Encoded Mask Operations

Read the Docs PyPI - Version

This library provides efficient run-length encoded (RLE) operations for binary masks in Python. It is designed to be fast and memory efficient, and is particularly useful for working with large datasets. The library provides an intuitive and extensive object-oriented interface as well as a simpler functional one. To achieve high efficiency, the core functionality is implemented in C, and wrapped via Cython.

RLEMaskLib is fully compatible with the COCO mask format (in the form of dictionaries) but can also work directly with runlength sequences.

The library provides many operations on masks, including:

  • Set operations (complement, difference, symmetric difference) and custom boolean functions.
  • Crop, pad, tile, concatenate
  • Connected components extraction
  • Warp (affine, perspective, lens distortion)
  • Transpose, flip, rotate by multiples of 90 degrees
  • Binary morphology: dilate, erode, open, close
  • Convolve with arbitrary kernels
  • Directly create fully foreground and fully background masks
  • Decompress of COCO's compressed RLE format to integer run-lengths, and vice versa
  • Extra compression (optional) using gzip on top of the LEB128-like encoding used by the COCO API (~40% reduction beyond the COCO compression)
  • Object-oriented and functional APIs.

This library originates as a fork of the COCO API's pycocotools.mask module (which was originally written by Piotr Dollár and Tsung-Yi Lin) but now mostly consists of new code.

Installation

pip install rlemasklib

Documentation

See https://rlemasklib.readthedocs.io/.

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts