Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我是 numpy 的新手,我遇到了麻烦。
我有两个 numpy 数组,img 和 thr:
>>>img.shape (2448, 3264, 3) >>>thr.shape (2448, 3264)
我想做这样的事情:img[x,y] = [255,255,255]只在thr[x,y] is not 0
img[x,y] = [255,255,255]
thr[x,y] is not 0
我尝试迭代数组并自己做,但这需要很长时间,所以我真的需要numpy下面的C。我还查看了掩码数组,但我不明白如何使用它们。
谢谢!
对索引数组使用NumPy 赋值:
img[thr != 0] = [255,255,255]