AnnotationTileGenerator#
- class AnnotationTileGenerator(info, store, renderer=None, tile_size=256, downsample=2, overlap=0)[source]#
Tile generator using an AnnotationRenderer to render tiles showing annotations held in an AnnotationStore
- Parameters:
info (WSIMeta) – An WSIMeta Object storing the metadata of the slide this generator is rendering tiles for
Store (AnnotationStore) – An AnnotationStore Object containing annotations to be rendered for given slide
renderer (AnnotationRenderer) – An AnnotationRenderer Object which will render annotations belonging to a tile according to specified parameters
tile_size (int) – The size of tiles to generate. Default is 256. Note that the output tile size will be \(\text{tile size} + 2 \times\text{overlap}\).
downsample (int) – The downsample factor between levels. Default is 2.
overlap (int) – The number of extra pixel to add to each edge of the tile. Default is 0.
store (AnnotationStore) –
Methods
Return a thumbnail which fits the whole slide in one tile.
Render a tile at a given level and coordinate.
The total pixel dimensions of the tile pyramid at a given level.
Attributes
Number of levels in the tile pyramid.
- get_thumb_tile()[source]#
Return a thumbnail which fits the whole slide in one tile.
The thumbnail output size has the longest edge equal to the tile size. The other edge preserves the original aspect ratio.
- Return type:
<module ‘PIL.Image’ from ‘/home/docs/checkouts/readthedocs.org/user_builds/tia-toolbox/envs/v1.4.1/lib/python3.10/site-packages/PIL/Image.py’>
- get_tile(level, x, y, res=1, pad_mode=None, interpolation=None)[source]#
Render a tile at a given level and coordinate.
Note that levels are in the reverse order of those in WSIReader. I.E. level 0 here corresponds to the lowest resolution whereas level 0 in WSIReader corresponds to the maximum resolution (baseline).
- Parameters:
- Returns:
Pillow image of the tile.
- Return type:
PIL.Image
Example
>>> from tiatoolbox.tools.pyramid import AnnotationTileGenerator >>> from tiatoolbox.wsicore.wsireader import WSIReader >>> from tiatoolbox.annotation.storage import SQLiteStore >>> wsi = WSIReader.open("sample.svs") >>> SQ=SQLiteStore.from_geojson(geo_path) >>> tile_generator = AnnotationTileGenerator( ... info=wsi.info, ... store=SQ, ... ) >>> tile_0_0_0 = tile_generator.get_tile(level=0, x=0, y=0)