1

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?

3
  • 3
    The link is dead. Commented May 7, 2017 at 12:59
  • 3
    a.max() - a or a.max() - a + a.min() if you don't care or do for the range of values in output? Commented May 7, 2017 at 13:02
  • 2
    @Divakar, just a minor note: a.max()+a.min()-a is better than a.max()-a+a.min() because it avoids creating unnecessary temp arrays. Commented May 7, 2017 at 13:08

1 Answer 1

4

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

arr2 = arr.max() + arr.min() - arr
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.