python 简单计算质心的方法

from scipy import ndimage
import numpy as np

a= np.array([
    [0,  0,  0,  0],
    [0,  1,  0,  0],
    [0,  2,  0,  0],
    [1,  0,  0,  0],
    [1,  1,  0,  1],
    [1,  2,  0,  1],
    [2,  0,  0,  0],
    [2,  1,  0,  0],
    [2,  2,  0,  0]
])

b = np.mean(a,axis=0)

print(b)

'''
[1.         1.         0.         0.22222222]
'''

你可能感兴趣的:(python3,python,numpy,质心)