Ohm
Ohm

Reputation: 2442

Python: Creating the "negative" of an array

I have this 64x64 2D array enter image description here the data for this array can be downloaded here - http://m.uploadedit.com/ba3s/1494223164755.txt

Now, I wish to make a copy of this array in which the areas that have the highest value receive the value of the areas with the lowest value and vice-versa. Is there a smart way of doing it in Python?

Upvotes: 1

Views: 77

Answers (1)

shx2
shx2

Reputation: 64318

If your data is stored in a 2dim numpy array arr, you can do:

arr2 = arr.max() + arr.min() - arr

Upvotes: 4

Related Questions