Lightweight image tiling and reconstruction for computer vision and deep learning pipelines.
Project description
imtile
Lightweight image tiling and reconstruction for computer vision & deep learning.
Split large images into fixed-size overlapping tiles for neural network inference, then reassemble them with weighted-average blending for seamless, lossless reconstruction.
Features
- ✅ Configurable overlap — eliminate boundary artifacts in segmentation / detection
- ✅ Lossless round-trip —
tile → predict → reconstructproduces the exact original dimensions - ✅ Boundary snapping — handles images whose dimensions aren't multiples of tile size
- ✅ GPU acceleration — auto-detects CuPy for transparent GPU processing
- ✅ Framework agnostic — works with plain NumPy arrays (no PyTorch/TF dependency)
- ✅ Grayscale & multi-channel — supports 2-D and 3-D arrays
- ✅ Tile position API — get
(y, x, y_end, x_end)coordinates for mapping predictions back
Installation
pip install imtile
With GPU support (requires CUDA):
pip install imtile[gpu]
Quick Start
import numpy as np
from imtile import ImageTiler
# Load your large image (H, W, C)
image = np.random.randint(0, 256, (2048, 2048, 3), dtype=np.uint8)
# Create tiler with 256×256 tiles and 32px overlap
tiler = ImageTiler(tile_size=256, overlap=32)
# Split into tiles
tiles = tiler.tile(image)
print(f"Generated {len(tiles)} tiles")
# Process each tile (e.g., run through a neural network)
predictions = [my_model(tile) for tile in tiles]
# Reconstruct the full-size output
result = tiler.reconstruct(predictions, image.shape)
assert result.shape == image.shape
Convenience Functions
from imtile import tile_image, reconstruct_image
tiles = tile_image(image, tile_size=256, overlap=32)
result = reconstruct_image(tiles, image.shape, tile_size=256, overlap=32)
Get Tile Positions
positions = tiler.get_tile_positions(image.shape)
for y_start, x_start, y_end, x_end in positions:
print(f"Tile at [{y_start}:{y_end}, {x_start}:{x_end}]")
Algorithm
┌──────────────────────────────────────────┐
│ Original Image (H×W) │
│ │
│ ┌─────────┐ │
│ │ Tile 0 │ │
│ │ │─overlap─┐ │
│ └─────────┘ │ │
│ ┌─────────────┤ │
│ │ Tile 1 │ │
│ │ │ │
│ └──────────────┘ │
│ ... │
│ ┌────────────┐ │
│ Boundary tiles snap → │ Tile N │ │
│ to image edge │ (snapped) │ │
│ └────────────┘ │
└──────────────────────────────────────────┘
Reconstruction: canvas += tile; weights += 1
result = canvas / weights (weighted average)
Complexity: O(H × W) — linear in image area, optimal.
API Reference
ImageTiler(tile_size, overlap=0)
| Method | Description |
|---|---|
tile(image) |
Split image into tiles. Returns List[ndarray]. |
reconstruct(tiles, original_shape) |
Reassemble tiles with weighted averaging. |
get_tile_positions(image_shape) |
Get (y, x, y_end, x_end) for each tile. |
Module Functions
| Function | Description |
|---|---|
tile_image(image, tile_size, overlap) |
Convenience wrapper for ImageTiler.tile. |
reconstruct_image(tiles, shape, tile_size, overlap) |
Convenience wrapper for ImageTiler.reconstruct. |
gpu_available() |
Returns True if CuPy/CUDA is detected. |
Use Cases
- Semantic segmentation of satellite / aerial / medical imagery
- Object detection on high-resolution images (complementary to SAHI)
- Super-resolution inference on large inputs
- Any pipeline that needs to process images larger than GPU memory
License
MIT — free for personal, academic, and commercial use.
Contributing
Contributions are welcome! Please open an issue or pull request on GitHub.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file imtile-0.1.0.tar.gz.
File metadata
- Download URL: imtile-0.1.0.tar.gz
- Upload date:
- Size: 10.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d33f72a3066a7d67705ca88c160906fe7c578dc6ddfc1d3f12c6eaf581ceae3e
|
|
| MD5 |
e34fa760cdd8256941a65d3409cb10dd
|
|
| BLAKE2b-256 |
5cb47153b4b4e7f3d332a0f413a579e51404e14db595f06603998d2da8dd235b
|
Provenance
The following attestation bundles were made for imtile-0.1.0.tar.gz:
Publisher:
publish.yml on omarkamelte/imtile
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
imtile-0.1.0.tar.gz -
Subject digest:
d33f72a3066a7d67705ca88c160906fe7c578dc6ddfc1d3f12c6eaf581ceae3e - Sigstore transparency entry: 1059745527
- Sigstore integration time:
-
Permalink:
omarkamelte/imtile@0d1094728ef3d8ebe4fb266e47e134c15e0f336b -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/omarkamelte
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@0d1094728ef3d8ebe4fb266e47e134c15e0f336b -
Trigger Event:
release
-
Statement type:
File details
Details for the file imtile-0.1.0-py3-none-any.whl.
File metadata
- Download URL: imtile-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
746d97d0e33a4f5608a8184fa2d6ca2c4719142d4f8c43115f974301d04c1557
|
|
| MD5 |
8d2722badfaf1bf934a5248c9bcf8e8c
|
|
| BLAKE2b-256 |
4d481953a1bb389ac29ff3ede85012bdb4f03a87382f168b3b550350cfd450ca
|
Provenance
The following attestation bundles were made for imtile-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on omarkamelte/imtile
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
imtile-0.1.0-py3-none-any.whl -
Subject digest:
746d97d0e33a4f5608a8184fa2d6ca2c4719142d4f8c43115f974301d04c1557 - Sigstore transparency entry: 1059745529
- Sigstore integration time:
-
Permalink:
omarkamelte/imtile@0d1094728ef3d8ebe4fb266e47e134c15e0f336b -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/omarkamelte
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@0d1094728ef3d8ebe4fb266e47e134c15e0f336b -
Trigger Event:
release
-
Statement type: