我正在尝试使用ndimage.measurements.center_of_mass
Scipy 库中的二进制图像找到质心。
我的代码如下:
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)
。
我不确定这里有什么不对。
有没有人有想法?
问候,
我正在尝试以一种很好的方式显示我的数据,例如在seaborn文档中看到的:
我不太确定如何继续。我设法获得了点的值及其各自的标准差,但它看起来很分散,而我只想显示一种趋势:
这是我玩的:
Final_array = Mean Std
0 0.739269 0.157892
1 0.807382 0.160464
2 0.800024 0.137239
3 0.825854 0.132472
4 0.864854 0.070544
.. ... ...
95 0.797202 0.101961
96 0.747578 0.143394
97 0.751472 0.158651
98 0.587009 0.198987
99 0.728447 0.104601
sns.set(style="darkgrid", palette="muted", color_codes=True)
fig, ax = plt.subplots(figsize=(7,5))
y_pos = np.arange(Final_array.shape[0])
ax.errorbar(y_pos, Final_array[:,0], yerr=Final_array[:,1], elinewidth=0.5)
plt.show()
Run Code Online (Sandbox Code Playgroud)
有人有想法吗?我在使用绘图方面非常初学者。可以平滑吗?并获得像seaborn图像中那样漂亮的叠加层而不是误差线?
这些可能是愚蠢的问题。
亲切的问候,