Skip to content

Commit 2961857

Browse files
author
donglaiw
committed
fix bug: make bg=-1 for distance_transform
1 parent b21b007 commit 2961857

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

connectomics/data/utils/data_transform.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def distance_transform(label: np.ndarray,
137137

138138
label_shape = label.shape
139139
all_bg_sample = False
140-
distance = np.zeros(label_shape, dtype=np.float32) + bg_value
140+
distance = np.zeros(label_shape, dtype=np.float32)
141141
semantic = np.zeros(label_shape, dtype=np.uint8)
142142

143143
indices = np.unique(label)
@@ -157,6 +157,7 @@ def distance_transform(label: np.ndarray,
157157
energy = boundary_edt / (boundary_edt.max() + eps) # normalize
158158
distance = np.maximum(distance, energy * temp2.astype(np.float32))
159159

160+
distance[distance == 0] = bg_value
160161
if padding:
161162
# Unpad the output array to preserve original shape.
162163
distance = array_unpad(distance, get_padsize(

0 commit comments

Comments
 (0)