Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- din = np.arange(64, dtype=np.uint8).reshape(8,8)
- h, w = din.shape[:2]
- left = din[1:-1,0:-2]
- right = din[1:-1,2:]
- top = din[0:-2,1:-1]
- bottom = din[2:,1:-1]
- out = din[1:-1,1:-1]
- xx, yy = np.meshgrid(np.arange(1, h-1), np.arange(1,h-1))
- colour = (xx ^ yy) & 1
- result = np.dstack([left,top,right,bottom,out,colour])
- print(din)
- print(result.reshape(-1, 6))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement