Uni*_*ic0 2 numpy scipy python-3.x
我正在尝试使用ndimage.measurements.center_of_massScipy 库中的二进制图像找到质心。
我的代码如下:
def show_keypoints(image, key_point):
plt.imshow(image, interpolation='nearest')
plt.scatter(key_point[0],key_point[1], s=20, marker='.', c='lightgreen')
#Loading the image (shape : (576,576) as np.array))
img = load_img(path)
centroid = scipy.ndimage.measurements.center_of_mass(img)
fig = plt.figure()
ax = plt.subplot()
ax.set_title('Label')
show_keypoints(img, centroid)
plt.show()
Run Code Online (Sandbox Code Playgroud)
获得:
所以我检查了我是否有正确的图像作为输入,它是正确的,我使用np.unique(imgs[i])got检查了图像是否是二进制的(array([0, 1], dtype=uint8)。
我不确定这里有什么不对。
有没有人有想法?
问候,
更改参数的顺序以进行分散:
plt.scatter(key_point[1], key_point[0], s=20, marker='.', c='lightgreen')
Run Code Online (Sandbox Code Playgroud)
imshow使用基于图像的约定绘制它的数据,而scatter与plot使用通常的(X,Y)坐标。
| 归档时间: |
|
| 查看次数: |
1035 次 |
| 最近记录: |