Guest User

Untitled

a guest
Jan 18th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. a = np.arange(16).reshape(4,4)
  2. array([[ 0, 1, 2, 3],
  3. [ 4, 5, 6, 7],
  4. [ 8, 9, 10, 11],
  5. [12, 13, 14, 15]])
  6. b = a[::2,1::2] and at the same time a[1::2,::2]
  7. array([[ 1, 3],
  8. [ 4, 6],
  9. [9, 11],
  10. [12,14]])
  11.  
  12. a = np.arange(16).reshape(4,4)
  13. array([[ 0, 1, 2, 3],
  14. [ 4, 5, 6, 7],
  15. [ 8, 9, 10, 11],
  16. [12, 13, 14, 15]])
  17. b = np.zeros((a.shape[0], a.shape[1]/2))
  18. b[::2,:] = a[::2,1::2]
  19. b[1::2,:] = a[1::2,::2]
  20. >>>> b
  21. array([[ 1., 3.],
  22. [ 4., 6.],
  23. [ 9., 11.],
  24. [ 12., 14.]])
Add Comment
Please, Sign In to add comment