Skip to content

Commit a4e58b8

Browse files
committed
👽 scikit-image>0.26.0 API uses max_image for remove_small_objects
1 parent 275e4e9 commit a4e58b8

File tree

5 files changed

+7
-6
lines changed

5 files changed

+7
-6
lines changed

requirements/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pillow>=9.3.0
2424
pydicom>=2.3.1 # Used by wsidicom
2525
pyyaml>=6.0
2626
requests>=2.28.1
27-
scikit-image>=0.20
27+
scikit-image>=0.26.0
2828
scikit-learn>=1.2.0
2929
scipy>=1.8
3030
shapely>=2.0.0

tiatoolbox/models/architecture/hovernet.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ def _proc_np_hv(
541541
blb = np.array(blb_raw >= 0.5, dtype=np.int32) # noqa: PLR2004
542542

543543
blb = ndimage.label(blb)[0]
544-
blb = remove_small_objects(blb, min_size=10)
544+
blb = remove_small_objects(blb, max_size=9)
545545
blb[blb > 0] = 1 # background is 0 already
546546

547547
h_dir = cv2.normalize(
@@ -610,7 +610,8 @@ def _proc_np_hv(
610610
"ignore",
611611
message="Only one label was provided to `remove_small_objects`",
612612
)
613-
marker = remove_small_objects(marker, min_size=obj_size)
613+
# scikit-image changed API in 0.26.0 from min_size to max_size.
614+
marker = remove_small_objects(marker, max_size=obj_size - 1)
614615

615616
return watershed(dist, markers=marker, mask=blb)
616617

tiatoolbox/models/architecture/hovernetplus.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ def _proc_ls(ls_map: np.ndarray) -> np.ndarray:
158158
epith_all = epith_all > 0
159159
epith_mask = morphology.remove_small_objects(
160160
epith_all,
161-
min_size=min_size,
161+
max_size=min_size - 1, # scikit-image >0.26.0
162162
).astype("uint8")
163163
epith_edited = epith_mask * ls_map
164164
epith_edited = epith_edited.astype("uint8")

tiatoolbox/models/architecture/micronet.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ def postproc(
603603
pred_map = raw_maps[0].compute() if is_dask else raw_maps[0]
604604
pred_bin = np.argmax(pred_map, axis=2)
605605
pred_inst = ndimage.label(pred_bin)[0]
606-
pred_inst = morphology.remove_small_objects(pred_inst, min_size=50)
606+
pred_inst = morphology.remove_small_objects(pred_inst, max_size=49)
607607
canvas = np.zeros(pred_inst.shape[:2], dtype=np.int32)
608608
# if margin is zero, there could be arrays of size zero.
609609
max_value = 0 if not np.any(pred_inst) else np.max(pred_inst)

tiatoolbox/models/architecture/nuclick.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ def postproc(
619619
620620
"""
621621
masks = preds > thresh
622-
masks = remove_small_objects(masks, min_size=min_size)
622+
masks = remove_small_objects(masks, max_size=min_size - 1)
623623
masks = remove_small_holes(masks, area_threshold=min_hole_size)
624624
if do_reconstruction:
625625
for i in range(len(masks)):

0 commit comments

Comments
 (0)