1

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!

1 Answer 1

4

Using NumPy assignment to an indexed array:

img[thr != 0] = [255,255,255]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.