wsidata.shapes2tiles#

shapes2tiles(wsi, shape_key, image_size=None)#

Convert arbitrary shapes into tile read specifications.

When a TileSpec is stored for shape_key, tiles are derived from it directly (uniform grid). Otherwise, each shape’s bounding box is used and the optimal pyramid level is selected per-shape.

Parameters:
wsiWSIData

The whole-slide image data object.

shape_keystr

Key into wsi.shapes for the shape collection.

image_sizetuple of (int, int), optional

Desired output (width, height). Only used when no TileSpec is available. When given, the best pyramid level is chosen so the read region is closest to image_size, and the returned TileRequest is populated with dsize=image_size for later resizing by the code that executes the request.

Returns:
list[TileRequest]

One TileOp per shape, with coordinates at level 0.