images#

File parsers for images stored as zoom-level pyramids

class DeepZoom(file: Path = None)[source]#

Represents a zoom-level image pyramid stored in DeepZoom format.

A DeepZoom image is a large image is subdivided into smaller tiles for various zoom levels, creating a “pyramid of tiles”. For given zoom level and region of interest, we then know how to quickly look up the data to be displayed, without having to rescale the original image.

This class reads and returns the meta data for the image, provides helper functions for working with dimensions, and loads and returns tiles. It doesn’t store pixel data in memory, but provides load_tile() to return it.

Higher zoom means bigger picture. Zoom level 0 corresponds to the smallest available picture, zoomed out the most. There is typically only one tile at that level, though that depends on the settings used when the image pyramid was generated.

file#

file with image meta data

image_width#

width of the full image

image_height#

height of the full image

tile_width#

width of a single tile

tile_height#

height of a single tile

overlap#

pixel overlap between tiles

tile_format#

file format of tile images

zoom_levels#

available zoom levels, biggest to smallest

zoom_min#

minimum available zoom level (smallest number)

zoom_max#

maximum available zoom level (largest number)

parse()[source]#

Parses the meta data for an image.

tiles_i(zoom)[source]#

Returns the number of tiles in the x direction.

tiles_j(zoom)[source]#

Returns the number of tiles in the y direction.

x_to_i(x)[source]#

Returns tile number for given x-coordinate in the full image.

y_to_j(y)[source]#

Returns tile number for given y-coordinate in the full image.

tile_x1(i, clip=False)[source]#

Returns the x-coordinate of the left edge of tiles number i.

This includes the overlap pixels.

tile_y1(j, clip=False)[source]#

Returns the y-coordinate of top edge of tiles number j.

This includes the overlap pixels.

tile_x2(i, zoom)[source]#

Returns the x-coordinate of the right edge of tiles number i.

This includes the overlap pixels. The returned pixel index is actually one pixel beyond the edge, in anticipation of right-inclusive ranges.

tile_y2(tile, zoom)[source]#

Returns the y-coordinate of the bottom edge of tiles number j.

This includes the overlap pixels. The returned pixel index is actually one pixel beyond the edge, in anticipation of right-inclusive ranges.

overlap_x1(i)[source]#

Returns the pixel overlap for tiles number i at left edge.

overlap_y1(j)[source]#

Returns the pixel overlap for tiles number j at top edge.

overlap_x2(i, zoom)[source]#

Returns the pixel overlap for tiles number i at right edge.

overlap_y2(j, zoom)[source]#

Returns the pixel overlap for tiles number j at bottom edge.

level_width(zoom)[source]#

Returns the width of the image at the given zoom level.

Raises ZoomError if the zoom level doesn’t exist.

level_height(zoom)[source]#

Returns the height of the image at the given zoom level.

Raises ZoomError if the zoom level doesn’t exist.

tile_file(i, j, zoom)[source]#

Returns the file path of tile (i, j) at given zoom level.

load_tile(i, j, zoom)[source]#

Loads tile (i, j) at given zoom level.

Returns the image data as a NumPy array. Raises FileFormatError if the file format is not recognized.