GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - vfdev-5/ImageTilingUtils: Minimalistic set of image reader agnostic tools to easily iterate over large images

BranchesTags
Open more actions menu

Latest commit

 

History

30 Commits
30 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
assets
assets
 
 
docs
docs
 
 
examples
examples
 
 
tests
tests
 
 
tiling
tiling
 
 
.gitignore
.gitignore
 
 
.travis.yml
.travis.yml
 
 
LICENSE.md
LICENSE.md
 
 
README.md
README.md
 
 
pyproject.toml
pyproject.toml
 
 
setup.cfg
setup.cfg
 
 
setup.py
setup.py
 
 

Repository files navigation

Build Status Coverage Status Documentation Status

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 1 tiles

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]

example 2 tiles

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

About

Minimalistic set of image reader agnostic tools to easily iterate over large images

imagetilingutils.readthedocs.io/en/latest/

Topics

imagepython3tiletiling

Resources

Readme
MIT license
Activity

Stars

14 stars

Watchers

2 watching

Forks

2 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.