Skip to content

Commit 143bda5

Browse files
committed
fix: fix the tresholding in dcan post-proc
1 parent 80218fb commit 143bda5

File tree

1 file changed

+4
-3
lines changed
  • cellseg_models_pytorch/postproc/functional

1 file changed

+4
-3
lines changed

cellseg_models_pytorch/postproc/functional/dcan.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,12 @@
3232
import skimage.morphology as morph
3333

3434
from cellseg_models_pytorch.transforms import percentile_normalize99
35-
from cellseg_models_pytorch.utils import naive_thresh_prob
3635

3736
__all__ = ["post_proc_dcan"]
3837

3938

4039
def post_proc_dcan(
41-
prob_map: np.ndarray, contour_map: np.ndarray, **kwargs
40+
prob_map: np.ndarray, contour_map: np.ndarray, thresh: float = 0.5, **kwargs
4241
) -> np.ndarray:
4342
"""DCAN post-processing pipeline.
4443
@@ -50,6 +49,8 @@ def post_proc_dcan(
5049
Probablilty map. Shape (H, W).
5150
contour_map : np.ndarray
5251
Contour map. Shape (H, W).
52+
thresh : float, default=0.5
53+
Threshold for the difference between prob_map and contour_map.
5354
5455
Returns
5556
-------
@@ -58,7 +59,7 @@ def post_proc_dcan(
5859
"""
5960
contour_map = percentile_normalize99(contour_map, amin=-1, amax=1)
6061
sub = prob_map - contour_map
61-
pre_insts = ndi.label(naive_thresh_prob(sub))[0]
62+
pre_insts = ndi.label((sub >= thresh).astype(int))[0]
6263

6364
inst_ids = np.unique(pre_insts)[1:]
6465
disk = morph.disk(3)

0 commit comments

Comments
 (0)