Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- a = np.arange(16).reshape(4,4)
- array([[ 0, 1, 2, 3],
- [ 4, 5, 6, 7],
- [ 8, 9, 10, 11],
- [12, 13, 14, 15]])
- b = a[::2,1::2] and at the same time a[1::2,::2]
- array([[ 1, 3],
- [ 4, 6],
- [9, 11],
- [12,14]])
- a = np.arange(16).reshape(4,4)
- array([[ 0, 1, 2, 3],
- [ 4, 5, 6, 7],
- [ 8, 9, 10, 11],
- [12, 13, 14, 15]])
- b = np.zeros((a.shape[0], a.shape[1]/2))
- b[::2,:] = a[::2,1::2]
- b[1::2,:] = a[1::2,::2]
- >>>> b
- array([[ 1., 3.],
- [ 4., 6.],
- [ 9., 11.],
- [ 12., 14.]])
Add Comment
Please, Sign In to add comment