Guest User

Untitled

a guest
Aug 3rd, 2012
119
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import numpy as np
  2. import numpy.ma
  3.  
  4. a=np.array([[[1,2,0],[1,2,7],[5,2,4]],
  5.             [[1,6,3],[1,2,3],[5,2,4]]])
  6. print a.max(axis=2)
  7.  
  8. argmax=np.argmax(a, axis=2)
  9. mask=np.zeros_like(a)
  10.  
  11. for i in xrange(mask.shape[0]):
  12.     for j in xrange(mask.shape[1]):
  13.         mask[i,j,argmax[i,j]]=1  
  14.  
  15. a=np.ma.masked_array(a, mask=mask)
  16. print a.max(axis=2)
RAW Paste Data