|
1 | | -from pathlib import Path |
2 | | -from typing import TYPE_CHECKING, Union |
| 1 | +from typing import TYPE_CHECKING |
3 | 2 |
|
4 | 3 | import cv2 |
5 | 4 |
|
6 | | -from .base import AssociatedImages, ReaderBase, SlideProperties, convert_image |
| 5 | +from .base import ReaderBase, SlideProperties |
7 | 6 |
|
8 | 7 | if TYPE_CHECKING: |
9 | 8 | from spatialdata.models import Image2DModel |
@@ -112,17 +111,16 @@ def get_region( |
112 | 111 | img = self.img |
113 | 112 |
|
114 | 113 | downsample_factor = self.properties.level_downsample[level] |
115 | | - # SpatialData coordinates must be translated to the respective level |
116 | | - x = x / downsample_factor |
117 | | - y = y / downsample_factor |
118 | | - width = width / downsample_factor |
119 | | - height = height / downsample_factor |
120 | 114 | if self.is_multiscale: |
121 | 115 | data = img.sel( |
122 | | - y=slice(y, y + height), x=slice(x, x + width) |
| 116 | + y=slice(y, y + height * downsample_factor), |
| 117 | + x=slice(x, x + width * downsample_factor), |
123 | 118 | ).image.data.compute() |
124 | 119 | else: |
125 | | - data = img.sel(y=slice(y, y + height), x=slice(x, x + width)).data.compute() |
| 120 | + data = img.sel( |
| 121 | + y=slice(y, y + height * downsample_factor), |
| 122 | + x=slice(x, x + width * downsample_factor), |
| 123 | + ).data.compute() |
126 | 124 | return data.transpose(1, 2, 0) |
127 | 125 |
|
128 | 126 | def get_thumbnail(self, size, **kwargs): |
|
0 commit comments