mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-16 11:21:25 +08:00
Fix label2rgb bug
This commit is contained in:
@@ -112,7 +112,7 @@ def label2rgb(label, image=None, colors=None, alpha=0.3,
|
||||
label = label - offset # Make sure you don't modify the input array.
|
||||
bg_label -= offset
|
||||
|
||||
new_type = np.min_scalar_type(label.max())
|
||||
new_type = np.min_scalar_type(int(label.max()))
|
||||
if new_type == np.bool:
|
||||
new_type = np.uint8
|
||||
label = label.astype(new_type)
|
||||
|
||||
@@ -114,11 +114,12 @@ def relabel_sequential(label_field, offset=1):
|
||||
>>> relab
|
||||
array([5, 5, 6, 6, 7, 9, 8])
|
||||
"""
|
||||
m = label_field.max()
|
||||
if not np.issubdtype(label_field.dtype, np.int):
|
||||
label_field = label_field.astype(np.int)
|
||||
new_type = np.min_scalar_type(int(m))
|
||||
label_field = label_field.astype(new_type)
|
||||
labels = np.unique(label_field)
|
||||
labels0 = labels[labels != 0]
|
||||
m = labels.max()
|
||||
if m == len(labels0): # nothing to do, already 1...n labels
|
||||
return label_field, labels, labels
|
||||
forward_map = np.zeros(m+1, int)
|
||||
|
||||
Reference in New Issue
Block a user