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

Euclidean distance & signed distance transform for multi-label 3D anisotropic images using marching parabolas.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Signed Distance Function

william-silversmith opened this issue · comments

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