skillfed

fastremap

Remap, mask, renumber, unique, and in-place transposition of 3D labeled images. Point cloud too.

fastremap v1.20.0 172.9K downloads/30d#10,321 on PyPI65
Copyleft license LGPL-3.0 Active released

What it is and what it does

fastremap is a C++-accelerated library for fast array manipulation on labeled NumPy arrays, designed for image processing and connectomics workflows. It provides optimized implementations of common operations like finding unique values, remapping labels via dictionary, renumbering to smaller data types, and extracting point clouds—operations that would be slow in pure Python or inefficient in NumPy for large sparse label spaces.

The package trades install complexity (compiled extension) for speed on bulk array operations. Its main use case is handling large labeled images (hundreds of megabytes to gigabytes) where Python loops or naive NumPy indexing become impractical. It also offers in-place transposition and memory-efficient array format conversions (C to Fortran order), useful when moving data between CPU, GPU, or disk.

Use it for:

  • Renumber a 64-bit segmentation label array down to 8-bit to save memory and fit smaller data types.
  • Remap arbitrary label values via dictionary on huge arrays without materializing an intermediate lookup table.
  • Extract coordinates of all voxels belonging to each label in a 3D image as a point cloud.
  • Count unique labels and their frequencies much faster than np.unique on large labeled arrays.
  • Physically transpose rectangular arrays in-place to convert between C and Fortran memory order before GPU upload or serialization.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Remap, renumber, and relabel NumPy arrays at C++ speed, plus perform in-place transposition and extract point clouds from labeled images.

Yes, if you work with large labeled NumPy arrays (segmentations, connectomics, image analysis) and need fast remapping, renumbering, or transposition. The LGPL-3.0 copyleft license is permissive for open-source use but requires careful review in proprietary contexts. Install friction is moderate due to the C++ extension, but pre-built wheels cover common platforms. No known security vulnerabilities.

Install

fastremap on PyPI

pip

pip install fastremap

uv

uv add fastremap

poetry

poetry add fastremap

Installing fastremap

Before you install

Medium install friction due to compiled C++ extension; pre-built wheels available for Python 3.10–3.13 on macOS, Linux, and Windows. Actively maintained with a recent release (64 days ago).

License in practice

LGPL-3.0 copyleft license requires derivative works to be distributed under the same license and provide source code; acceptable for most open-source projects but may conflict with proprietary software licensing.

Quickstart

pip install fastremap
import fastremap
import numpy as np

labels = np.array([1, 3, 5, 5, 10])
uniq, cts = fastremap.unique(labels, return_counts=True)
labels, remapping = fastremap.renumber(labels, in_place=True)

Requires NumPy; if pre-built wheels are unavailable for your platform, a C++ compiler is needed to build from source.

Verify before relying

  • Whether the performance gains over NumPy operations scale predictably with array size or are most significant for specific data types or dimensions.
  • Compatibility and performance characteristics on platforms beyond the listed wheel distributions.

Package facts

License LGPL-3.0 (copyleft)
Python support supports the current Python release (<4.0,>=3.9)
Install friction medium — platform-specific wheel
Runtime dependencies 1 — numpy
Maintenance actively maintained — 64 days since the last release
Last repo commit
First released
Downloads 172,921/month — #10,321 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: fastremap-1.20.0-cp310-cp310-macosx_10_9_x86_64.whl; fastremap-1.20.0-cp310-cp310-macosx_11_0_arm64.whl; fastremap-1.20.0-cp310-cp310-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl; fastremap-1.20.0-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl; fastremap-1.20.0-cp310-cp310-win32.whl; fastremap-1.20.0-cp310-cp310-win_amd64.whl; fastremap-1.20.0-cp311-cp311-macosx_10_9_x86_64.whl; fastremap-1.20.0-cp311-cp311-macosx_11_0_arm64.whl; fastremap-1.20.0-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl; fastremap-1.20.0-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl; fastremap-1.20.0-cp311-cp311-win32.whl; fastremap-1.20.0-cp311-cp311-win_amd64.whl; fastremap-1.20.0-cp312-cp312-macosx_10_13_x86_64.whl; fastremap-1.20.0-cp312-cp312-macosx_11_0_arm64.whl; fastremap-1.20.0-cp312-cp312-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl; fastremap-1.20.0-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl; fastremap-1.20.0-cp312-cp312-win32.whl; fastremap-1.20.0-cp312-cp312-win_amd64.whl; fastremap-1.20.0-cp313-cp313-macosx_10_13_x86_64.whl; fastremap-1.20.0-cp313-cp313-macosx_11_0_arm64.whl

Development Status :: 5 - Production/StableIntended Audience :: DevelopersProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Topic :: Utilities

Tags

fast array remappingrenumber labeled arraysnumpy label relabelingin-place array transposepoint cloud extractionfast unique valuesarray masking operations
image-processingarray-optimizationconnectomics

More Utilities packages