Skip to content

Commit 4a755e8

Browse files
author
donglaiw
committed
fix bug: make bg=-1 for skeleton_aware_distance_transform
1 parent 2961857 commit 4a755e8

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

connectomics/data/utils/data_transform.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,8 @@ 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
160+
if bg_value != 0:
161+
distance[distance == 0] = bg_value
161162
if padding:
162163
# Unpad the output array to preserve original shape.
163164
distance = array_unpad(distance, get_padsize(
@@ -209,7 +210,7 @@ def skeleton_aware_distance_transform(
209210
all_bg_sample = False
210211

211212
skeleton = np.zeros(label_shape, dtype=np.uint8)
212-
distance = np.zeros(label_shape, dtype=np.float32) + bg_value
213+
distance = np.zeros(label_shape, dtype=np.float32)
213214
semantic = np.zeros(label_shape, dtype=np.uint8)
214215

215216
indices = np.unique(label)
@@ -250,6 +251,9 @@ def skeleton_aware_distance_transform(
250251
energy = energy ** alpha
251252
distance = np.maximum(distance, energy * temp2.astype(np.float32))
252253

254+
if bg_value != 0:
255+
distance[distance==0] = bg_value
256+
253257
if padding:
254258
# Unpad the output array to preserve original shape.
255259
distance = array_unpad(distance, get_padsize(

0 commit comments

Comments
 (0)