How does the scipy distance_transform_edt function work?

后端 未结 2 928
粉色の甜心
粉色の甜心 2021-02-05 23:22

https://docs.scipy.org/doc/scipy-0.14.0/reference/generated/scipy.ndimage.morphology.distance_transform_edt.html

I\'m having trouble understanding how the Euclidean dist

2条回答
  •  余生分开走
    2021-02-05 23:53

    Warren has already explained how distance_transform_edt works. In your case,you could change sampling units along x and y

    ndimage.distance_transform_edt(a)
    array([[ 0.,  0.,  0.,  0.,  0.],
           [ 0.,  1.,  0.,  0.,  0.],
           [ 0.,  0.,  0.,  0.,  0.],
           [ 0.,  0.,  0.,  1.,  0.],
           [ 0.,  0.,  0.,  0.,  0.]])
    

    But

    >>> ndimage.distance_transform_edt(a, sampling=[2,2])
    array([[ 0.,  0.,  0.,  0.,  0.],
           [ 0.,  2.,  0.,  0.,  0.],
           [ 0.,  0.,  0.,  0.,  0.],
           [ 0.,  0.,  0.,  2.,  0.],
           [ 0.,  0.,  0.,  0.,  0.]])
    

    Or

    ndimage.distance_transform_edt(a, sampling=[3,3])
    array([[ 0.,  0.,  0.,  0.,  0.],
           [ 0.,  3.,  0.,  0.,  0.],
           [ 0.,  0.,  0.,  0.,  0.],
           [ 0.,  0.,  0.,  3.,  0.],
           [ 0.,  0.,  0.,  0.,  0.]])
    

提交回复
热议问题