PointsPatchExtractor¶
- class PointsPatchExtractor(input_img, locations_list, patch_size=(224, 224), resolution=0, units='level', pad_mode='constant', pad_constant_values=0, *, within_bound=False)[source]¶
Extracting patches with specified points as a centre.
- Parameters:
input_img(str – class:WSIReader): Input image for patch extraction.
pathlib.Path – class:WSIReader): Input image for patch extraction.
input_img (str | Path | np.ndarray | wsireader.WSIReader)
locations_list (np.ndarray | DataFrame | str | Path)
resolution (Resolution)
units (Units)
pad_mode (str)
within_bound (bool)
- :param
numpy.ndarray
: class:WSIReader): Input image for patch extraction.
- Parameters:
locations_list (ndarray, pd.DataFrame, str, pathlib.Path) – Contains location and/or type of patch. This can be path to csv, npy or json files. Input can also be a
numpy.ndarray
orpandas.DataFrame
. NOTE: value of location $(x,y)$ is expected to be based on the specified resolution and units (not the ‘baseline’ resolution).patch_size (int or tuple(int)) – Patch size tuple (width, height).
resolution (Resolution) – Resolution at which to read the image, default = 0. Either a single number or a sequence of two numbers for x and y are valid. This value is in terms of the corresponding units. For example: resolution=0.5 and units=”mpp” will read the slide at 0.5 microns per-pixel, and resolution=3, units=”level” will read at level at pyramid level / resolution layer 3.
units (Units) – The units of resolution, default = “level”. Supported units are: microns per pixel (mpp), objective power (power), pyramid / resolution level (level), Only pyramid / resolution levels (level) embedded in the whole slide image are supported.
pad_mode (str) – Method for padding at edges of the WSI. Default to ‘constant’. See
numpy.pad()
for more information.pad_constant_values (int or tuple(int)) – Values to use with constant padding. Defaults to 0. See
numpy.pad()
for more.within_bound (bool) – Whether to extract patches beyond the input_image size limits. If False, extracted patches at margins will be padded appropriately based on pad_constant_values and pad_mode. If True, patches at the margins whose bounds would exceed the mother image dimensions would be neglected. Default is False.
input_img (str | Path | np.ndarray | wsireader.WSIReader)
Initialize
PointsPatchExtractor
.Methods