Skip to content

Commit

Permalink
🐛 Fix Immutable Output from WSIReader (#850)
Browse files Browse the repository at this point in the history
- Resolve issue #837 

The output of WSI readers (read_rect, read_region, etc) are immutable, i.e. Read-only. We assume that created Numpy arrays created from PIL images in the `background_composite` are mutable by default.
After Numpy v1.16.0, doing np.asarray(pil_image) will return an immutable Numpy array. Gladly, there is an easy fix for this, we should use `np.array()` instead of `np.asarray`.
  • Loading branch information
mostafajahanifar authored Aug 23, 2024
1 parent b0b1474 commit 70db186
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tiatoolbox/utils/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ def background_composite(
)
composite.alpha_composite(image)
if not alpha:
return np.asarray(composite.convert("RGB"))
return np.array(composite.convert("RGB"))

return np.asarray(composite)
return np.array(composite)


def _convert_scalar_to_width_height(array: np.ndarray) -> np.ndarray:
Expand Down

0 comments on commit 70db186

Please sign in to comment.