Image Tiling Utils
Minimalistic set of image reader agnostic tools to easily iterate over large images
Example 1
Let's iterate over a large image with overlapping tiles of the same size tiles in pixels. At boundaries we add "no-data" pixels. Let's assume the data access is provided with an example function
def read_data(x, y, width, height, out_width=None, out_height=None):
out_width = width if out_width is None else out_width
out_height = height if out_height is None else out_height
img.read(x, y, width, height, out_width, out_height)
Thus, overlapping tiles can be extracted as
from tiling import ConstStrideTiles
tiles = ConstStrideTiles(image_size=(500, 500), tile_size=(256, 256), stride=(100, 100),
origin=(-100, -100),
scale=1.0,
include_nodata=True)
print("Number of tiles: %i" % len(tiles))
for extent, out_size in tiles:
x, y, width, height = extent
data = read_data(x, y, width, height,
out_width=out_size[0],
out_height=out_size[1])
print("data.shape: {}".format(data.shape))
# Access a tile:
i = len(tiles) // 2
extent, out_size = tiles[i]
Example 2
Let's iterate over a large image with overlapping tiles of the same size in pixels.
In this case we prefer to not going outside the input image and fill tiles with nodata.
In this situation, overlapping is not constant.
Let's assume the data access is provided with an example function
def read_data(x, y, width, height, out_width=None, out_height=None):
out_width = width if out_width is None else out_width
out_height = height if out_height is None else out_height
img.read(x, y, width, height, out_width, out_height)
Thus, overlapping tiles can be extracted as
from tiling import ConstSizeTiles
tiles = ConstSizeTiles(image_size=(500, 500), tile_size=(256, 256), min_overlapping=15, scale=1.0)
print("Number of tiles: %i" % len(tiles))
for extent, out_size in tiles:
assert out_size[0] == tiles.tile_size[0]
assert out_size[1] == tiles.tile_size[1]
x, y, width, height = extent
data = read_data(x, y, width, height,
out_width=out_size[0],
out_height=out_size[1])
print("data.shape: {}".format(data.shape))
# Access a tile:
i = len(tiles) // 2
extent = tiles[i]
Installation:
from pip
pip install tiling
from sources
pip install git+https://github.com/vfdev-5/ImageTilingUtils.git
Examples
For more practical examples, see notebooks
Metadata
Release files for tiling 0.3.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 | |
|---|---|---|---|
| tiling-0.3.0.tar.gz | 5.3 kB | Details |
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| tiling-0.3.0-py3.6.egg | Legacy Egg format | - | - | Details |
| tiling-0.3.0-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Total release size: 26.4 kB
Release files / tiling-0.3.0.tar.gz
| Download URL | tiling-0.3.0.tar.gz |
|---|---|
| Size | 5.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
888bf09385f5e200916e3308a2a2b1534c6837d52be552e5d077687f5be9799a
|
|
BLAKE2b-256 checksum How to use checksums |
8b5cf877513ee613894203d8e78f7a926b45b51e6408699f4e189d8e9d8331f7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.6.7
|
Release files / tiling-0.3.0-py3.6.egg
| Download URL | tiling-0.3.0-py3.6.egg |
|---|---|
| Size | 13.4 kB |
| Tags | Egg |
|
SHA-256 checksum How to use checksums |
cd9623d9c9bb3b7ec410b5a4bd87a16930e9559695ba6ef4a287bbd1993986ee
|
|
BLAKE2b-256 checksum How to use checksums |
0d7d69478f6027f0e3a59ff91e7be219204fa858a236724620872268e3f38825
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.6.7
|
Release files / tiling-0.3.0-py2.py3-none-any.whl
| Download URL | tiling-0.3.0-py2.py3-none-any.whl |
|---|---|
| Size | 7.6 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
92d606be0a49746ef6de758c23e09ee232454252d5170fdb8ac01ba7863b5b07
|
|
BLAKE2b-256 checksum How to use checksums |
8b7c741c08e17e66983c3423c1f2a3ec729e538b62bfa67e4fafd1b442745ee4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.6.7
|