wsidata.reader.ReaderBase#

class ReaderBase#

Bases: ABC

The base class for all reader

This class defines the basic interface for all reader

Attributes:
filestr

The path to the image file

propertiesSlideProperties

The properties of the slide

namestr

The name of the reader

readerAny

The reader object

property associated_images#

The associated images in a key-value pair

abstractmethod create_reader()#

Create the reader

This function should be implemented in the subclass

  1. create the reader

  2. use set_reader to set the reader

abstractmethod detach_reader()#

Detach the reader

This function will be called when the object is deleted or sent to other process

Please implement this function in the subclass

  1. Close the reader

  2. use set_reader to set the reader to None

  3. Clean up any resources that are not python-managed

get_center(x, y, width, height, level=0, **kwargs)#

Get a patch from image with center

get_level(level, in_bounds=False)#

Extract the image at the given level

A very expensive operation, use with caution

Parameters:
levelint

The level to extract

in_boundsbool

If True, only extract the region that are in the bounds

abstractmethod get_region(x, y, width, height, level=0, **kwargs)#

Get a region from image with top-left corner.

x, y are always in level 0 coordinates. width, height are at the specified pyramid level.

This should return a numpy array in yxc format.

abstractmethod get_thumbnail(size, **kwargs)#

Get a thumbnail of the image

property raw_properties#

Get the raw properties of the slide

translate_level(level)#

Translate the level to the actual level

level -1 refer to the lowest resolution level

Parameters:
levelint

The level to translate