seung-lab / euclidean-distance-transform-3d

Euclidean distance & signed distance transform for multi-label 3D anisotropic images using marching parabolas.
GNU General Public License v3.0
234 stars 37 forks source link

Signed Distance Function #43

Closed william-silversmith closed 2 years ago

william-silversmith commented 2 years ago

Should be pretty easy to make. Something like?

edt.edt(labels) - edt.edt(~labels)

Might be faster to do one pass with edt:

max_label = np.max(labels) + 1
mask = (labels == 0)
sdf = edt.edt(labels + mask * max_label)
sdf[mask] *= -1 # alternative 1
sdf = (sdf * -mask) + (sdf * ~mask) # alternative 2