Skip to content

Commit

Permalink
Fixes{#191}
Browse files Browse the repository at this point in the history
  • Loading branch information
AjeyPaiK committed Nov 14, 2023
1 parent f6b4b6e commit a8e9c89
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions dlup/_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,10 +402,15 @@ def read_region(
region = region.resize(size, resample=self._interpolator, box=box)
return region

def get_scaled_size(self, scaling: GenericNumber) -> tuple[int, int]:
def get_scaled_size(self, scaling: GenericNumber, use_limit_bounds: Optional[bool] = False) -> tuple[int, int]:
"""Compute slide image size at specific scaling."""
size = np.array(self.size) * scaling
return cast(tuple[int, int], tuple(size.astype(int)))
if use_limit_bounds:
bounded_size = self.bounded_size
size = int(bounded_size[0] * scaling), int(bounded_size[1] * scaling)
else:
size = np.array(self.size) * scaling
cast(tuple[int, int], tuple(size.astype(int)))
return size

def get_mpp(self, scaling: float) -> float:
"""Returns the respective mpp from the scaling."""
Expand Down Expand Up @@ -482,6 +487,12 @@ def size(self) -> tuple[int, int]:
"""Returns the highest resolution image size in pixels. Returns in (width, height)."""
return self._wsi.dimensions

@property
def bounded_size(self) -> tuple[int, ...]:
"""Returns the effective size of the wsi considering the slide bounds property"""
_, bounded_size = self._wsi.slide_bounds
return int(bounded_size[0]), int(bounded_size[1])

@property
def mpp(self) -> float:
"""Returns the microns per pixel of the high res image."""
Expand Down

0 comments on commit a8e9c89

Please sign in to comment.