Reputation: 127
i'm new to numpy and i'm running into trouble.
I've got two numpy arrays, img and thr:
>>>img.shape
(2448, 3264, 3)
>>>thr.shape
(2448, 3264)
And i want to do something like this: set img[x,y] = [255,255,255]
only when thr[x,y] is not 0
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.
Thanks!
Upvotes: 1
Views: 1036
Reputation: 879691
Using NumPy assignment to an indexed array:
img[thr != 0] = [255,255,255]
Upvotes: 4