我想要在numpy图像数组中获取给定值的x和y坐标。在python数组中查找值的X和Y坐标
我可以通过使用for语句手动运行行和列来完成此操作,但这看起来相当慢,而且我正面有更好的方法来执行此操作。
我试图修改我在本文中找到的解决方案。 Finding the (x,y) indexes of specific (R,G,B) color values from images stored in NumPy ndarrays
a = image
c = intensity_value
y_locs = np.where(np.all(a == c, axis=0))
x_locs = np.where(np.all(a == c, axis=1))
return np.int64(x_locs), np.int64(y_locs)
我有np.int64将值转换回int64。
那么到底什么是你现在的问题? – Kasramvd 2015-04-04 21:17:31