File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff 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 (
You can’t perform that action at this time.
0 commit comments