2019-01-21
阅读量:
672
有没有办法在多个值上运行np.where而不是一个?
我想知道我是否有一个numpy数组中的图像,比如250x250x3(3个通道),是否可以使用np.where来快速找出大小为3的250x250数组是否等于[143,255, 0]或rgb代表的另一种颜色得到一个250x250的bool阵列?
当我在4x4x3的代码中尝试时,我得到了一个3x3阵列,我不能完全确定它的形状来自哪里。
import numpy as np
test = np.arange(4,52).reshape(4,4,3)
print(np.where(test == [4,5,6]))
-------------------------------------------
Result:
array([[0, 0, 0],
[0, 0, 0],
[0, 1, 2]])
What I'm trying to get:
array([[1, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0]])






评论(0)


暂无数据
推荐帖子
0条评论
0条评论
0条评论