从ndimage.distance_transform_bf
的文档中:
This function calculates the distance transform of the
input
, by replacing each background element (zero values), with its shortest distance to the foreground (any element non-zero).
现在让我们在代码中尝试一下:
import matplotlib.pyplot as plt
import numpy as np
from scipy import ndimage
square = np.zeros((16, 16))
square[4:-4, 4:-4] = 1
plt.imshow(square)
dist = ndimage.distance_transform_bf(square)
plt.imshow(dist)
显然,这个函数是在转换前景元素而不是背景。这是一个明显的错误还是我遗漏了什么?你知道吗
目前没有回答
相关问题 更多 >
编程相关推荐