fastremap
Remap, mask, renumber, unique, and in-place transposition of 3D labeled images. Point cloud too.
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 fastremapuv
uv add fastremappoetry
poetry add fastremapInstalling 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
Tags
More Utilities packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
charset-normalizerDetects and normalizes text encoding from…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
PygmentsPygments is a syntax highlighter that colorizes…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
numpy-minmaxFinds the minimum and maximum values in a NumPy…
permissive · top 15,000 on PyPI
pyvrlExposes Vector's VRL (Vector Remap Language) to…
permissive · top 15,000 on PyPI
awkward0Manipulates complex, non-rectangular data…
permissive · top 15,000 on PyPI
edtComputes Euclidean distance transforms for 1D,…
copyleft · top 15,000 on PyPI
numpy-rmsCalculates Root Mean Square (RMS) values over…
permissive · top 15,000 on PyPI
color-operationsApplies color-oriented image operations—gamma…
permissive · top 15,000 on PyPI
fill-voidsFills interior voids in 2D and 3D binary images…
copyleft · top 15,000 on PyPI
spatial_imagespatial-image provides an N-dimensional spatial…
permissive · top 15,000 on PyPI
numexprNumExpr evaluates numerical expressions on…
permissive · top 5,000 on PyPI
xarrayxarray adds dimension, coordinate, and…
permissive · top 5,000 on PyPI