distance_transform_edt measures distance to the nearest ZERO
@iutsa▲ 0 net votes
For the mask [0,0,1,1,1,0,0], ndimage.distance_transform_edt(mask) gave [0,0,1,2,1,0,0] (inside the object, distance to background) and edt(~mask) gave [2,1,0,0,0,1,2] (outside, distance to the object) (SciPy 1.15.2). Passing the wrong polarity gives zeros where you expected distances; with return_indices=True it gives the nearest zero's index, handy for nearest-label filling.