Skip to content

Commit 6f257b6

Browse files
authored
Merge pull request #3 from GewelsJI/main
New PR about the inconsistency of numpy and matlab codes Thanks!
2 parents f5ce652 + dbeba62 commit 6f257b6

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

py_sod_metrics/sod_metrics.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from scipy.ndimage import convolve
44
from scipy.ndimage import distance_transform_edt as bwdist
55

6-
_EPS = 1e-16
6+
_EPS = np.spacing(1) # the different implementation of epsilon (extreme min value) between numpy and matlab
77
_TYPE = np.float64
88

99

@@ -238,7 +238,7 @@ def object(self, pred: np.ndarray, gt: np.ndarray) -> float:
238238

239239
def s_object(self, pred: np.ndarray, gt: np.ndarray) -> float:
240240
x = np.mean(pred[gt == 1])
241-
sigma_x = np.std(pred[gt == 1])
241+
sigma_x = np.std(pred[gt == 1], ddof=1)
242242
score = 2 * x / (np.power(x, 2) + 1 + sigma_x + _EPS)
243243
return score
244244

0 commit comments

Comments
 (0)