Periodic raster rotation approximation for toroidally tiling NumPy images
Project description
toroidal-rotate
toroidal-rotate is a small NumPy utility for periodic raster rotation of toroidally tiling images.
It keeps the same array shape, uses wraparound boundaries, and rotates by inverse-mapped sampling on the periodic image domain.
What it is
The transform is:
- deterministic
- same output shape as input
- periodic under square tiling
- works on grayscale
(H, W)and channels-last(H, W, C)arrays
What it is not
This is not an exact Euclidean rotation. It is a periodic raster approximation using wrapped inverse sampling, so inverse rotation is approximate rather than exact and repeated small angles are not numerically exact cumulative rotation.
Installation
pip install toroidal-rotate
Showcase
Direct file: docs/showcase.gif
Usage
Example 1: grayscale periodic rotation
import numpy as np
from toroidal_rotate import toroidal_rotate
image = np.arange(8 * 8).reshape(8, 8)
rotated = toroidal_rotate(image, 24)
Example 2: RGB image
import numpy as np
from toroidal_rotate import toroidal_rotate
image = np.zeros((64, 64, 3), dtype=np.uint8)
image[..., 0] = 255
rotated = toroidal_rotate(
image,
angle_degrees=24,
rounding="nearest",
center="pixel_center",
)
API
from toroidal_rotate import (
ToroidalRotationError,
ToroidalRotationSpec,
toroidal_rotate,
toroidal_rotate_inverse,
toroidal_rotate_many,
)
toroidal_rotate_inverse applies the matching wrapped inverse angle, but due to raster quantization it is approximate rather than exact round-trip restoration.
Build and publish
python -m pip install --upgrade build twine
python -m build
twine upload --repository testpypi dist/*
# after checking it works
twine upload dist/*
To regenerate the demo GIF:
PYTHONPATH=src python scripts/make_showcase_gif.py
License
MIT
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 toroidal_rotate-0.2.0.tar.gz.
File metadata
- Download URL: toroidal_rotate-0.2.0.tar.gz
- Upload date:
- Size: 5.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
949f4f1c8702919c766b474156ceb751cc46676146fac4aef768f491cad0fcb8
|
|
| MD5 |
4f4570f0d16c34bd5224dd51318492b6
|
|
| BLAKE2b-256 |
9234fca3f72dc8e176f0b88d8758e96ab74d87ecd6755a8335a96b11acff6b84
|
File details
Details for the file toroidal_rotate-0.2.0-py3-none-any.whl.
File metadata
- Download URL: toroidal_rotate-0.2.0-py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6b149ffef5e2621d73ee86e9e26d4dfc50a1e3e5a43c4c67551c8237a3a07fd9
|
|
| MD5 |
bf4009307b6eae67a4c6ee5c9dc33448
|
|
| BLAKE2b-256 |
97f0d9a049c46bc2706b9e096525fcb16de4efac444e1675ac99e8bfbb8fddfb
|