ratiopath.openslide.OpenSlide
Bases: OpenSlide
A wrapper around the OpenSlide library to provide additional functionality.
Source code in ratiopath/openslide.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
|
closest_level(mpp)
Finds the closest slide level to match the desired MPP.
This method compares the desired MPP (µm/px) with the MPP of the available levels in the slide and selects the level with the closest match.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mpp
|
float | tuple[float, float]
|
The desired µm/px value. |
required |
Returns:
Type | Description |
---|---|
int
|
The index of the level with the closest µm/px resolution to the desired value. |
Source code in ratiopath/openslide.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
|
read_region_relative(location, level, size)
Reads a region from the slide with coordinates relative to the specified level.
This method adjusts the coordinates based on the level's downsampling factor before reading the region from the slide.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
location
|
tuple[int, int]
|
The (x, y) coordinates at the specified level. |
required |
level
|
int
|
The level of the slide to read from. |
required |
size
|
tuple[int, int]
|
The (width, height) of the region to read. |
required |
Returns:
Type | Description |
---|---|
Image
|
The image of the requested region. |
Source code in ratiopath/openslide.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
|
slide_resolution(level)
Returns the resolution of the slide in µm/px at the given level.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
level
|
int
|
The level of the slide to calculate the resolution. |
required |
Returns:
Type | Description |
---|---|
tuple[float, float]
|
The [x, y] resolution of the slide in µm/px. |
Source code in ratiopath/openslide.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
|