Skip to main content

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.

PyPI version Downloads Python License: MIT CI

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-triptile → predict → reconstruct produces 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

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)

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.

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. See CONTRIBUTING.md for guidelines.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

imtile-0.1.1.tar.gz (10.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

imtile-0.1.1-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file imtile-0.1.1.tar.gz.

File metadata

  • Download URL: imtile-0.1.1.tar.gz
  • Upload date:
  • Size: 10.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for imtile-0.1.1.tar.gz
Algorithm Hash digest
SHA256 8b8879ef72d308eb541d8a33fd2347285d2c1f029cdaa314addfa43d94434225
MD5 4ecb67dca644d4f372857412c6d47690
BLAKE2b-256 9cb80f22ab31b993f40e16f7cbd6f038bb27d419688afa7b34c9215f0b0413dd

See more details on using hashes here.

Provenance

The following attestation bundles were made for imtile-0.1.1.tar.gz:

Publisher: publish.yml on omarkamelte/imtile

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file imtile-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: imtile-0.1.1-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

Hashes for imtile-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e137d4516c2f289f175c4c98b3121ef072c0294d0c79b0e8b38e6d445fa9533b
MD5 d468ea1dc104af3d8e57f41d7fdd93a2
BLAKE2b-256 b2d9b00168b97f40605bb3b51c5c0c56c8ce23d007e2133a2b7db5752a258acd

See more details on using hashes here.

Provenance

The following attestation bundles were made for imtile-0.1.1-py3-none-any.whl:

Publisher: publish.yml on omarkamelte/imtile

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page