掩码为1时numpy更改数组值 [英] numpy change array values when mask is one

查看:80
本文介绍了掩码为1时numpy更改数组值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是numpy的新手,我遇到了麻烦.

i'm new to numpy and i'm running into trouble.

我有两个numpy数组,img和thr:

I've got two numpy arrays, img and thr:

>>>img.shape
(2448, 3264, 3)
>>>thr.shape
(2448, 3264)

我想做这样的事情:仅当thr[x,y] is not 0

And i want to do something like this: set img[x,y] = [255,255,255] only when thr[x,y] is not 0

我尝试遍历数组并自己做,但是需要很长时间,所以我真的需要在numpy下使用C.我也看了屏蔽数组,但是我不明白如何使用它们.

I tried iterating over the array and do it myself but it takes a long time, so i really need the C underneath numpy. I also took a look to masked arrays but i didn't understand how to use them.

谢谢!

推荐答案

使用 查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆