-
Notifications
You must be signed in to change notification settings - Fork 36
Frequently Asked Questions (FAQ)
William Silversmith edited this page Jun 3, 2021
·
1 revision
Hi fellow distance transform fans. I figure I'll just jot some FAQ notes here until I can more formally integrate them into the repo somehow.
The signed distance transform is usually defined as positive in the interior of an object and negative in the exterior of the object. The library only provides positive values, how can we achieve a signed distance transform?
Maybe we should support this more formally, but here's a quick way to do it. We first mask the background (the presumed negative space) and then apply a negative sign to the masked pixels after the transform completes.
import edt
import numpy as np
labels = ... # some 3d voxel source
new_bg = np.max(labels) + 1
labels += (labels == 0) * new_bg
dt = edt.edt(labels, anisotropy=(1,1,1))
dt[labels == new_bg] *= -1