mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-05 08:31:31 +08:00
Better handling of labeled pixels in random walker segmentation when we
return the whole probability.
This commit is contained in:
@@ -350,6 +350,11 @@ def random_walker(data, labels, beta=130, mode='bf', tol=1.e-3, copy=True,
|
||||
labels = labels.astype(np.float)
|
||||
X = np.array([_clean_labels_ar(Xline, labels,
|
||||
copy=True).reshape(data.shape) for Xline in X])
|
||||
for i in range(1, int(labels.max()) + 1):
|
||||
mask_i = np.squeeze(labels == i)
|
||||
X[i - 1, mask_i] = 1
|
||||
X[np.setdiff1d(np.arange(0, labels.max(), dtype=np.int),
|
||||
[i - 1]), mask_i] = 0
|
||||
else:
|
||||
X = _clean_labels_ar(X + 1, labels).reshape(data.shape)
|
||||
return X
|
||||
|
||||
@@ -58,7 +58,7 @@ def test_2d_bf():
|
||||
return_full_prob=True)
|
||||
assert (full_prob_bf[1, 25:45, 40:60] >=
|
||||
full_prob_bf[0, 25:45, 40:60]).all()
|
||||
return data, labels_bf
|
||||
return data, labels_bf, full_prob_bf
|
||||
|
||||
|
||||
def test_2d_cg():
|
||||
|
||||
Reference in New Issue
Block a user