Albucore

0.1.5 · active · verified Thu Apr 09

Albucore is a high-performance Python library offering optimized atomic functions for image processing in deep learning and computer vision. It serves as a foundational component for the AlbumentationsX library, automatically selecting the fastest implementation for operations using backends like NumPy and OpenCV. Currently at version 0.1.5, the library is actively maintained with frequent updates and performance enhancements.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to import and use a basic image processing function (`multiply` and `add`) from Albucore. It highlights the crucial image shape convention by providing examples for both RGB and grayscale images, ensuring the channel dimension is always present.

import numpy as np
import albucore

# Create a sample RGB image (H, W, C) - uint8 is a supported dtype
image_rgb = np.random.randint(0, 256, (100, 100, 3), dtype=np.uint8)

# Create a sample grayscale image (H, W, 1) - explicit channel dimension is required
image_gray = np.random.randint(0, 256, (100, 100, 1), dtype=np.uint8)

# Apply a function, e.g., multiply by a constant
result_rgb = albucore.multiply(image_rgb, 1.5)
result_gray = albucore.add(image_gray, 50)

print(f"Original RGB shape: {image_rgb.shape}, dtype: {image_rgb.dtype}")
print(f"Result RGB shape: {result_rgb.shape}, dtype: {result_rgb.dtype}")
print(f"Original Grayscale shape: {image_gray.shape}, dtype: {image_gray.dtype}")
print(f"Result Grayscale shape: {result_gray.shape}, dtype: {result_gray.dtype}")

view raw JSON →