In [1]:
%pylab inline

import numpy as np
import scipy.ndimage

seeds = np.zeros([8, 10])

seeds[1:7, 8] = 1
seeds[6, 5] = 2
seeds[2, 0] = 3

seeds

plt.imshow(seeds, interpolation="nearest")


Populating the interactive namespace from numpy and matplotlib
Out[1]:
<matplotlib.image.AxesImage at 0x27c2da44400>

In [2]:
dist ,inds = scipy.ndimage.morphology.distance_transform_edt(seeds==0, return_indices=True, return_distances=True)
display(inds)
plt.imshow(dist, interpolation="nearest")
# display(dist)


array([[[2, 2, 2, 2, 1, 1, 1, 1, 1, 1],
        [2, 2, 2, 2, 1, 1, 1, 1, 1, 1],
        [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],
        [2, 2, 2, 2, 6, 6, 3, 3, 3, 3],
        [2, 2, 2, 6, 6, 6, 4, 4, 4, 4],
        [2, 2, 6, 6, 6, 6, 6, 5, 5, 5],
        [2, 6, 6, 6, 6, 6, 6, 6, 6, 6],
        [2, 6, 6, 6, 6, 6, 6, 6, 6, 6]],

       [[0, 0, 0, 0, 8, 8, 8, 8, 8, 8],
        [0, 0, 0, 0, 8, 8, 8, 8, 8, 8],
        [0, 0, 0, 0, 0, 8, 8, 8, 8, 8],
        [0, 0, 0, 0, 5, 5, 8, 8, 8, 8],
        [0, 0, 0, 5, 5, 5, 8, 8, 8, 8],
        [0, 0, 5, 5, 5, 5, 5, 8, 8, 8],
        [0, 5, 5, 5, 5, 5, 5, 8, 8, 8],
        [0, 5, 5, 5, 5, 5, 5, 8, 8, 8]]])
Out[2]:
<matplotlib.image.AxesImage at 0x27c2db59be0>

In [ ]:
plt.imshow(dist, interpolation="nearest")