之间的差异我对Numpy来说是个新手,我无法找到符合我要求的任何东西。numpy count其中值大于
有没有什么好的方法来做count.where(value-value2> threshold)?
我有斧,y位置numpy的阵列和我需要计数最近的邻居类似于此
东西:
[(93, 256), (93, 256), (93, 256), (93, 257), (54, 130), (55,131)]
我有93/256-257和2 4个邻居在54-55/130-131
之间的差异我对Numpy来说是个新手,我无法找到符合我要求的任何东西。numpy count其中值大于
有没有什么好的方法来做count.where(value-value2> threshold)?
我有斧,y位置numpy的阵列和我需要计数最近的邻居类似于此
东西:
[(93, 256), (93, 256), (93, 256), (93, 257), (54, 130), (55,131)]
我有93/256-257和2 4个邻居在54-55/130-131
如果你只是想看看有多少次出现:
的条件是value1 - value0 > 100
x = np.array([[93, 256], [93, 256], [93, 256], [93, 257], [54, 130], [55, 131]])
y = np.where(x[:,1] - x[:,0] > 100)
print(y[0].shape[0])
如果您对x和y坐标的条件,那么你可以做这样的事情:
y = np.where((x[:,1] - 256 < 10) & (x[:,0] - 50 > 40))
希望这有助于。
有一个合适的计算邻居的方法 - numpy.isclose(a, b, atol)。一系列的4内的下列计算邻居:
threshold = 4
np.isclose([93, 256], [94, 256], atol=threshold)
结果计算到元组两点:
[True, True]
也许会有所帮助。
你的'value-value2'实际上并不是应用于元组的成员,而是应用于两个不同的元组?你有一个度量来获得两个元组之间的距离吗? – pekapa