Skip to content

Commit

Permalink
Revert _is_foreground_numpy chang
Browse files Browse the repository at this point in the history
  • Loading branch information
BPdeRooij committed Aug 2, 2024
1 parent 8f6f6d2 commit a8814d7
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion dlup/background.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,15 @@ def _is_foreground_numpy(
x, y, w, h, mpp = region

mask_size = np.array(background_mask.shape[:2][::-1])

region_view = slide_image.get_scaled_view(slide_image.get_scaling(mpp))
_background_mask = PIL.Image.fromarray(background_mask)

# Type of background_mask is Any here.
# The scaling should be computed using the longest edge of the image.
background_size = (_background_mask.width, _background_mask.height)

region_size = slide_image.get_scaled_size(slide_image.get_scaling(mpp))
region_size = region_view.size
max_dimension_index = max(range(len(background_size)), key=background_size.__getitem__)
scaling = background_size[max_dimension_index] / region_size[max_dimension_index]
scaled_region = np.array((x, y, w, h)) * scaling
Expand Down

0 comments on commit a8814d7

Please sign in to comment.