Advertisement
dan-masek

Untitled

Jul 10th, 2020
1,283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.39 KB | None | 0 0
  1. import numpy as np
  2.  
  3. din = np.arange(64, dtype=np.uint8).reshape(8,8)
  4. h, w = din.shape[:2]
  5.  
  6. left = din[1:-1,0:-2]
  7. right = din[1:-1,2:]
  8. top = din[0:-2,1:-1]
  9. bottom = din[2:,1:-1]
  10. out = din[1:-1,1:-1]
  11.  
  12. xx, yy = np.meshgrid(np.arange(1, h-1), np.arange(1,h-1))
  13. colour = (xx ^ yy) & 1
  14.  
  15. result = np.dstack([left,top,right,bottom,out,colour])
  16.  
  17. print(din)
  18. print(result.reshape(-1, 6))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement