如果这个标题不是新名词的话。在
假设我们有一个numpy数组作为世界地图。
参数是(x y r g b)-都是int16
示例:
a = np.array([[ 0, 0, 0, 255, 0], #index 0
[ 0, 1, 0, 0, 255], #index 1
[ 0, 2, 0, 255, 0]]) #index 2
现在我们要找到x和y值(0,2)的行的索引值,因此是索引为2的行。在
^{pr2}$
在不输入其他值(rgb)的情况下,我如何做到这一点?基本上,我们正在搜索一个包含两个值的五值行-我该怎么做?在
Tags:
您可以将行切片到第二列,并检查它们是否等于} 设置}将满足所有条件的设置为
[0,2]
。然后使用^{axis
到{True
,并使用布尔数组索引ndarray
:以下是您的数据:
下面是获取包含[a,b]的行索引的解决方案:
^{pr2}$输出:
说明:
了解其工作原理的最佳方法是打印每个部分:
输出:
输出:
输出:
[假-假-真]
相关问题 更多 >
编程相关推荐