ndtiler
A lightweight Python package for iterative tiling over N-dimensional arrays.
Overview
ndtiler is a simple, efficient library that generates tile coordinates for processing large N-dimensional arrays in smaller chunks. This approach is particularly useful for operations on large images, volumetric data, or any N-dimensional matrix that's too large to process at once.
While available as a package, the entire implementation is contained in a single file that can be easily copy-pasted into your project as a "header-only" style Python module.
The library offers two tiling strategies:
- Static tiling: Requires even sampling of the input matrix (default)
- Minimally Dynamic tiling: Adjusts the final tiles in each dimension to fit the matrix size exactly
Installation
pip install ndtiler
Basic Usage
import numpy as np
from ndtiler import tile_nd, dynamic_tile_nd
# Create a sample 2D array
data = np.zeros((512, 512))
# Define tile size and overlap
tile_size = (128, 128)
overlap = (32, 32)
# Generate tile coordinates using static tiling
for ((y0, y1), (x0, x1)) in tile_nd(data.shape, tile_size, overlap):
tile = data[y0:y1, x0:x1] # Extract the tile
#
# Process the tile...
#
# Generate tile coordinates using dynamic tiling
for ((y0, y1), (x0, x1)) in dynamic_tile_nd(data.shape, tile_size, overlap):
tile = data[y0:y1, x0:x1] # Extract the tile
#
# Process the tile...
#
Key Functions
Tiling Functions
tile_nd(size, tile_size, overlap): Static tiling that requires even division of the input shape.dynamic_tile_nd(size, tile_size, overlap): Dynamic tiling that adjusts the final tiles in each dimension.
Utility Functions
get_stride(tile_size, overlap): Calculate the step size between tiles.get_overlap_from_stride(tile_size, stride): Calculate overlap given tile size and stride.get_overflow(size, tile_size, overlap): Calculate the adjustment needed for even tiling.get_tile_count(size, tile_size, overlap): Calculate the number of tiles needed in each dimension.
More in-depth examples can be seen in the examples/ directory.
License
MIT License
Author
Ryan 'RyanIRL' Peters
Metadata
Release files for ndtiler 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ndtiler-0.1.0.tar.gz | 4.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ndtiler-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.1 kB
Release files / ndtiler-0.1.0.tar.gz
| Download URL | ndtiler-0.1.0.tar.gz |
|---|---|
| Size | 4.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1e7fa95c86f151003da76b593ed67edc04012e804473b98ca4ffb9bacb13ba52
|
|
BLAKE2b-256 checksum How to use checksums |
b49e6f56153e719ce6607d1d6e319f8c95f5c3fffc22dab50fea4ca6200f4b7f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.13
|
Release files / ndtiler-0.1.0-py3-none-any.whl
| Download URL | ndtiler-0.1.0-py3-none-any.whl |
|---|---|
| Size | 5.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2d90ad28de549cc024cc15aa69b7493df09775b26add8fb2cc8da7fcb5bc11ab
|
|
BLAKE2b-256 checksum How to use checksums |
d1de490669178a85b4ae26fa44912c0ead1877774fbf8f65532c3fa0678f9f42
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.13
|