Albucore is a library of optimized atomic functions designed for efficient image processing. These functions serve as the foundation for AlbumentationsX, an image augmentation library.
@article{iglovikov2026albumentationsx,
title = {AlbumentationsX: One Augmentation Pipeline for Images and Related Annotations},
author = {Iglovikov, Vladimir},
journal = {arXiv preprint arXiv:2608.11123},
year = {2026},
doi = {10.48550/arXiv.2608.11123},
url = {https://arxiv.org/abs/2608.11123}
}
Overview
Image processing operations can be implemented in several ways, with performance depending on dtype, size, layout, and channel count. Albucore routes each operation to a benchmark-selected NumPy, OpenCV, NumKong, StringZilla, or eligible CPU PyTorch implementation.
Image routers accept uint8, float16, and float32; float64 image inputs are not supported. NumPy uses channel-last layouts, while eager CPU Torch calls use explicit channel-first layouts where channel semantics matter. The specialized uint8 LUT operation is uint8-only.
Installation
Requires Python 3.11+. CI covers Python 3.11, 3.12, 3.13, and 3.14. Choose and install the PyTorch build for your CPU,
CUDA, or MPS environment first. Then install Albucore with an OpenCV extra. For a Linux CPU-only headless application:
CUDA or macOS (MPS): Select and install the matching PyTorch build with the
PyTorch installation selector, then install Albucore:
pip install "albucore[headless,torch]"
pip install albucore installs only the base dependency set. Use it when a transitive consumer only resolves
Albucore, such as during a documentation build. The current public import graph requires both OpenCV and PyTorch.
The torch extra declares Albucore's PyTorch runtime requirement but cannot select a CPU, CUDA, or MPS wheel through
standard package metadata. Use PyTorch's platform-specific installation command before installing Albucore. The examples
use the headless OpenCV extra. When Albucore installs OpenCV, choose exactly one extra: headless, gui,
contrib, or contrib-headless. Use albucore[torch] when reusing an existing OpenCV installation.
AlbumentationsX passes prevalidated CPU, strided Torch tensors with requires_grad=False to
resize3d and warp_affine3d; the low-level routers do not repeat those checks or move/detach Tensor data.
warp_affine3d and remap3d also accept rank-5 volume batches with one shared affine matrix or pull grid.
With OpenCV GUI support (for local development with cv2.imshow):
pip install "albucore[gui,torch]"
With OpenCV contrib modules:
pip install "albucore[contrib,torch]" # GUI version
pip install "albucore[contrib-headless,torch]" # Headless version
Note: If you already have one of the supported OpenCV distributions installed, use pip install "albucore[torch]"
after installing the platform-specific PyTorch build. This does not add another OpenCV package; Albucore uses the
existing installation.
The channel dimension is always present, even for grayscale ((H, W, 1), never (H, W)). NumPy layouts are
channel-last:
Single image: (H, W, C)
Batch of images: (N, H, W, C)
3D volume: (D, H, W, C)
Volume batch: (N, D, H, W, C), accepted only by warp_affine3d and remap3d
CPU Torch uses CHW, NCHW, CDHW, or NCDHW; common operations that need a channel axis take an explicit
layout= keyword. Spatial routers such as resize and resize3d define their layout by the operation. See
docs/image-conventions.md for details.
Functions
The tables below highlight public routers exported directly by albucore. Their implementations live in the
operation modules listed in docs/public-api.md. Image routers support uint8, float16, and
float32, except where a table states a narrower dtype contract.
Arithmetic
Function
Signature
What it does
How it works
clip
(img, dtype=None, *, out=None)
Saturate to the selected dtype range; dtype follows out or input when omitted
uint8 scalar/vector → LUT; float16 HWC C=1 uses NumKong scale with neonhalf=true for exact half controls from 20,480 elements; C=3 uses OpenCV CV16F for exact half controls from 61,440 elements; other float16/float32 paths are benchmark-selected
uint8 uses OpenCV/LUT/NumKong; float16 HWC C=1 uses NumKong scale with neonhalf=true for exact half controls from 20,480 elements; C=3 uses OpenCV CV16F for exact half controls from 61,440 elements; other float16/float32 paths are benchmark-selected
uint8 → LUT; float32 scalar → NumKong scale; float16 and other controls use measured NumPy/Torch paths
value / factor / exponent can be a scalar, a length-C 1-D array (per-channel), or a
full image-shaped array.
These arithmetic routers do not impose an image-range convention on floating-point data. Without out, they do not
write input storage; a supplied destination is returned by identity and may alias only where the operation allows it.
Tensor calls that depend on channel semantics require layout=. All operations express dtype conversion, clipping,
layout, and output ownership in their own signatures or bodies.
These functions preserve the input shape. Without out, they leave input data unchanged. Supply out=destination
to reuse a writable result buffer; floating inputs may use out=array, including supported views. Uint8 input
requires a float32 destination. AX owns any protective copy needed before writing shared storage. See the elementwise benchmark report for routing thresholds, environment, and NumKong results.
Sample a volume or batch through one shared normalized 3D pull grid
NumPy DHWC/NDHWC or CPU Torch CDHW/NCDHW; grid layout (D_out, H_out, W_out, 3)
matmul
(a, b)
Matrix multiply (a @ b)
NumPy @ (BLAS-backed); float16 uses float32 accumulation and casts back
pairwise_distances_squared
(points1, points2)
Squared Euclidean distance matrix (N, M)
NumKong cdist for N*M < 1000, D≥9, and contiguous float32 D=8 through 2,048 pairs; NumPy coordinate differences otherwise
The package also star-exports copy_make_border, gaussian_blur3d, pad3d, remap, remap3d, resize, resize3d, warp_affine, warp_affine3d, and warp_perspective; see docs/public-api.md and their docstrings for complete signatures. gaussian_blur3d, pad3d, and resize3d expect one NumPy DHWC volume or CPU Torch CDHW tensor per call. warp_affine3d and remap3d accept those single-volume layouts or NumPy NDHWC and CPU Torch NCDHW batches.
Type conversion
Function
Signature
What it does
How it works
convert_dtype
(img, dtype, *, max_value=None, out=None)
Convert among uint8, float16, and float32; uint8↔float scales by 255 by default, float↔float casts, same dtype returns by identity
Uint8→float uses a result-dtype LUT; contiguous float16→uint8 uses a cached 65,536-entry OpenCV LUT on macOS ARM64 and Linux x86-64 for the default scale; other float quantization retains measured NumPy/NumKong/Torch routes
Performance
Measured routing: Each function may have several NumPy, OpenCV, NumKong, StringZilla, or CPU PyTorch implementations. The router picks one from dtype, size, memory layout, channel count, and semantic constraints, using thresholds from repeatable benchmarks.
NumKong: SIMD blend for uint8 and single-channel float32 add_weighted, plus same-shaped uint8 add(..., field); cdist for small and measured high-dimensional pairwise_distances_squared regions; wide-accumulator moments for selected statistics routes (see docs/numkong-performance.md).
CPU PyTorch: Selected eager 3D volume operations use full-path Torch routes after benchmarks include the NumPy/Tensor bridge, thread settings, and output repair (see docs/torch-performance-optimization.md).
Tensor LUTs: Shared uint8 lookups on contiguous CPU Tensors use a direct StringZilla destination path in the measured size regions (see docs/numkong-performance.md).
Micro-benchmarks vs NumPy/OpenCV/NumKong: see benchmarks/README.md. Run uv run python benchmarks/benchmark_elementwise.py for exp/sqrt, or uv run python benchmarks/benchmark_numkong.py for a smaller NumKong sweep.
Albucore is publicly available under the MIT License, including
contributions accepted under the
Albucore Contributor License Agreement Version 1.0. The CLA does not
change the repository's public license. Historical contributions remain
available under MIT and become CLA-covered only through an applicable Version
1.0 Acceptance Record. See CONTRIBUTING.md for the individual
CLA Assistant and entity acceptance paths.
Acknowledgements
Albucore provides core image-processing primitives for AlbumentationsX. We'd like to thank all AlbumentationsX contributors and the broader computer vision community for their inspiration and support.
Works well with
Use together with albucore: extensions, drivers, servers and companion tools.
opencv-pythonPythie’s Index: 81Wrapper package for OpenCV python bindings.34.3M downloads/mo
albumentationsPythie’s Index: 37Fast, flexible, and advanced augmentation library for deep learning, computer vision, and medical imaging. Albumentations offers a wide range of transformations for both 2D (images, masks, bboxes, keypoints) and 3D (volumes, volumetric masks, keypoints) data, with optimized performance and seamless integration into ML workflows.2.4M downloads/mo
albumentationsxPythie’s Index: 84Fast, flexible, and advanced augmentation library for deep learning, computer vision, and medical imaging. Albumentations offers a wide range of transformations for both 2D (images, masks, bboxes, keypoints) and 3D (volume data, volumetric masks, keypoints) data, with optimized performance and seamless integration into ML workflows. Available under AGPL-3.0-only or a commercial license with agreed coverage for your team, products, and deployments.150.8K downloads/mo