fastremap is a highly optimized C++ library with a Python wrapper for high-performance image and point cloud processing. It provides extremely fast functions for remapping, masking, renumbering, finding unique elements, and in-place transposition of 3D labeled images. The current version is 1.18.0, and it maintains an active release cadence with frequent updates.
pip install fastremapVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates basic usage of `fastremap` for remapping labels in a NumPy array. It shows both non-in-place (`remap`) and in-place (`remap_inplace`) operations, as well as the `renumber` function for making labels contiguous and obtaining the mapping.
Use `arr.copy()` before passing to an `_inplace` function, or use functions like `fastremap.remap` which return a new array.
Always unpack the return value like `new_array, old_to_new_map = fastremap.renumber(arr)` to access both components.
Ensure input arrays for label processing are explicitly cast to appropriate unsigned integer types (e.g., `arr.astype(np.uint32)`).