Fixing immediate issue in distance_transform_lin
@@ -117,28 +117,28 @@ def distance_transform_lin(im, axis=0, mode='both'):
' Reduce dimensionality with np.squeeze(im) to avoid' +
' unexpected behavior.')
if mode in ['backward', 'reverse']:
- im = sp.flip(im, axis)
+ im = np.flip(im, axis)
im = distance_transform_lin(im=im, axis=axis, mode='forward')
- im = sp.flip(im, axis)
+ im = np.flip(im, axis)
return im
elif mode in ['both']:
im_f = distance_transform_lin(im=im, axis=axis, mode='forward')
im_b = distance_transform_lin(im=im, axis=axis, mode='backward')
return sp.minimum(im_f, im_b)
else:
- b = sp.cumsum(im > 0, axis=axis)
- c = sp.diff(b*(im == 0), axis=axis)
- d = sp.minimum.accumulate(c, axis=axis)
+ b = np.cumsum(im > 0, axis=axis)
+ c = np.diff(b*(im == 0), axis=axis)
+ d = np.minimum.accumulate(c, axis=axis)
if im.ndim == 1:
- e = sp.pad(d, pad_width=[1, 0], mode='constant', constant_values=0)
+ e = np.pad(d, pad_width=[1, 0], mode='constant', constant_values=0)
elif im.ndim == 2:
ax = [[[1, 0], [0, 0]], [[0, 0], [1, 0]]]
- e = sp.pad(d, pad_width=ax[axis], mode='constant', constant_values=0)
+ e = np.pad(d, pad_width=ax[axis], mode='constant', constant_values=0)
elif im.ndim == 3:
ax = [[[1, 0], [0, 0], [0, 0]],
[[0, 0], [1, 0], [0, 0]],
[[0, 0], [0, 0], [1, 0]]]
- e = sp.pad(d, pad_width=ax[axis], mode='constant', constant_values=0)
+ e = np.pad(d, pad_width=ax[axis], mode='constant', constant_values=0)
f = im*(b + e)
return f
